diff --git a/src/main/java/com/yutou/qqbot/models/setu/GetSeTu.java b/src/main/java/com/yutou/qqbot/models/setu/GetSeTu.java index ad03d0b..3332d3a 100644 --- a/src/main/java/com/yutou/qqbot/models/setu/GetSeTu.java +++ b/src/main/java/com/yutou/qqbot/models/setu/GetSeTu.java @@ -13,6 +13,8 @@ import net.mamoe.mirai.message.data.MessageChainBuilder; import java.io.File; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class GetSeTu extends Model { @Override @@ -40,10 +42,16 @@ public class GetSeTu extends Model { } else if (msg.contains("来点") && msg.contains("涩图")) { isRun = true; isR18 = true; + msg = msg.replace("涩图", "色图"); } if (isRun) { Log.i(event.getSource().getFromId() + " > " + msg); - String key = msg.replace("来点", "").replace("色图", "").replace("涩图", ""); + Pattern pattern = Pattern.compile("来点(.*?)色图"); + Matcher matcher=pattern.matcher(msg); + String key=null; + if(matcher.find()){ + key=matcher.group(1); + } String url = "https://api.lolicon.app/setu/v2?r18=0&size=regular"; if (isR18) { url = "https://api.lolicon.app/setu/v2?r18=1&size=regular"; @@ -96,21 +104,6 @@ public class GetSeTu extends Model { } public static void main(String[] args) { - QQBotManager.getInstance(); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - String ret = HttpTools.get("https://api.ixiaowai.cn/api/api.php?return=json"); - JSONObject json = JSONObject.parseObject(ret); - HttpTools.download(json.getString("imgurl"), - "setu.jpg", new DownloadInterface() { - @Override - public void onDownload(File file) { - super.onDownload(file); - QQBotManager.getInstance().sendMessage(file, 583819556L, ""); - } - }); + } }