mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-19 12:47:25 +08:00
feat: check app_code dynamically
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import json
|
||||
from config import pconf
|
||||
from config import pconf, plugin_config
|
||||
from common.log import logger
|
||||
|
||||
|
||||
@@ -24,5 +24,22 @@ class Plugin:
|
||||
logger.debug(f"loading plugin config, plugin_name={self.name}, conf={plugin_conf}")
|
||||
return plugin_conf
|
||||
|
||||
def save_config(self, config: dict):
|
||||
try:
|
||||
plugin_config[self.name] = config
|
||||
# 写入全局配置
|
||||
global_config_path = "./plugins/config.json"
|
||||
if os.path.exists(global_config_path):
|
||||
with open(global_config_path, "w", encoding='utf-8') as f:
|
||||
json.dump(plugin_config, f, indent=4, ensure_ascii=False)
|
||||
# 写入插件配置
|
||||
plugin_config_path = os.path.join(self.path, "config.json")
|
||||
if os.path.exists(plugin_config_path):
|
||||
with open(plugin_config_path, "w", encoding='utf-8') as f:
|
||||
json.dump(config, f, indent=4, ensure_ascii=False)
|
||||
|
||||
except Exception as e:
|
||||
logger.warn("save plugin config failed: {}".format(e))
|
||||
|
||||
def get_help_text(self, **kwargs):
|
||||
return "暂无帮助信息"
|
||||
|
||||
Reference in New Issue
Block a user