From 1b593106abab057097fdd9fcd22f9c62e18d43a3 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sun, 17 Apr 2022 21:37:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=A9=E5=9B=BE=E6=A8=A1=E5=9D=97=EF=BC=9A?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E6=AD=A3=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yutou/qqbot/models/setu/GetSeTu.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) 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, ""); - } - }); + } }