Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
[#] Config -> 最低支持版本 & 其它小改动
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoCurit committed Feb 13, 2024
1 parent 095da0b commit ce39db1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

public class ConfigData {
public int Version = 0;
public int Version_minSupport = 0;
public List<ConfigBotsData> Bots = new ArrayList<>();
public Boolean UsingProxy = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@
import java.nio.file.Paths;

public class ConfigManage {
public static String configFile = "Config.yml";
public static int configVersion = 0;
public static ConfigData configs;
private static final Logger logger = LogManager.getLogger(ConfigManage.class);


public static void ReadConfig () {
try {
Configs = YamlConfig.loadFromFile(new File("Config.yml"), new ConfigData());
configs = YamlConfig.loadFromFile(new File(configFile), new ConfigData());
if (configs.Version_minSupport > configVersion) {
throw new Exception("配置版本过高");
}
logger.info("加载配置成功");
} catch (Exception e) {
logger.warn("加载配置失败",e);
Expand All @@ -31,7 +36,7 @@ public static void DefaultConfig() {
return;
}
try (InputStream is = Main.class.getResourceAsStream("/Config.yml");
OutputStream os = new FileOutputStream("Config.yml")) {
OutputStream os = new FileOutputStream(configFile)) {
if (is == null) {
throw new IllegalArgumentException("找不到jar内资源文件:Config.yml");
}
Expand All @@ -47,7 +52,7 @@ public static void DefaultConfig() {
}
public static void SaveConfig() {
try {
Files.writeString(new File("Config.yml").toPath(), YamlConfig.saveToString(Configs));
Files.writeString(new File(configFile).toPath(), YamlConfig.saveToString(configs));
logger.info("保存配置成功");
} catch (Exception e) {
logger.warn("保存配置失败",e);
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/Config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#配置版本 无特殊不需要改动
Version: 0
Version_minSupport: 0

#创建Bot 根据不同的密钥访问不同的Bot
Bots:
- #访问密钥 留空或default 表示无需密钥 通过不同的密钥链接不同的bot
Key: "default"
Expand All @@ -27,13 +29,13 @@ ProxyType: "HTTP"
#API端口设置为0关闭 如果HTTP和HTTPS都监听失败则无法启动
#API端口 默认8092 curl http://127.0.0.1:8092/Ping
APIPort: 8092
#最大同时处理API请求的线程数
APIMaxThread: 10
#API HTTPS 端口 默认8093 curl https://127.0.0.1:8093/Ping
APISSLPort: 8093
#API HTTPS 证书 格式jks
APISSL_keyStorePath: "keystore.jks"
APISSL_keyStorePassword: "123456"
#最大同时处理API请求的线程数
APIMaxThread: 10

#通过OpenAI官方接口调用时聊天历史记录模式
# 0 = 关闭上下文 , 将最新一条消息发送到默认频道 (如要使用还需要请在Coze中关闭上下文记忆)
Expand Down

0 comments on commit ce39db1

Please sign in to comment.