修改了配置文件格式,能够正常读取
温度采样相关功能待添加......
This commit is contained in:
@@ -6,8 +6,8 @@ plugins {
|
||||
id("net.mamoe.mirai-console") version "2.16.0"
|
||||
}
|
||||
|
||||
group = "com.plugin"
|
||||
version = "0.1.0"
|
||||
group = "work.slhaf.chatai"
|
||||
version = "2.1.0"
|
||||
|
||||
dependencies{
|
||||
implementation ("com.squareup.okhttp3:okhttp:5.0.0-alpha.12")
|
||||
@@ -21,7 +21,8 @@ dependencies{
|
||||
implementation("top.mrxiaom.mirai:overflow-core-all:1.0.0")
|
||||
implementation ("com.alibaba:fastjson:1.2.73")
|
||||
implementation ("org.projectlombok:lombok:1.18.36")
|
||||
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.36")
|
||||
compileOnly("org.projectlombok:lombok:1.18.36")
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package plugin.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CustomCommandTemplate {
|
||||
private String command;
|
||||
private int modelTemplateIndex;
|
||||
private String customModel;
|
||||
private String customPromotion;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "command: " + command + "\r\n" +
|
||||
"modelTemplateIndex: " + modelTemplateIndex + "\r\n" +
|
||||
"customModel: " + customModel + "\r\n" +
|
||||
"customPromotion: " + customPromotion;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package plugin.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelConfigTemplate {
|
||||
private String template_name;
|
||||
private String base_url;
|
||||
private String apikey;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin;
|
||||
package work.slhaf.chatai;
|
||||
|
||||
import net.mamoe.mirai.console.plugin.jvm.JavaPlugin;
|
||||
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescriptionBuilder;
|
||||
@@ -6,13 +6,13 @@ import net.mamoe.mirai.event.GlobalEventChannel;
|
||||
import net.mamoe.mirai.event.events.FriendMessageEvent;
|
||||
import net.mamoe.mirai.event.events.GroupMessageEvent;
|
||||
import net.mamoe.mirai.event.events.MessageEvent;
|
||||
import plugin.chat.constant.Constant;
|
||||
import plugin.config.Config;
|
||||
import plugin.config.CustomCommandTemplate;
|
||||
import plugin.config.ModelConfigTemplate;
|
||||
import plugin.listener.FriendMessageListener;
|
||||
import plugin.listener.GroupMessageListener;
|
||||
import plugin.listener.OwnerMessageListener;
|
||||
import work.slhaf.chatai.chat.constant.Constant;
|
||||
import work.slhaf.chatai.config.Config;
|
||||
import work.slhaf.chatai.config.CustomCommandTemplate;
|
||||
import work.slhaf.chatai.config.ModelConfigTemplate;
|
||||
import work.slhaf.chatai.listener.FriendMessageListener;
|
||||
import work.slhaf.chatai.listener.GroupMessageListener;
|
||||
import work.slhaf.chatai.listener.OwnerMessageListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -41,8 +41,8 @@ public final class App extends JavaPlugin {
|
||||
//加载配置
|
||||
try {
|
||||
Config config = Config.ConfigLoader.load();
|
||||
App.class.getClassLoader().loadClass("plugin.utils.OCRUtil");
|
||||
App.class.getClassLoader().loadClass("plugin.utils.ChatUtil");
|
||||
App.class.getClassLoader().loadClass("work.slhaf.chatai.utils.OCRUtil");
|
||||
App.class.getClassLoader().loadClass("work.slhaf.chatai.utils.ChatUtil");
|
||||
|
||||
owner = config.getOwner().substring(1);
|
||||
bot = config.getBot().substring(1);
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.chat;
|
||||
package work.slhaf.chatai.chat;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
@@ -6,11 +6,11 @@ import cn.hutool.json.JSONUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import plugin.chat.constant.Constant;
|
||||
import plugin.chat.pojo.ChatBody;
|
||||
import plugin.chat.pojo.ChatResponse;
|
||||
import plugin.chat.pojo.Message;
|
||||
import plugin.chat.pojo.PrimaryChatResponse;
|
||||
import work.slhaf.chatai.chat.constant.Constant;
|
||||
import work.slhaf.chatai.chat.pojo.ChatBody;
|
||||
import work.slhaf.chatai.chat.pojo.ChatResponse;
|
||||
import work.slhaf.chatai.chat.pojo.Message;
|
||||
import work.slhaf.chatai.chat.pojo.PrimaryChatResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -65,7 +65,7 @@ public class ChatClient {
|
||||
}
|
||||
|
||||
public ChatResponse runChat(String content){
|
||||
HttpRequest request = HttpRequest.post(url+"/chat/completions");
|
||||
HttpRequest request = HttpRequest.post(url+ "/work/slhaf/chatai/completions");
|
||||
request.header("Content-Type", "application/json");
|
||||
request.header("Authorization", "Bearer " + apikey);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.chat.constant;
|
||||
package work.slhaf.chatai.chat.constant;
|
||||
|
||||
public class Constant {
|
||||
public static class Character{
|
||||
@@ -57,6 +57,9 @@ public class Constant {
|
||||
}
|
||||
|
||||
public static class Path {
|
||||
public static final String CONFIG_PATH = "./config/ChatAI/config.yaml";
|
||||
public static final String CONFIG_BASIC_PATH = "./config/ChatAI/basic.yaml";
|
||||
public static final String CONFIG_ALIOCR_PATH = "./config/ChatAI/aliocr.yaml";
|
||||
public static final String CONFIG_MODEL_PATH = "./config/ChatAI/model.yaml";
|
||||
public static final String CONFIG_CUSTOM_PATH = "./config/ChatAI/custom.yaml";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.chat.pojo;
|
||||
package work.slhaf.chatai.chat.pojo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.chat.pojo;
|
||||
package work.slhaf.chatai.chat.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.chat.pojo;
|
||||
package work.slhaf.chatai.chat.pojo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.chat.pojo;
|
||||
package work.slhaf.chatai.chat.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.config;
|
||||
package work.slhaf.chatai.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
18
src/main/java/work/slhaf/chatai/config/BasicConfig.java
Normal file
18
src/main/java/work/slhaf/chatai/config/BasicConfig.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package work.slhaf.chatai.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BasicConfig {
|
||||
private String owner;
|
||||
private String bot;
|
||||
private String timeout;
|
||||
private String timeCheck;
|
||||
private List<Long> blacklist;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.config;
|
||||
package work.slhaf.chatai.config;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.Getter;
|
||||
@@ -8,14 +8,16 @@ import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.inspector.TagInspector;
|
||||
import plugin.chat.constant.Constant;
|
||||
import work.slhaf.chatai.chat.constant.Constant;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Setter
|
||||
@@ -23,30 +25,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class Config {
|
||||
|
||||
/**
|
||||
* owner QQ
|
||||
*/
|
||||
private String owner;
|
||||
|
||||
/**
|
||||
* bot QQ
|
||||
*/
|
||||
private String bot;
|
||||
|
||||
/**
|
||||
* 对话记录过期时间
|
||||
*/
|
||||
private String timeout;
|
||||
|
||||
/**
|
||||
* 检测对话记录间隔
|
||||
*/
|
||||
private String timeCheck;
|
||||
|
||||
/**
|
||||
* 群聊黑名单
|
||||
*/
|
||||
private List<Long> blacklist;
|
||||
private BasicConfig basicConfig;
|
||||
|
||||
/**
|
||||
* 阿里OCR配置
|
||||
@@ -56,7 +35,7 @@ public class Config {
|
||||
/**
|
||||
* 模板配置
|
||||
*/
|
||||
private List<ModelConfigTemplate> modelConfigTemplates;
|
||||
private ArrayList<ModelConfigTemplate> modelConfigTemplates;
|
||||
|
||||
/**
|
||||
* 预设配置
|
||||
@@ -66,10 +45,31 @@ public class Config {
|
||||
private Config() {
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return basicConfig.getOwner();
|
||||
}
|
||||
|
||||
public String getBot() {
|
||||
return basicConfig.getBot();
|
||||
}
|
||||
|
||||
public String getTimeout(){
|
||||
return basicConfig.getTimeout();
|
||||
}
|
||||
|
||||
public String getTimeCheck(){
|
||||
return basicConfig.getTimeCheck();
|
||||
}
|
||||
|
||||
public List<Long> getBlacklist(){
|
||||
return basicConfig.getBlacklist();
|
||||
}
|
||||
|
||||
|
||||
public static class ConfigLoader {
|
||||
private static final Yaml yaml;
|
||||
@Getter
|
||||
private static Config config;
|
||||
private static Config config = new Config();
|
||||
|
||||
static {
|
||||
DumperOptions options = new DumperOptions();
|
||||
@@ -82,31 +82,76 @@ public class Config {
|
||||
TagInspector tagInspector = tag -> true;
|
||||
loaderOptions.setTagInspector(tagInspector);
|
||||
Yaml yaml = new Yaml(loaderOptions);
|
||||
File file = new File(Constant.Path.CONFIG_PATH);
|
||||
if (file.exists()) {
|
||||
FileInputStream fileInputStream = new FileInputStream(Constant.Path.CONFIG_PATH);
|
||||
config = BeanUtil.toBean(yaml.load(fileInputStream), Config.class);
|
||||
fileInputStream.close();
|
||||
File[] files = new File[]{
|
||||
new File(Constant.Path.CONFIG_BASIC_PATH),
|
||||
new File(Constant.Path.CONFIG_ALIOCR_PATH),
|
||||
new File(Constant.Path.CONFIG_MODEL_PATH),
|
||||
new File(Constant.Path.CONFIG_CUSTOM_PATH)
|
||||
};
|
||||
boolean isExist = true;
|
||||
for (File file : files) {
|
||||
if (!file.exists()) {
|
||||
isExist = false;
|
||||
}
|
||||
}
|
||||
if (isExist) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
FileInputStream inputStream = new FileInputStream(files[i]);
|
||||
switch (i) {
|
||||
case 0:
|
||||
BasicConfig basicConfig = BeanUtil.toBean(yaml.load(inputStream), BasicConfig.class);
|
||||
config.setBasicConfig(basicConfig);
|
||||
break;
|
||||
case 1:
|
||||
AliOCRConfig aliOCRConfig = BeanUtil.toBean(yaml.load(inputStream), AliOCRConfig.class);
|
||||
config.setOcrConfig(aliOCRConfig);
|
||||
break;
|
||||
case 2:
|
||||
ArrayList<Map> modelTemplateMaps = yaml.load(inputStream);
|
||||
ArrayList<ModelConfigTemplate> modelTemplates = new ArrayList<>();
|
||||
for (Map modelTemplateMap : modelTemplateMaps) {
|
||||
ModelConfigTemplate modelConfigTemplate = new ModelConfigTemplate();
|
||||
modelConfigTemplate.loadMap((LinkedHashMap<String, String>) modelTemplateMap);
|
||||
modelTemplates.add(modelConfigTemplate);
|
||||
}
|
||||
config.setModelConfigTemplates(modelTemplates);
|
||||
break;
|
||||
case 3:
|
||||
ArrayList<Map> customTemplateMaps = yaml.load(inputStream);
|
||||
ArrayList<CustomCommandTemplate> customTemplates = new ArrayList<>();
|
||||
for (Map customTemplateMap : customTemplateMaps) {
|
||||
CustomCommandTemplate customCommandTemplate = new CustomCommandTemplate();
|
||||
customCommandTemplate.loadMap((LinkedHashMap<String,String>) customTemplateMap);
|
||||
customTemplates.add(customCommandTemplate);
|
||||
}
|
||||
config.setCustomCommandTemplates(customTemplates);
|
||||
break;
|
||||
}
|
||||
inputStream.close();
|
||||
}
|
||||
log.info("load config success");
|
||||
} else {
|
||||
for (File file : files) {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
config = new Config();
|
||||
}
|
||||
config.setBasicConfig(new BasicConfig());
|
||||
//基础配置
|
||||
config.setOwner("your_bot_owner_qq_number(e.g. Q1145141919810)");
|
||||
config.setBot("your_bot_qq_number(e.g. Q1145141919810)");
|
||||
config.setTimeout("M3600000");
|
||||
config.setTimeCheck("M60000");
|
||||
ArrayList<Long> blacklist = new ArrayList<>();
|
||||
blacklist.add(123456789L);
|
||||
blacklist.add(987654321L);
|
||||
config.setBlacklist(blacklist);
|
||||
config.setBasicConfig(new BasicConfig("your_bot_owner_qq_number(e.g. Q1145141919810)",
|
||||
"your_bot_qq_number(e.g. Q1145141919810)",
|
||||
"M3600000",
|
||||
"M60000",
|
||||
blacklist
|
||||
));
|
||||
|
||||
//OCR配置
|
||||
config.setOcrConfig(new AliOCRConfig("ocr_accessKeyId", "ocr_accessKeySecret"));
|
||||
|
||||
//模型模板
|
||||
List<ModelConfigTemplate> templateList = new ArrayList<>();
|
||||
ArrayList<ModelConfigTemplate> templateList = new ArrayList<>();
|
||||
templateList.add(new ModelConfigTemplate("zhipu", "https://open.bigmodel.cn/api/paas/v4", "zhipu_apikey"));
|
||||
templateList.add(new ModelConfigTemplate("deepseek", "https://api.deepseek.com/v1", "deepseek_apikey"));
|
||||
config.setModelConfigTemplates(templateList);
|
||||
@@ -120,13 +165,29 @@ public class Config {
|
||||
log.warn("配置文件创建成功,请关闭后进行配置");
|
||||
System.exit(0);
|
||||
}
|
||||
ConfigLoader.config = config;
|
||||
return config;
|
||||
}
|
||||
|
||||
private static void dump() throws IOException {
|
||||
FileWriter fileWriter = new FileWriter(Constant.Path.CONFIG_PATH);
|
||||
yaml.dump(BeanUtil.beanToMap(config), fileWriter);
|
||||
public static void dump() throws IOException {
|
||||
FileWriter writer = new FileWriter(Constant.Path.CONFIG_BASIC_PATH);
|
||||
yaml.dump(BeanUtil.beanToMap(config.getBasicConfig()), writer);
|
||||
|
||||
FileWriter writer1 = new FileWriter(Constant.Path.CONFIG_ALIOCR_PATH);
|
||||
yaml.dump(BeanUtil.beanToMap(config.getOcrConfig()), writer1);
|
||||
|
||||
FileWriter writer2 = new FileWriter(Constant.Path.CONFIG_MODEL_PATH);
|
||||
ArrayList<LinkedHashMap<String,String>> mapList= new ArrayList<>();
|
||||
for (ModelConfigTemplate modelConfigTemplate : config.getModelConfigTemplates()) {
|
||||
mapList.add(modelConfigTemplate.toMap());
|
||||
}
|
||||
yaml.dump(mapList, writer2);
|
||||
|
||||
FileWriter writer3 = new FileWriter(Constant.Path.CONFIG_CUSTOM_PATH);
|
||||
ArrayList<LinkedHashMap<String,String>> mapList1 = new ArrayList<>();
|
||||
for (CustomCommandTemplate customCommandTemplate : config.getCustomCommandTemplates()) {
|
||||
mapList1.add(customCommandTemplate.toMap());
|
||||
}
|
||||
yaml.dump(mapList1, writer3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +230,6 @@ public class Config {
|
||||
}
|
||||
CustomCommandTemplate customCommand = new CustomCommandTemplate(command, modelTemplateIndex, customModel, customPromotion);
|
||||
customCommands.add(customCommand);
|
||||
dump();
|
||||
return "预设添加完毕!\r\n" + customCommand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package work.slhaf.chatai.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CustomCommandTemplate {
|
||||
private String command;
|
||||
private int modelTemplateIndex;
|
||||
private String customModel;
|
||||
private String customPromotion;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "command: " + command + "\r\n" +
|
||||
"modelTemplateIndex: " + modelTemplateIndex + "\r\n" +
|
||||
"customModel: " + customModel + "\r\n" +
|
||||
"customPromotion: " + customPromotion;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String,String> toMap(){
|
||||
LinkedHashMap<String,String> map = new LinkedHashMap<>();
|
||||
map.put("command",command);
|
||||
map.put("modelTemplateIndex", String.valueOf(modelTemplateIndex));
|
||||
map.put("customModel",customModel);
|
||||
map.put("customPromotion",customPromotion);
|
||||
return map;
|
||||
}
|
||||
|
||||
public void loadMap(HashMap<String,String> map){
|
||||
this.command = map.get("command");
|
||||
this.modelTemplateIndex = Integer.parseInt(map.get("modelTemplateIndex"));
|
||||
this.customModel = map.get("customModel");
|
||||
this.customPromotion = map.get("customPromotion");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package work.slhaf.chatai.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelConfigTemplate {
|
||||
private String template_name;
|
||||
private String base_url;
|
||||
private String apikey;
|
||||
|
||||
public LinkedHashMap<String,String> toMap(){
|
||||
LinkedHashMap<String,String> map = new LinkedHashMap<>();
|
||||
map.put("template_name",template_name);
|
||||
map.put("base_url",base_url);
|
||||
map.put("apikey",apikey);
|
||||
return map;
|
||||
}
|
||||
|
||||
public void loadMap(LinkedHashMap<String,String> map){
|
||||
this.apikey = map.get("apikey");
|
||||
this.template_name = map.get("template_name");
|
||||
this.base_url = map.get("base_url");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.constant;
|
||||
package work.slhaf.chatai.constant;
|
||||
|
||||
public enum MethodsConstant {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package plugin.listener;
|
||||
package work.slhaf.chatai.listener;
|
||||
|
||||
import net.mamoe.mirai.event.EventHandler;
|
||||
import net.mamoe.mirai.event.SimpleListenerHost;
|
||||
import net.mamoe.mirai.event.events.FriendMessageEvent;
|
||||
import plugin.chat.constant.Constant;
|
||||
import plugin.utils.ChatUtil;
|
||||
import plugin.utils.OCRUtil;
|
||||
import work.slhaf.chatai.chat.constant.Constant;
|
||||
import work.slhaf.chatai.utils.ChatUtil;
|
||||
import work.slhaf.chatai.utils.OCRUtil;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -1,13 +1,13 @@
|
||||
package plugin.listener;
|
||||
package work.slhaf.chatai.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.mamoe.mirai.event.EventHandler;
|
||||
import net.mamoe.mirai.event.SimpleListenerHost;
|
||||
import net.mamoe.mirai.event.events.GroupMessageEvent;
|
||||
import net.mamoe.mirai.message.data.At;
|
||||
import plugin.chat.constant.Constant;
|
||||
import plugin.utils.ChatUtil;
|
||||
import plugin.utils.OCRUtil;
|
||||
import work.slhaf.chatai.chat.constant.Constant;
|
||||
import work.slhaf.chatai.utils.ChatUtil;
|
||||
import work.slhaf.chatai.utils.OCRUtil;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.listener;
|
||||
package work.slhaf.chatai.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.mamoe.mirai.contact.Group;
|
||||
@@ -8,10 +8,10 @@ import net.mamoe.mirai.event.events.FriendMessageEvent;
|
||||
import net.mamoe.mirai.event.events.GroupMessageEvent;
|
||||
import net.mamoe.mirai.event.events.MessageEvent;
|
||||
import net.mamoe.mirai.message.data.At;
|
||||
import plugin.chat.constant.Constant;
|
||||
import plugin.config.Config;
|
||||
import plugin.config.CustomCommandTemplate;
|
||||
import plugin.utils.ChatUtil;
|
||||
import work.slhaf.chatai.chat.constant.Constant;
|
||||
import work.slhaf.chatai.config.Config;
|
||||
import work.slhaf.chatai.config.CustomCommandTemplate;
|
||||
import work.slhaf.chatai.utils.ChatUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class OwnerMessageListener extends SimpleListenerHost {
|
||||
* @return 处理结果
|
||||
*/
|
||||
private String handleCommand(String instruction, String arguments) throws IOException {
|
||||
return switch (instruction) {
|
||||
String result = switch (instruction) {
|
||||
case "添加预设" -> {
|
||||
if (arguments.matches(Constant.Regex.ADD_CUSTOM)) {
|
||||
String[] argumentsArray = arguments.split(Constant.Order.SPLIT_CUSTOM);
|
||||
@@ -140,5 +140,7 @@ public class OwnerMessageListener extends SimpleListenerHost {
|
||||
case "删除预设" -> Config.ConfigLoader.removeCustom(arguments);
|
||||
default -> "该指令不存在!";
|
||||
};
|
||||
Config.ConfigLoader.dump();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.pojo;
|
||||
package work.slhaf.chatai.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -1,12 +1,12 @@
|
||||
package plugin.utils;
|
||||
package work.slhaf.chatai.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import plugin.chat.ChatClient;
|
||||
import plugin.chat.constant.Constant;
|
||||
import plugin.chat.pojo.ChatResponse;
|
||||
import plugin.config.Config;
|
||||
import plugin.config.CustomCommandTemplate;
|
||||
import plugin.config.ModelConfigTemplate;
|
||||
import work.slhaf.chatai.chat.ChatClient;
|
||||
import work.slhaf.chatai.chat.constant.Constant;
|
||||
import work.slhaf.chatai.chat.pojo.ChatResponse;
|
||||
import work.slhaf.chatai.config.Config;
|
||||
import work.slhaf.chatai.config.CustomCommandTemplate;
|
||||
import work.slhaf.chatai.config.ModelConfigTemplate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin.utils;
|
||||
package work.slhaf.chatai.utils;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.aliyun.ocr_api20210707.Client;
|
||||
@@ -7,8 +7,8 @@ import com.aliyun.ocr_api20210707.models.RecognizeAdvancedResponse;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import plugin.config.Config;
|
||||
import plugin.pojo.OCRDataInfo;
|
||||
import work.slhaf.chatai.config.Config;
|
||||
import work.slhaf.chatai.pojo.OCRDataInfo;
|
||||
|
||||
@Slf4j
|
||||
public class OCRUtil {
|
||||
@@ -1 +1 @@
|
||||
plugin.App
|
||||
work.slhaf.chatai.App
|
||||
@@ -13,7 +13,7 @@ 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 work.slhaf.chatai.App;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
|
||||
Reference in New Issue
Block a user