diff --git a/pom.xml b/pom.xml index 972aaa2..b839d2f 100644 --- a/pom.xml +++ b/pom.xml @@ -35,17 +35,17 @@ net.mamoe mirai-core-jvm - 2.10.4 + 2.11.1 org.jetbrains.kotlinx kotlinx-coroutines-jdk8 - 1.6.1-native-mt + 1.6.2 org.jetbrains.kotlinx kotlinx-coroutines-core-jvm - 1.6.1-native-mt + 1.6.2 @@ -60,7 +60,7 @@ com.alibaba.fastjson2 fastjson2 - 2.0.6 + 2.0.7 @@ -117,18 +117,25 @@ com.google.zxing core - 3.4.1 + 3.5.0 com.google.protobuf protobuf-java - 3.20.1 + 3.21.1 com.google.protobuf protobuf-java-util - 3.20.1 + 3.21.1 + + + + org.reflections + reflections + 0.10.2 diff --git a/src/main/java/com/yutou/qqbot/QQBotApplication.java b/src/main/java/com/yutou/qqbot/QQBotApplication.java index 99bb40e..9b7b636 100644 --- a/src/main/java/com/yutou/qqbot/QQBotApplication.java +++ b/src/main/java/com/yutou/qqbot/QQBotApplication.java @@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class QQBotApplication { - public static final String version="QQBot v.1.2.29"; + public static final String version="QQBot v.1.3"; public static void main(String[] args) { System.out.println("version = " + version); SpringApplication.run(QQBotApplication.class, args); diff --git a/src/main/java/com/yutou/qqbot/QQBotManager.java b/src/main/java/com/yutou/qqbot/QQBotManager.java index c970112..dfc74d4 100644 --- a/src/main/java/com/yutou/qqbot/QQBotManager.java +++ b/src/main/java/com/yutou/qqbot/QQBotManager.java @@ -1,17 +1,16 @@ package com.yutou.qqbot; import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONFactory; import com.alibaba.fastjson2.JSONObject; import com.yutou.qqbot.Listeners.QQMessageListener; -import com.yutou.qqbot.MessageEvent.Message; import com.yutou.qqbot.models.Animal.TurnipProphet; +import com.yutou.qqbot.models.Commands.BTDownload; import com.yutou.qqbot.models.Commands.BaiduDown; import com.yutou.qqbot.models.Commands.Bangumi; -import com.yutou.qqbot.models.Commands.BTDownload; import com.yutou.qqbot.models.Commands.Moyu; import com.yutou.qqbot.models.Commands.System.*; import com.yutou.qqbot.models.Model; +import com.yutou.qqbot.models.WebSign.BaiHeHui; import com.yutou.qqbot.models.WebSign.BiliBiliMangeSign; import com.yutou.qqbot.models.WebSign.Tsdm; import com.yutou.qqbot.models.XiaoMi.MiRouter; @@ -30,7 +29,6 @@ import net.mamoe.mirai.utils.ExternalResource; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Objects; @@ -38,29 +36,6 @@ public class QQBotManager { public static Long defGroup = 891655174L; - static { - Model.classList.add(QQSetu.class); - Model.classList.add(Audio.class); - Model.classList.add(BtFlash.class); - Model.classList.add(Cmd.class); - Model.classList.add(Help.class); - Model.classList.add(IP.class); - Model.classList.add(OpenPC.class); - Model.classList.add(Restart.class); - Model.classList.add(ToolsIdea.class); - Model.classList.add(UpdateIP.class); - Model.classList.add(Version.class); - Model.classList.add(Bangumi.class); - - Model.classList.add(TurnipProphet.class); - Model.classList.add(Tsdm.class); - Model.classList.add(BaiduDown.class); - Model.classList.add(MiRouter.class); - Model.classList.add(GetSeTu.class); - Model.classList.add(BTDownload.class); - Model.classList.add(BiliBiliMangeSign.class); - Model.classList.add(Moyu.class); - } private static QQBotManager botManager = null; private Bot bot; @@ -73,7 +48,6 @@ public class QQBotManager { Object isRun = ConfigTools.load(ConfigTools.CONFIG, "qq_bot"); if (isRun != null && (boolean) isRun) { isLogin = true; - isInit = true; init(); } } @@ -110,7 +84,7 @@ public class QQBotManager { } String str = sendMessage("姬妻酱上线拉~☆Daze~ 当前版本:" + QQBotApplication.version); Log.i(str); - + isInit = true; } }).start(); bot.join(); @@ -120,7 +94,7 @@ public class QQBotManager { } - public static QQBotManager getInstance() { + public synchronized static QQBotManager getInstance() { if (botManager == null && !isInit) { botManager = new QQBotManager(); } @@ -247,8 +221,8 @@ public class QQBotManager { json.put("t1", 3234567890L); System.out.println("json = " + json); - String tmp=json.toString(); - JSONObject json2=JSON.parseObject(tmp); + String tmp = json.toString(); + JSONObject json2 = JSON.parseObject(tmp); System.out.println("json2 = " + json2); } diff --git a/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java b/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java index 19dc9fb..162f0ea 100644 --- a/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java +++ b/src/main/java/com/yutou/qqbot/models/Animal/TurnipProphet.java @@ -3,6 +3,7 @@ package com.yutou.qqbot.models.Animal; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.*; @@ -16,7 +17,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; - +@UseModel public class TurnipProphet extends Model { public static class TurnipData { public static final String MODEL = "趋势:"; diff --git a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliVideo.java b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliVideo.java index b7a3c25..7394465 100644 --- a/src/main/java/com/yutou/qqbot/models/BiliBili/BiliVideo.java +++ b/src/main/java/com/yutou/qqbot/models/BiliBili/BiliVideo.java @@ -8,6 +8,7 @@ import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.TextFormat; import com.google.protobuf.UnknownFieldSet; import com.google.protobuf.util.JsonFormat; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.bilibili.*; import com.yutou.qqbot.interfaces.DownloadInterface; import com.yutou.qqbot.interfaces.ObjectInterface; @@ -30,7 +31,7 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.Inflater; - +@UseModel public class BiliVideo extends Model { public String downloadPath = "tmp"; diff --git a/src/main/java/com/yutou/qqbot/models/Commands/BTDownload.java b/src/main/java/com/yutou/qqbot/models/Commands/BTDownload.java index 0c41c27..bf5aae7 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/BTDownload.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/BTDownload.java @@ -1,11 +1,12 @@ package com.yutou.qqbot.models.Commands; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.interfaces.ObjectInterface; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.AppTools; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class BTDownload extends Model { private static final String DownloadHomePath="/media/yutou/disk_lvm/public/download/"; @Override diff --git a/src/main/java/com/yutou/qqbot/models/Commands/BaiduDown.java b/src/main/java/com/yutou/qqbot/models/Commands/BaiduDown.java index c4f4f05..22a7f31 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/BaiduDown.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/BaiduDown.java @@ -1,5 +1,6 @@ package com.yutou.qqbot.models.Commands; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.interfaces.ObjectInterface; import com.yutou.qqbot.models.Model; @@ -8,7 +9,7 @@ import com.yutou.qqbot.utlis.Log; import net.mamoe.mirai.event.events.MessageEvent; import java.io.File; - +@UseModel public class BaiduDown extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/Bangumi.java b/src/main/java/com/yutou/qqbot/models/Commands/Bangumi.java index a301e88..55a2c03 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/Bangumi.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/Bangumi.java @@ -1,5 +1,6 @@ package com.yutou.qqbot.models.Commands; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.interfaces.DownloadInterface; import com.yutou.qqbot.models.Model; @@ -14,7 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; - +@UseModel public class Bangumi extends Model { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java b/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java index 41e364d..fe771ce 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/Moyu.java @@ -2,6 +2,7 @@ package com.yutou.qqbot.models.Commands; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.interfaces.DownloadInterface; import com.yutou.qqbot.models.Model; @@ -11,7 +12,7 @@ import com.yutou.qqbot.utlis.Log; import net.mamoe.mirai.event.events.MessageEvent; import java.io.File; - +@UseModel public class Moyu extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/Audio.java b/src/main/java/com/yutou/qqbot/models/Commands/System/Audio.java index 68f35ad..0d9e2f0 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/Audio.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/Audio.java @@ -1,9 +1,10 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.models.audio.QQAudio; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class Audio extends Model { @Override diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/BtFlash.java b/src/main/java/com/yutou/qqbot/models/Commands/System/BtFlash.java index 5ff8959..e3ca6b9 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/BtFlash.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/BtFlash.java @@ -1,10 +1,11 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.HttpTools; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class BtFlash extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/Cmd.java b/src/main/java/com/yutou/qqbot/models/Commands/System/Cmd.java index e194433..902fa8d 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/Cmd.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/Cmd.java @@ -1,9 +1,10 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.RedisTools; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class Cmd extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/Help.java b/src/main/java/com/yutou/qqbot/models/Commands/System/Help.java index cb5a6fe..2559245 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/Help.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/Help.java @@ -1,9 +1,10 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class Help extends Model { @Override diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/IP.java b/src/main/java/com/yutou/qqbot/models/Commands/System/IP.java index 97f9928..0ef48da 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/IP.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/IP.java @@ -1,9 +1,10 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.RedisTools; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class IP extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/OpenPC.java b/src/main/java/com/yutou/qqbot/models/Commands/System/OpenPC.java index 0198b89..a38a65f 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/OpenPC.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/OpenPC.java @@ -1,12 +1,13 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.RedisTools; import net.mamoe.mirai.event.events.MessageEvent; import java.text.SimpleDateFormat; import java.util.Date; - +@UseModel public class OpenPC extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/Restart.java b/src/main/java/com/yutou/qqbot/models/Commands/System/Restart.java index 982fe26..b1366ca 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/Restart.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/Restart.java @@ -1,10 +1,11 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.AppTools; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class Restart extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/ToolsIdea.java b/src/main/java/com/yutou/qqbot/models/Commands/System/ToolsIdea.java index bb29747..77cbefc 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/ToolsIdea.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/ToolsIdea.java @@ -1,12 +1,13 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.IdeaTools; import com.yutou.qqbot.utlis.RedisTools; import com.yutou.qqbot.utlis.StringUtils; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class ToolsIdea extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/UpdateIP.java b/src/main/java/com/yutou/qqbot/models/Commands/System/UpdateIP.java index 31af18f..e1f679d 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/UpdateIP.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/UpdateIP.java @@ -1,9 +1,10 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.RedisTools; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class UpdateIP extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/Commands/System/Version.java b/src/main/java/com/yutou/qqbot/models/Commands/System/Version.java index bcb395c..1489c46 100644 --- a/src/main/java/com/yutou/qqbot/models/Commands/System/Version.java +++ b/src/main/java/com/yutou/qqbot/models/Commands/System/Version.java @@ -1,9 +1,10 @@ package com.yutou.qqbot.models.Commands.System; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import net.mamoe.mirai.event.events.MessageEvent; - +@UseModel public class Version extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java b/src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java index 41dff47..957ad51 100644 --- a/src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java +++ b/src/main/java/com/yutou/qqbot/models/WebSign/BaiHeHui.java @@ -2,6 +2,7 @@ package com.yutou.qqbot.models.WebSign; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.*; @@ -11,7 +12,7 @@ import org.openqa.selenium.WebElement; import java.io.File; import java.util.concurrent.TimeUnit; - +@UseModel public class BaiHeHui extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/BiliBiliMangeSign.java b/src/main/java/com/yutou/qqbot/models/WebSign/BiliBiliMangeSign.java index 803d811..110872a 100644 --- a/src/main/java/com/yutou/qqbot/models/WebSign/BiliBiliMangeSign.java +++ b/src/main/java/com/yutou/qqbot/models/WebSign/BiliBiliMangeSign.java @@ -1,5 +1,6 @@ package com.yutou.qqbot.models.WebSign; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.bilibili.BiliBiliManga; import com.yutou.qqbot.bilibili.BiliLogin; @@ -9,7 +10,7 @@ import com.yutou.qqbot.utlis.QRCodeUtils; import net.mamoe.mirai.event.events.MessageEvent; import java.io.File; - +@UseModel public class BiliBiliMangeSign extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/NicePT.java b/src/main/java/com/yutou/qqbot/models/WebSign/NicePT.java index a3e59ea..08fa133 100644 --- a/src/main/java/com/yutou/qqbot/models/WebSign/NicePT.java +++ b/src/main/java/com/yutou/qqbot/models/WebSign/NicePT.java @@ -2,6 +2,7 @@ package com.yutou.qqbot.models.WebSign; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.*; @@ -10,7 +11,7 @@ import org.openqa.selenium.WebDriver; import java.io.File; import java.util.concurrent.TimeUnit; - +@UseModel public class NicePT extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java b/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java index a07e31c..816c814 100644 --- a/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java +++ b/src/main/java/com/yutou/qqbot/models/WebSign/Tsdm.java @@ -3,6 +3,7 @@ package com.yutou.qqbot.models.WebSign; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.*; @@ -11,7 +12,7 @@ import org.openqa.selenium.*; import java.io.File; import java.util.concurrent.TimeUnit; - +@UseModel public class Tsdm extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java b/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java index ab2ec3e..afa849c 100644 --- a/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java +++ b/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java @@ -3,6 +3,7 @@ package com.yutou.qqbot.models.XiaoMi; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.models.Model; import com.yutou.qqbot.utlis.HttpTools; @@ -12,7 +13,7 @@ import net.mamoe.mirai.event.events.MessageEvent; import java.util.HashSet; import java.util.Set; - +@UseModel public class MiRouter extends Model { public static String redis_key = "MiRouterDevices"; 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 20365e3..6de52a0 100644 --- a/src/main/java/com/yutou/qqbot/models/setu/GetSeTu.java +++ b/src/main/java/com/yutou/qqbot/models/setu/GetSeTu.java @@ -3,6 +3,7 @@ package com.yutou.qqbot.models.setu; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.interfaces.DownloadInterface; import com.yutou.qqbot.models.Model; @@ -21,7 +22,7 @@ import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; - +@UseModel public class GetSeTu extends Model { @Override public boolean isUserPublic() { diff --git a/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java b/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java index 797a3c2..0461f92 100644 --- a/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java +++ b/src/main/java/com/yutou/qqbot/utlis/ApplicationInit.java @@ -1,16 +1,19 @@ package com.yutou.qqbot.utlis; +import com.yutou.qqbot.Annotations.UseModel; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.QQNumberManager; import com.yutou.qqbot.models.Model; import net.mamoe.mirai.Bot; import net.mamoe.mirai.contact.Group; +import org.reflections.Reflections; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Set; import java.util.Timer; import java.util.TimerTask; @@ -18,6 +21,9 @@ import java.util.TimerTask; public class ApplicationInit implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { + Reflections ref = new Reflections("com.yutou.qqbot.models"); + Set> annotatedWith = ref.getTypesAnnotatedWith(UseModel.class); + Model.classList.addAll(annotatedWith); new Timer().schedule(new TimerTask() { private String oldTime = ""; diff --git a/src/main/java/com/yutou/qqbot/utlis/BangumiTools.java b/src/main/java/com/yutou/qqbot/utlis/BangumiTools.java index f6bd19c..629a28f 100644 --- a/src/main/java/com/yutou/qqbot/utlis/BangumiTools.java +++ b/src/main/java/com/yutou/qqbot/utlis/BangumiTools.java @@ -347,8 +347,11 @@ public class BangumiTools { public static void main(String[] args) { List list = BangumiTools.reportSearchBangumi("处刑少女的生存之道"); - for (String s : list) { + /*for (String s : list) { System.out.println(s); - } + }*/ + JSONObject test=new JSONObject(); + test.put("data",JSON.toJSON(list)); + System.out.println(test); } }