完善了owner的相关指令;

添加了群聊黑名单功能;
完善了清理线程超时时间以及最近操作时间的相关功能;
改正了之前正则表达式中出现的错误。
This commit is contained in:
slhaf
2024-10-03 23:18:31 +08:00
parent 3d0ad90ef7
commit 883bd39026
12 changed files with 429 additions and 82 deletions

View File

@@ -10,7 +10,9 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
import plugin.App;
import plugin.constant.ChatConstant;
import plugin.constant.ConfigConstant;
import plugin.listener.OwnerMessageListener;
import plugin.utils.AIUtil;
import plugin.utils.ConfigUtil;
@@ -20,6 +22,8 @@ import java.lang.reflect.Method;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static kotlin.io.ConsoleKt.readln;
public class MyTest {
public static void www(String[] args) {
String miraiCode = "看下这个题目[mirai:image:https://multimedia.nt.qq.com.cn/download?appid=1407&fileid=CgoyOTk4ODEzODgyEhQW4G7W3v2lT-NKItOqORRIbuK6rxiZzgcg_woo4u2zytCqiANQgL2jAQ&spec=0&rkey=CAMSKMa3OFokB_Tlf6uVSrtr8zFEBtyDtGIdmuztQCnfO9gIDN19LUsLquI]";
@@ -139,13 +143,44 @@ public class MyTest {
}
@Test
public void mainTest() throws ClassNotFoundException, IOException {
public void ownerTest() throws ClassNotFoundException, IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException {
ConfigUtil.load();
Long id = 2998813882L;
String content = "hello";
Class clazz = OwnerMessageListener.class;
Method handleCommand = clazz.getDeclaredMethod("handleCommand", String.class, String.class);
handleCommand.setAccessible(true);
while (true){
String input = readln();
String command = input.split(ChatConstant.BLANK)[0];
String arguments = input.split(ChatConstant.BLANK)[1];
Object invoke = handleCommand.invoke(clazz.getDeclaredConstructor().newInstance(), command, arguments);
System.out.println(invoke);
}
}
@Test
public void chatTest() throws IOException, ClassNotFoundException {
ConfigUtil.load();
Long id = 1L;
String content = "你好";
String chatCommand = "/c ";
String s = AIUtil.customChat(id, content, null, chatCommand);
System.out.println(s);
String customChat = AIUtil.customChat(id, content, null, chatCommand);
System.out.println(customChat);
String defaultChat = AIUtil.defaultChat(id, content, null);
System.out.println(defaultChat);
String chatOnce = AIUtil.chatOnce(content, null);
System.out.println(chatOnce);
}
@Test
public void regexTest(){
String str = "/c glm";
System.out.println(str.matches(ConfigConstant.MODEL_CHANGE));
}
}