From 93be2a0ad8f7ef79a34afec4643b9f91e00cfb7f Mon Sep 17 00:00:00 2001 From: yutou Date: Tue, 22 Jun 2021 09:55:11 +0800 Subject: [PATCH] =?UTF-8?q?idea=E6=BF=80=E6=B4=BB=E7=A0=81=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=9C=B0=E5=9D=80=E6=94=B9=E4=B8=BA=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/yutou/nas/NasApplication.java | 2 +- src/main/java/com/yutou/nas/utils/IdeaTools.java | 4 ++-- .../java/com/yutou/nas/utils/QQBotManager.java | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/yutou/nas/NasApplication.java b/src/main/java/com/yutou/nas/NasApplication.java index 6d02f39..072da37 100644 --- a/src/main/java/com/yutou/nas/NasApplication.java +++ b/src/main/java/com/yutou/nas/NasApplication.java @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import; @Import(BTDownloadManager.class) @SpringBootApplication public class NasApplication { - public static final String version="1.1.4.2"; + public static final String version="1.1.5"; public static void main(String[] args) { SpringApplication.run(NasApplication.class, args); AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); diff --git a/src/main/java/com/yutou/nas/utils/IdeaTools.java b/src/main/java/com/yutou/nas/utils/IdeaTools.java index 18d2386..07aac77 100644 --- a/src/main/java/com/yutou/nas/utils/IdeaTools.java +++ b/src/main/java/com/yutou/nas/utils/IdeaTools.java @@ -31,8 +31,8 @@ public class IdeaTools { return ""; } - public static List getIdeaList() { - File file = HttpTools.syncDownload("http://idea.medeming.com/a/jihuoma.zip", "idea.zip"); + public static List getIdeaList(String url) { + File file = HttpTools.syncDownload(url, "idea.zip"); List list = new ArrayList<>(); try { ZipFile zip = new ZipFile(file, Charset.forName("gbk")); diff --git a/src/main/java/com/yutou/nas/utils/QQBotManager.java b/src/main/java/com/yutou/nas/utils/QQBotManager.java index 0223971..aa2ec31 100644 --- a/src/main/java/com/yutou/nas/utils/QQBotManager.java +++ b/src/main/java/com/yutou/nas/utils/QQBotManager.java @@ -13,6 +13,7 @@ import net.mamoe.mirai.message.data.Image; import net.mamoe.mirai.message.data.MessageChainBuilder; import net.mamoe.mirai.utils.BotConfiguration; import net.mamoe.mirai.utils.ExternalResource; +import org.springframework.util.StringUtils; import java.io.File; import java.lang.reflect.Field; @@ -45,6 +46,7 @@ public class QQBotManager { private final static String QQ_BT_RELOAD = "!刷bt"; private final static String QQ_TOOLS_IDEA = "!idea"; private final static String QQ_TOOLS_IDEA_FILE = "!idea>"; + private final static String QQ_TOOLS_IDEA_URL = "!idea_url"; } private static QQBotManager botManager = null; @@ -279,8 +281,15 @@ public class QQBotManager { break; case QQCommands.QQ_TOOLS_IDEA: builder = new StringBuilder(); - for (String name : IdeaTools.getIdeaList()) { - builder.append(QQCommands.QQ_TOOLS_IDEA_FILE).append(name).append("\n"); + if(StringUtils.isEmpty(RedisTools.get("ideaUrl"))){ + builder.append("暂未设置IDEA激活码下载地址"); + }else { + for (String name : IdeaTools.getIdeaList(RedisTools.get("ideaUrl"))) { + builder.append(QQCommands.QQ_TOOLS_IDEA_FILE).append(name).append("\n"); + } + if(builder.toString().trim().length()==0){ + builder.append("激活码文件中未包含txt文件"); + } } getInstance().sendMessage(builder.toString()); break; @@ -311,6 +320,9 @@ public class QQBotManager { QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, "")); }else if(msg.startsWith(QQCommands.QQ_TOOLS_IDEA_FILE)){ getInstance().sendMessage(IdeaTools.getIdea(msg.replace(QQCommands.QQ_TOOLS_IDEA_FILE,""))); + }else if(msg.startsWith(QQCommands.QQ_TOOLS_IDEA_URL)){ + RedisTools.set("ideaUrl",msg.replace(QQCommands.QQ_TOOLS_IDEA_URL,"").trim()); + getInstance().sendMessage("已设定下载地址:"+RedisTools.get("ideaUrl")); } } }