涩图模块:区分色图和涩图关键词
This commit is contained in:
parent
4e56d31e43
commit
10fd1d6863
@ -33,16 +33,30 @@ public class GetSeTu extends Model {
|
|||||||
@Override
|
@Override
|
||||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||||
super.onMessage(qq, event, isGroup);
|
super.onMessage(qq, event, isGroup);
|
||||||
if (msg.startsWith("来点")&&(msg.endsWith("色图")||msg.endsWith("涩图"))) {
|
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);
|
Log.i(event.getSource().getFromId() + " > " + msg);
|
||||||
String key = msg.replace("来点", "").replace("色图", "").replace("涩图", "");
|
String key = msg.replace("来点", "").replace("色图", "").replace("涩图", "");
|
||||||
String url="https://api.lolicon.app/setu/v2?r18=2";
|
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 (!StringUtils.isEmpty(key)) {
|
||||||
url="https://api.lolicon.app/setu/v2?tag="+ URLEncoder.encode(key, StandardCharsets.UTF_8)+"&r18=2";
|
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);
|
String ret = HttpTools.get(url);
|
||||||
JSONObject json = JSONObject.parseObject(ret);
|
JSONObject json = JSONObject.parseObject(ret);
|
||||||
System.out.println("json = " + json);
|
|
||||||
if (json.getJSONArray("data").size() == 0) {
|
if (json.getJSONArray("data").size() == 0) {
|
||||||
QQBotManager.getInstance().sendMessage(qq, "找不到喵~");
|
QQBotManager.getInstance().sendMessage(qq, "找不到喵~");
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user