diff --git a/src/main/java/com/yutou/qqbot/Listeners/QQMessageListener.java b/src/main/java/com/yutou/qqbot/Listeners/QQMessageListener.java index 39a53f4..4e80e24 100644 --- a/src/main/java/com/yutou/qqbot/Listeners/QQMessageListener.java +++ b/src/main/java/com/yutou/qqbot/Listeners/QQMessageListener.java @@ -36,7 +36,6 @@ public class QQMessageListener extends SimpleListenerHost { if (event.getSource().getFromId() == 583819556) { new AdminMessage(qqNumber, event.getMessage().contentToString()); } - System.out.println("isGroup = " + isGroup); for (Class model : Model.classList) { if (QQNumberManager.getManager().isUseModel(qqNumber, model)) { try { diff --git a/src/main/java/com/yutou/qqbot/MessageEvent/AdminMessage.java b/src/main/java/com/yutou/qqbot/MessageEvent/AdminMessage.java index e2730a1..4908de5 100644 --- a/src/main/java/com/yutou/qqbot/MessageEvent/AdminMessage.java +++ b/src/main/java/com/yutou/qqbot/MessageEvent/AdminMessage.java @@ -3,6 +3,7 @@ package com.yutou.qqbot.MessageEvent; import com.yutou.qqbot.QQBotManager; import com.yutou.qqbot.QQNumberManager; import com.yutou.qqbot.models.Model; +import com.yutou.qqbot.utlis.RedisTools; import com.yutou.qqbot.utlis.StringUtils; import java.util.List; @@ -16,6 +17,9 @@ public class AdminMessage extends Message { private static final String MODEL_ADD = "!新增模块"; private static final String MODEL_SHOW = "!查看模块"; private static final String MODEL_DEL = "!删除模块"; + + private static final String SHOW="!列表"; + private static final String HELP="!help"; } public AdminMessage(Long qq, String msg) { @@ -27,8 +31,8 @@ public class AdminMessage extends Message { for (Class aClass : Model.classList) { System.err.println(aClass.getName()); } - String[] commands; switch (msgGroup[0]) { + case QQCommands.HELP -> QQBotManager.getInstance().sendMessage(qq,Model.getCommands(QQCommands.class).toString()); case QQCommands.POWER_ADD -> { if (msgGroup.length == 1) { StringBuilder builder = Model.getCommands(Model.QQGroupCommands.class); @@ -106,6 +110,27 @@ public class AdminMessage extends Message { } } } + case QQCommands.SHOW -> { + List users=QQNumberManager.getManager().getNumber(); + StringBuilder builder=new StringBuilder(); + for (Long user : users) { + builder.append(user).append(":\n"); + if(QQNumberManager.getManager().isGroup(user)){ + List list=QQNumberManager.getManager().getUseModel(user); + builder.append("模块(").append(list.size()).append("):\n"); + for (String model : list) { + builder.append(model).append("\n"); + } + } + List list=QQNumberManager.getManager().getPower(user); + builder.append("权限(").append(list.size()).append("):\n"); + for (String power : list) { + builder.append(power).append("\n"); + } + builder.append("\n"); + } + QQBotManager.getInstance().sendMessage(qq,builder.toString()); + } } } diff --git a/src/main/java/com/yutou/qqbot/QQBotManager.java b/src/main/java/com/yutou/qqbot/QQBotManager.java index d0a6f72..1323ce3 100644 --- a/src/main/java/com/yutou/qqbot/QQBotManager.java +++ b/src/main/java/com/yutou/qqbot/QQBotManager.java @@ -1,6 +1,7 @@ package com.yutou.qqbot; import com.yutou.qqbot.Listeners.QQMessageListener; +import com.yutou.qqbot.models.Animal.TurnipProphet; import com.yutou.qqbot.models.Commands.Bangumi; import com.yutou.qqbot.models.Commands.System.*; import com.yutou.qqbot.models.Model; @@ -33,6 +34,8 @@ public class QQBotManager { Model.classList.add(UpdateIP.class); Model.classList.add(Version.class); Model.classList.add(Bangumi.class); + + Model.classList.add(TurnipProphet.class); } private static QQBotManager botManager = null; private Bot bot; diff --git a/src/main/java/com/yutou/qqbot/QQNumberManager.java b/src/main/java/com/yutou/qqbot/QQNumberManager.java index c94da30..14486aa 100644 --- a/src/main/java/com/yutou/qqbot/QQNumberManager.java +++ b/src/main/java/com/yutou/qqbot/QQNumberManager.java @@ -35,7 +35,7 @@ public class QQNumberManager { public List getNumber(){ List list =new ArrayList<>(); Jedis jedis=RedisTools.getRedis(); - jedis.select(3); + jedis.select(RedisTools.QQBOT_USER); Set set=jedis.keys("*"); for (String s : set) { list.add(Long.parseLong(s)); diff --git a/src/main/java/com/yutou/qqbot/utlis/RedisTools.java b/src/main/java/com/yutou/qqbot/utlis/RedisTools.java index c6bc951..4c9a112 100644 --- a/src/main/java/com/yutou/qqbot/utlis/RedisTools.java +++ b/src/main/java/com/yutou/qqbot/utlis/RedisTools.java @@ -17,6 +17,7 @@ import java.util.Set; public class RedisTools { + public static final int QQBOT_USER = 3; private static boolean isNotInstallRedis = false; private static String host; private static int port; @@ -78,11 +79,11 @@ public class RedisTools { } public static boolean set(Object key, String value) { - return set(3, key+"", value); + return set(QQBOT_USER, key+"", value); } public static boolean set(String key, String value, long timeout) { - return set(key, value, timeout,3); + return set(key, value, timeout,QQBOT_USER); } public static String get(String key, int dbIndex) { @@ -102,11 +103,11 @@ public class RedisTools { } public static String get(Object key) { - return get(key+"", 3); + return get(key+"", QQBOT_USER); } public static boolean remove(String key) { - return remove(key,3); + return remove(key,QQBOT_USER); } public static void removeLoginState(String uid) { @@ -127,7 +128,7 @@ public class RedisTools { return tmp; } public static boolean exists(Object key,String value){ - return exists(3,key,value); + return exists(QQBOT_USER,key,value); } public static boolean exists(int db,Object key, String value) { if (isNotInstallRedis) { @@ -194,13 +195,9 @@ public class RedisTools { } public static void pullMsg(String channel, String msg) { - Log.i("1"); Jedis jedis = getPoolRedis(); - Log.i("2"); jedis.publish(channel, msg); - Log.i("3"); jedis.close(); - Log.i("4"); } private static boolean init = false;