涩图模块:区分色图和涩图关键词
This commit is contained in:
parent
4e56d31e43
commit
10fd1d6863
@ -33,28 +33,42 @@ public class GetSeTu extends Model {
|
||||
@Override
|
||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||
super.onMessage(qq, event, isGroup);
|
||||
if (msg.startsWith("来点")&&(msg.endsWith("色图")||msg.endsWith("涩图"))) {
|
||||
Log.i(event.getSource().getFromId()+" > "+msg);
|
||||
String key=msg.replace("来点","").replace("色图","").replace("涩图","");
|
||||
String url="https://api.lolicon.app/setu/v2?r18=2";
|
||||
if(!StringUtils.isEmpty(key)){
|
||||
url="https://api.lolicon.app/setu/v2?tag="+ URLEncoder.encode(key, StandardCharsets.UTF_8)+"&r18=2";
|
||||
boolean isRun = false;
|
||||
boolean isR18 = false;
|
||||
if (msg.contains("来点") && msg.contains("色图")) {
|
||||
isRun = true;
|
||||
} else if (msg.contains("来点") && msg.contains("涩图")) {
|
||||
isRun = true;
|
||||
isR18 = true;
|
||||
}
|
||||
if (isRun) {
|
||||
Log.i(event.getSource().getFromId() + " > " + msg);
|
||||
String key = msg.replace("来点", "").replace("色图", "").replace("涩图", "");
|
||||
String url = "https://api.lolicon.app/setu/v2?r18=0";
|
||||
if (isR18) {
|
||||
url = "https://api.lolicon.app/setu/v2?r18=1";
|
||||
}
|
||||
if (!StringUtils.isEmpty(key)) {
|
||||
if (isR18) {
|
||||
url = "https://api.lolicon.app/setu/v2?tag=" + URLEncoder.encode(key, StandardCharsets.UTF_8) + "&r18=1";
|
||||
} else {
|
||||
url = "https://api.lolicon.app/setu/v2?tag=" + URLEncoder.encode(key, StandardCharsets.UTF_8) + "&r18=0";
|
||||
}
|
||||
}
|
||||
String ret = HttpTools.get(url);
|
||||
JSONObject json = JSONObject.parseObject(ret);
|
||||
System.out.println("json = " + json);
|
||||
if(json.getJSONArray("data").size()==0){
|
||||
QQBotManager.getInstance().sendMessage(qq,"找不到喵~");
|
||||
if (json.getJSONArray("data").size() == 0) {
|
||||
QQBotManager.getInstance().sendMessage(qq, "找不到喵~");
|
||||
return;
|
||||
}
|
||||
JSONObject item=json.getJSONArray("data").getJSONObject(0);
|
||||
StringBuilder builder=new StringBuilder();
|
||||
JSONObject item = json.getJSONArray("data").getJSONObject(0);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(item.getString("title"));
|
||||
builder.append("\n");
|
||||
builder.append("R18:");
|
||||
if(item.getBoolean("r18")){
|
||||
if (item.getBoolean("r18")) {
|
||||
builder.append("YES!");
|
||||
}else{
|
||||
} else {
|
||||
builder.append("NO~");
|
||||
}
|
||||
builder.append("\n");
|
||||
@ -63,7 +77,7 @@ public class GetSeTu extends Model {
|
||||
builder.append(tags).append("、");
|
||||
}
|
||||
HttpTools.download(item.getJSONObject("urls").getString("original"),
|
||||
System.currentTimeMillis()+"_setu.jpg",
|
||||
System.currentTimeMillis() + "_setu.jpg",
|
||||
true
|
||||
, new DownloadInterface() {
|
||||
@Override
|
||||
@ -75,7 +89,7 @@ public class GetSeTu extends Model {
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
super.onError(e);
|
||||
QQBotManager.getInstance().sendMessage(qq,"获取失败喵~");
|
||||
QQBotManager.getInstance().sendMessage(qq, "获取失败喵~");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user