idea激活码下载地址改为动态配置

This commit is contained in:
yutou 2021-06-22 09:55:11 +08:00
parent 3fcf1e72cc
commit 93be2a0ad8
3 changed files with 17 additions and 5 deletions

View File

@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
@Import(BTDownloadManager.class) @Import(BTDownloadManager.class)
@SpringBootApplication @SpringBootApplication
public class NasApplication { 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) { public static void main(String[] args) {
SpringApplication.run(NasApplication.class, args); SpringApplication.run(NasApplication.class, args);
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");

View File

@ -31,8 +31,8 @@ public class IdeaTools {
return ""; return "";
} }
public static List<String> getIdeaList() { public static List<String> getIdeaList(String url) {
File file = HttpTools.syncDownload("http://idea.medeming.com/a/jihuoma.zip", "idea.zip"); File file = HttpTools.syncDownload(url, "idea.zip");
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
try { try {
ZipFile zip = new ZipFile(file, Charset.forName("gbk")); ZipFile zip = new ZipFile(file, Charset.forName("gbk"));

View File

@ -13,6 +13,7 @@ import net.mamoe.mirai.message.data.Image;
import net.mamoe.mirai.message.data.MessageChainBuilder; import net.mamoe.mirai.message.data.MessageChainBuilder;
import net.mamoe.mirai.utils.BotConfiguration; import net.mamoe.mirai.utils.BotConfiguration;
import net.mamoe.mirai.utils.ExternalResource; import net.mamoe.mirai.utils.ExternalResource;
import org.springframework.util.StringUtils;
import java.io.File; import java.io.File;
import java.lang.reflect.Field; 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_BT_RELOAD = "!刷bt";
private final static String QQ_TOOLS_IDEA = "!idea"; private final static String QQ_TOOLS_IDEA = "!idea";
private final static String QQ_TOOLS_IDEA_FILE = "!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; private static QQBotManager botManager = null;
@ -279,8 +281,15 @@ public class QQBotManager {
break; break;
case QQCommands.QQ_TOOLS_IDEA: case QQCommands.QQ_TOOLS_IDEA:
builder = new StringBuilder(); builder = new StringBuilder();
for (String name : IdeaTools.getIdeaList()) { if(StringUtils.isEmpty(RedisTools.get("ideaUrl"))){
builder.append(QQCommands.QQ_TOOLS_IDEA_FILE).append(name).append("\n"); 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()); getInstance().sendMessage(builder.toString());
break; break;
@ -311,6 +320,9 @@ public class QQBotManager {
QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, "")); QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, ""));
}else if(msg.startsWith(QQCommands.QQ_TOOLS_IDEA_FILE)){ }else if(msg.startsWith(QQCommands.QQ_TOOLS_IDEA_FILE)){
getInstance().sendMessage(IdeaTools.getIdea(msg.replace(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"));
} }
} }
} }