diff --git a/robot-data/cache/account.secrets b/robot-data/cache/account.secrets index 30e38cc..7ae11eb 100644 Binary files a/robot-data/cache/account.secrets and b/robot-data/cache/account.secrets differ diff --git a/robot-data/cache/servers.json b/robot-data/cache/servers.json index 3111db3..1c8d9f8 100644 --- a/robot-data/cache/servers.json +++ b/robot-data/cache/servers.json @@ -1,38 +1,38 @@ [ - { - "host": "111.30.169.83", - "port": 443 - }, { "host": "msfwifi.3g.qq.com", "port": 8080 }, { - "host": "111.30.182.254", - "port": 443 + "host": "116.130.229.191", + "port": 80 }, { - "host": "36.155.207.230", - "port": 443 + "host": "182.50.15.44", + "port": 80 }, { - "host": "120.232.31.239", + "host": "123.125.0.195", + "port": 80 + }, + { + "host": "220.194.118.236", + "port": 80 + }, + { + "host": "182.50.8.188", "port": 8080 }, { - "host": "120.241.130.195", + "host": "157.148.55.96", + "port": 443 + }, + { + "host": "157.255.5.104", + "port": 8080 + }, + { + "host": "153.3.244.48", "port": 14000 - }, - { - "host": "36.155.163.25", - "port": 80 - }, - { - "host": "39.156.126.178", - "port": 80 - }, - { - "host": "36.155.163.117", - "port": 8080 } ] \ No newline at end of file diff --git a/robot-data/cache/session.bin b/robot-data/cache/session.bin index b0e6f70..6f7084b 100644 --- a/robot-data/cache/session.bin +++ b/robot-data/cache/session.bin @@ -1,2 +1,2 @@ -h׭ u+]uSfJvv)POtϺRBf,y* .Ώo Qtq-;yJxL"&Kd왏J87mdKjNc8WfFjkszCzNЄ? Ѓ?P" D" " ϰ"H \ No newline at end of file +h'Le"qjːx$/V9zQ6ZӳJ>2֐*90;كձDC#j 2[eO& )Q)dmtWkf9fgTW67wH4 ڙ?? P " Π" "܅ۓ" ˔ \ No newline at end of file diff --git a/src/main/java/com/mtz/qqbot/Controller/listController.java b/src/main/java/com/mtz/qqbot/Controller/listController.java index 0727f50..2b89563 100644 --- a/src/main/java/com/mtz/qqbot/Controller/listController.java +++ b/src/main/java/com/mtz/qqbot/Controller/listController.java @@ -15,6 +15,7 @@ public class listController { return "今日好友消息:[" + HandleMessageListener.friendMessageCount + "]条
" + "今日群聊1消息:[" + HandleMessageListener.group1MessageCount + "]条
" + "今日群聊2消息:[" + HandleMessageListener.group2MessageCount + "]条
" + + "牢豆年糕汤消息:[" + HandleMessageListener.group3MessageCount + "]条
" + "今日收到的群聊临时会话消息:[" + HandleMessageListener.groupTempMessageCount + "]条

" + "今日群聊1违禁消息:[" + RecallMessageListener.group1InvalidCount + "]条
" + "今日群聊2违禁消息:[" + RecallMessageListener.group2InvalidCount + "]条
" + diff --git a/src/main/java/com/mtz/qqbot/Listener/HandleMessageListener.java b/src/main/java/com/mtz/qqbot/Listener/HandleMessageListener.java index 9cd965e..9499ee1 100644 --- a/src/main/java/com/mtz/qqbot/Listener/HandleMessageListener.java +++ b/src/main/java/com/mtz/qqbot/Listener/HandleMessageListener.java @@ -11,6 +11,7 @@ public class HandleMessageListener { public static int friendMessageCount = 0; public static int group1MessageCount = 0; public static int group2MessageCount = 0; + public static int group3MessageCount = 0; public static int groupTempMessageCount = 0; @@ -38,6 +39,12 @@ public class HandleMessageListener { group2MessageCount++; } + @RobotListenerHandler(contactId = 850111709) + public void handleGroupLAODOUMessage(GroupMessageEvent event) { + handleGroupMessage(event); + group3MessageCount++; + } + @RobotListenerHandler public void handleGroupTempMessage(GroupTempMessageEvent event) { String message = event.getMessage().contentToString(); diff --git a/src/main/java/com/mtz/qqbot/Listener/RecallMessageListener.java b/src/main/java/com/mtz/qqbot/Listener/RecallMessageListener.java index 91a6548..9d1215a 100644 --- a/src/main/java/com/mtz/qqbot/Listener/RecallMessageListener.java +++ b/src/main/java/com/mtz/qqbot/Listener/RecallMessageListener.java @@ -22,7 +22,7 @@ public class RecallMessageListener extends MessageListener { public static List group2InvalidMember = new ArrayList(); public RecallMessageListener() { - super(List.of("原神", "OP"), true);//自定义违禁词 + super(List.of("原神"), true);//自定义违禁词 } public int recall(GroupMessageEvent event, int groupInvalidCount, Map groupMemberInvalidedCountList, List groupInvalidMember) throws InterruptedException {//当有人发违禁词自动撤回并禁言一分钟 diff --git a/src/main/java/com/mtz/qqbot/Listener/sendByConsoleListener.java b/src/main/java/com/mtz/qqbot/Listener/sendByConsoleListener.java index d692710..390d8be 100644 --- a/src/main/java/com/mtz/qqbot/Listener/sendByConsoleListener.java +++ b/src/main/java/com/mtz/qqbot/Listener/sendByConsoleListener.java @@ -27,7 +27,7 @@ public class sendByConsoleListener extends MessageListener { System.out.println("机器人发送:" + str); } - @RobotListenerHandler(contactId = {518909220, 1033597003}, concurrency = true)//当有人消息中带有“呼叫bot”时,可以从控制台输入一条消息发送 + @RobotListenerHandler(concurrency = true)//当有人消息中带有“呼叫管理”时,可以从控制台输入一条消息发送 public void sendMessageToGroup(GroupMessageEvent event) { String message = event.getMessage().contentToString(); if (this.invalidText(message)) { @@ -35,7 +35,8 @@ public class sendByConsoleListener extends MessageListener { String str = input.nextLine(); MessageChain chain = new MessageChainBuilder() .append(new At(event.getSender().getId())) - .append(" " + str) + .append(" ") + .append(str) .build(); event.getGroup().sendMessage(chain); System.out.println("机器人发送:" + chain); diff --git a/src/main/java/com/mtz/qqbot/Listener/vDecryptListener.java b/src/main/java/com/mtz/qqbot/Listener/vDecryptListener.java new file mode 100644 index 0000000..78dda18 --- /dev/null +++ b/src/main/java/com/mtz/qqbot/Listener/vDecryptListener.java @@ -0,0 +1,34 @@ +package com.mtz.qqbot.Listener; + +import com.mtz.qqbot.Service.vService; +import net.itbaima.robot.event.RobotListener; +import net.itbaima.robot.event.RobotListenerHandler; +import net.itbaima.robot.listener.MessageListener; +import net.mamoe.mirai.event.events.GroupMessageEvent; +import net.mamoe.mirai.message.data.At; +import net.mamoe.mirai.message.data.MessageChain; +import net.mamoe.mirai.message.data.MessageChainBuilder; + +import java.util.List; + +@RobotListener +public class vDecryptListener extends MessageListener { + public vDecryptListener() { + super(List.of("解密"), true); + } + + @RobotListenerHandler + public void decrypt(GroupMessageEvent event) { + String message = event.getMessage().contentToString(); + if (this.invalidText(message)) { + String[] originMessage = message.split(" "); + String plaintext = String.valueOf(vService.Decrypt(originMessage)); + MessageChain chain = new MessageChainBuilder() + .append(new At(event.getSender().getId())) + .append(" ") + .append(plaintext) + .build(); + event.getGroup().sendMessage(chain); + } + } +} diff --git a/src/main/java/com/mtz/qqbot/Listener/vEncryptListener.java b/src/main/java/com/mtz/qqbot/Listener/vEncryptListener.java new file mode 100644 index 0000000..cc9ebc9 --- /dev/null +++ b/src/main/java/com/mtz/qqbot/Listener/vEncryptListener.java @@ -0,0 +1,35 @@ +package com.mtz.qqbot.Listener; + +import com.mtz.qqbot.Service.vService; +import net.itbaima.robot.event.RobotListener; +import net.itbaima.robot.event.RobotListenerHandler; +import net.itbaima.robot.listener.MessageListener; +import net.mamoe.mirai.event.events.GroupMessageEvent; +import net.mamoe.mirai.message.data.At; +import net.mamoe.mirai.message.data.MessageChain; +import net.mamoe.mirai.message.data.MessageChainBuilder; + +import java.io.IOException; +import java.util.List; + +@RobotListener +public class vEncryptListener extends MessageListener { + public vEncryptListener() { + super(List.of("加密"), true); + } + + @RobotListenerHandler + public void encrypt(GroupMessageEvent event) throws IOException { + String message = event.getMessage().contentToString(); + if (this.invalidText(message)) { + String[] originMessage = message.split(" "); + String ciphertext = String.valueOf(vService.Encrypt(originMessage)); + MessageChain chain = new MessageChainBuilder() + .append(new At(event.getSender().getId())) + .append(" ") + .append(ciphertext) + .build(); + event.getGroup().sendMessage(chain); + } + } +} diff --git a/src/main/java/com/mtz/qqbot/Service/vService.java b/src/main/java/com/mtz/qqbot/Service/vService.java new file mode 100644 index 0000000..4e5837d --- /dev/null +++ b/src/main/java/com/mtz/qqbot/Service/vService.java @@ -0,0 +1,68 @@ +package com.mtz.qqbot.Service; + +import com.mtz.qqbot.Tool.vTools; + +import java.io.IOException; +import java.util.ArrayList; + +import static com.mtz.qqbot.Tool.vTools.alphabet; + +public class vService { + public static StringBuilder Encrypt(String[] originMessage) throws IOException { + //加密 + String passwd = originMessage[2]; + char[] passwd1 = passwd.toCharArray(); + ArrayList passwdList = vTools.Transform(passwd1); + //System.out.println("密钥转换为密钥数字串为:" + passwdList); + + String plaintext = originMessage[1]; + char[] plaintext1 = plaintext.toCharArray(); + ArrayList plaintextList = vTools.Transform(plaintext1); + //System.out.println("明文转换为明文数字串为" + plaintextList); + + vTools.Longer(passwdList, plaintextList); + //System.out.println("增加后的密钥数字串:" + passwdList); + + //输出密文 + StringBuilder ciphertext = new StringBuilder(); + for (int i = 0; i < plaintextList.size(); i++) { + if ((plaintextList.get(i) + passwdList.get(i)) >= alphabet.length) { + plaintextList.set(i, (passwdList.get(i) + plaintextList.get(i) - alphabet.length)); + } else { + plaintextList.set(i, (passwdList.get(i) + plaintextList.get(i))); + } + ciphertext.append(alphabet[plaintextList.get(i)]); + } + return ciphertext; + } + + public static StringBuilder Decrypt(String[] originMessage) { + //解密 + String passwd = originMessage[2]; + char[] passwd1 = passwd.toCharArray(); + ArrayList passwdList = vTools.Transform(passwd1); + + String ciphertext = originMessage[1]; + char[] ciphertext1 = ciphertext.toCharArray(); + ArrayList ciphertextList = vTools.Transform(ciphertext1); + //System.out.println("密文转换为密文数字串为" + ciphertextList); + + vTools.Longer(passwdList, ciphertextList); + //System.out.println("增加后的密钥数字串:" + passwdList); + + //输出明文 + StringBuilder plaintext = new StringBuilder(); + for (int i = 0; i < ciphertextList.size(); i++) { + if ((ciphertextList.get(i) - passwdList.get(i)) < 0) { + ciphertextList.set(i, ciphertextList.get(i) - passwdList.get(i) + alphabet.length); + } else { + ciphertextList.set(i, ciphertextList.get(i) - passwdList.get(i)); + } + plaintext.append(alphabet[ciphertextList.get(i)]); + } + return plaintext; + } + + +} + diff --git a/src/main/java/com/mtz/qqbot/Tool/vTools.java b/src/main/java/com/mtz/qqbot/Tool/vTools.java new file mode 100644 index 0000000..7c47d18 --- /dev/null +++ b/src/main/java/com/mtz/qqbot/Tool/vTools.java @@ -0,0 +1,41 @@ +package com.mtz.qqbot.Tool; + +import java.util.ArrayList; +import java.util.Scanner; + +public class vTools { + //字符表 + public static char[] alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '/', '.', '-', '_', '?', '=', '&', '%'}; + + public static ArrayList Transform(char[] text) { + ArrayList list = new ArrayList<>(); + for (char c : text) { + for (int j = 0; j < alphabet.length; j++) { + if (c == alphabet[j]) { + list.add(j); + } + } + } + return list; + } + + public static void Longer(ArrayList passwdList, ArrayList list) { + int i = 0; + while (passwdList.size() < list.size()) { + passwdList.add(passwdList.get(i)); + i++; + } + } + + public static int Input() { + //防止玩家输入其他字符的输入数字方法 + Scanner scanner = new Scanner(System.in); + if (scanner.hasNextInt()) { + return scanner.nextInt(); + } else { + System.out.println("请输入数字!"); + System.out.print("请输入:"); + return Input(); + } + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e14d39f..6fd71ab 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,13 +6,13 @@ itbaima: password: mtzmtq2002 signer: - version: 8.9.71 + version: 8.9.63 url: http://localhost:8888 type: fuqiuluo authorization-key: 114514 data: - contact-cache: true + contact-cache: false work-dir: robot-data cache-dir: cache