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")); } } }