涩图模块:搜索不到后会尝试搜索非18、模糊搜索
This commit is contained in:
parent
086d773ac0
commit
19a9fb0d1b
@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class QQBotApplication {
|
||||
public static final String version="QQBot v.1.2.18";
|
||||
public static final String version="QQBot v.1.2.19";
|
||||
public static void main(String[] args) {
|
||||
System.out.println("version = " + version);
|
||||
SpringApplication.run(QQBotApplication.class, args);
|
||||
|
@ -47,27 +47,40 @@ public class GetSeTu extends Model {
|
||||
if (isRun) {
|
||||
Log.i(event.getSource().getFromId() + " > " + msg);
|
||||
Pattern pattern = Pattern.compile("来点(.*?)色图");
|
||||
Matcher matcher=pattern.matcher(msg);
|
||||
String key=null;
|
||||
if(matcher.find()){
|
||||
key=matcher.group(1);
|
||||
Matcher matcher = pattern.matcher(msg);
|
||||
String key = null;
|
||||
if (matcher.find()) {
|
||||
key = matcher.group(1);
|
||||
}
|
||||
if (!getSeTu("tag", key, isR18, false, qq, event)) {
|
||||
if (!getSeTu("tag", key, isR18, true, qq, event)) {
|
||||
if (!getSeTu("dec", key, isR18, true, qq, event)) {
|
||||
QQBotManager.getInstance().sendMessage(qq, "找不到喵~");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getSeTu(String model, String key, boolean r18, boolean fuzzyR18, Long qq, MessageEvent event) {
|
||||
String url = "https://api.lolicon.app/setu/v2?r18=0&size=regular";
|
||||
if (isR18) {
|
||||
if (r18) {
|
||||
url = "https://api.lolicon.app/setu/v2?r18=1&size=regular";
|
||||
}
|
||||
if (!StringUtils.isEmpty(key)) {
|
||||
if (isR18) {
|
||||
url = "https://api.lolicon.app/setu/v2?tag=" + URLEncoder.encode(key, StandardCharsets.UTF_8) + "&r18=1&size=regular";
|
||||
if (r18) {
|
||||
url = "https://api.lolicon.app/setu/v2?" + model + "=" + URLEncoder.encode(key, StandardCharsets.UTF_8) + "&r18=1&size=regular";
|
||||
} else {
|
||||
url = "https://api.lolicon.app/setu/v2?tag=" + URLEncoder.encode(key, StandardCharsets.UTF_8) + "&r18=0&size=regular";
|
||||
url = "https://api.lolicon.app/setu/v2?" + model + "=" + URLEncoder.encode(key, StandardCharsets.UTF_8) + "&r18=0&size=regular";
|
||||
}
|
||||
}
|
||||
if (fuzzyR18) {
|
||||
url = url.replace("&r18=0", "&r18=2").replace("&r18=1", "&r18=2");
|
||||
}
|
||||
String ret = HttpTools.get(url);
|
||||
JSONObject json = JSONObject.parseObject(ret);
|
||||
if (json.getJSONArray("data").size() == 0) {
|
||||
QQBotManager.getInstance().sendMessage(qq, "找不到喵~");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
JSONObject item = json.getJSONArray("data").getJSONObject(0);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@ -91,7 +104,7 @@ public class GetSeTu extends Model {
|
||||
@Override
|
||||
public void onDownload(File file) {
|
||||
super.onDownload(file);
|
||||
QQBotManager.getInstance().sendMessage(file, qq,event.getMessage(), builder.toString());
|
||||
QQBotManager.getInstance().sendMessage(file, qq, event.getMessage(), builder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -101,16 +114,16 @@ public class GetSeTu extends Model {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String msg="来点1色图";
|
||||
String msg = "来点1色图";
|
||||
Pattern pattern = Pattern.compile("来点(.*?)色图");
|
||||
Matcher matcher=pattern.matcher(msg);
|
||||
String key=null;
|
||||
if(matcher.find()){
|
||||
key=matcher.group(1);
|
||||
Matcher matcher = pattern.matcher(msg);
|
||||
String key = null;
|
||||
if (matcher.find()) {
|
||||
key = matcher.group(1);
|
||||
}
|
||||
System.out.println("key = " + key);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user