|
|
@@ -31,6 +31,7 @@ available_setting = {
|
|
|
"trigger_by_self": False, # 是否允许机器人触发
|
|
|
"image_create_prefix": ["画", "看", "找"], # 开启图片回复的前缀
|
|
|
"concurrency_in_session": 1, # 同一会话最多有多少条消息在处理中,大于1可能乱序
|
|
|
+ "image_create_size": "256x256", # 图片大小,可选有 256x256, 512x512, 1024x1024
|
|
|
# chatgpt会话参数
|
|
|
"expires_in_seconds": 3600, # 无操作会话的过期时间
|
|
|
"character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。", # 人格描述
|
|
|
@@ -79,6 +80,7 @@ available_setting = {
|
|
|
# channel配置
|
|
|
"channel_type": "wx", # 通道类型,支持:{wx,wxy,terminal,wechatmp,wechatmp_service}
|
|
|
"debug": False, # 是否开启debug模式,开启后会打印更多日志
|
|
|
+ "appdata_dir": "", # 数据目录
|
|
|
# 插件配置
|
|
|
"plugin_trigger_prefix": "$", # 规范插件提供聊天相关指令的前缀,建议不要和管理员指令前缀"#"冲突
|
|
|
}
|
|
|
@@ -116,7 +118,7 @@ class Config(dict):
|
|
|
|
|
|
def load_user_datas(self):
|
|
|
try:
|
|
|
- with open("user_datas.pkl", "rb") as f:
|
|
|
+ with open(os.path.join(get_appdata_dir(), "user_datas.pkl"), "rb") as f:
|
|
|
self.user_datas = pickle.load(f)
|
|
|
logger.info("[Config] User datas loaded.")
|
|
|
except FileNotFoundError as e:
|
|
|
@@ -127,7 +129,7 @@ class Config(dict):
|
|
|
|
|
|
def save_user_datas(self):
|
|
|
try:
|
|
|
- with open("user_datas.pkl", "wb") as f:
|
|
|
+ with open(os.path.join(get_appdata_dir(), "user_datas.pkl"), "wb") as f:
|
|
|
pickle.dump(self.user_datas, f)
|
|
|
logger.info("[Config] User datas saved.")
|
|
|
except Exception as e:
|
|
|
@@ -188,3 +190,11 @@ def read_file(path):
|
|
|
|
|
|
def conf():
|
|
|
return config
|
|
|
+
|
|
|
+
|
|
|
+def get_appdata_dir():
|
|
|
+ data_path = os.path.join(get_root(), conf().get("appdata_dir", ""))
|
|
|
+ if not os.path.exists(data_path):
|
|
|
+ logger.info("[INIT] data path not exists, create it: {}".format(data_path))
|
|
|
+ os.makedirs(data_path)
|
|
|
+ return data_path
|