From 27791fedb5135dbf27e391c55b791325ae54bbe9 Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Thu, 27 Nov 2025 15:40:26 +0200 Subject: [PATCH] =?UTF-8?q?refactor(config):=E9=87=8D=E6=9E=84api=5Fconfig?= =?UTF-8?q?.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- src/configs/api_config.py | 97 +++++++++++++++++++++++++++++++ src/configs/api_config_example.py | 75 ------------------------ 3 files changed, 98 insertions(+), 76 deletions(-) create mode 100644 src/configs/api_config.py delete mode 100644 src/configs/api_config_example.py diff --git a/.gitignore b/.gitignore index 26c1d76..c543b2f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ bili.cookie *.log *.mp4 /bili.cookie -/src/configs/api_config.py + /src/configs/jm_config.yml /src/resources/temp /update_remote_code.py diff --git a/src/configs/api_config.py b/src/configs/api_config.py new file mode 100644 index 0000000..1455267 --- /dev/null +++ b/src/configs/api_config.py @@ -0,0 +1,97 @@ +import yaml +from pathlib import Path + +CURRENT_FILE = Path(__file__).resolve() +ROOT_DIR = CURRENT_FILE.parent.parent.parent # config -> src -> project root +CONFIG_PATH = ROOT_DIR / "config.yaml" + +with open(CONFIG_PATH, "r", encoding="utf-8") as f: + config = yaml.safe_load(f) + +#print(data) +app_id = config['bot']['app_id'] +bot_account = config['bot']['bot_account'] +""" +谷歌邮箱配置 +""" +google_enabled = config['mail']['google']['enabled'] +google_smtp_server = config['mail']['google']['smtp_server'] +google_email = config['mail']['google']['email'] +google_password = config['mail']['google']['password'] +""" +qq 邮箱配置 +""" +qq_enabled = config['mail']['qq']['enabled'] +qq_smtp_server = config['mail']['qq']['smtp_server'] +qq_email = config['mail']['qq']['email'] +qq_password = config['mail']['qq']['password'] + +""" +自建邮箱配置 +""" +server_enabled = config['mail']['server']['enabled'] +server_smtp_server = config['mail']['server']['smtp_server'] +server_email = config['mail']['server']['email'] +server_password = config['mail']['server']['password'] +server_port = int(config['mail']['server']['port']) + +""" +图床配置 +""" +# SMMS图床相关配置 +smms_enabled = config['image_hosting']['smms']['enabled'] +smms_token= config['image_hosting']['smms']['token'] +smms_image_upload_history= config['image_hosting']['smms']['smms_image_upload_history'] + +# 聚合图床相关配置 +ju_he_enabled = config['image_hosting']['superbed']['enabled'] +ju_he_token= config['image_hosting']['superbed']['token'] +ju_he_image_list= config['image_hosting']['superbed']['superbed_image_list'] + +#随机图 anosu +anosu_url = config['image_hosting']['random_pic'] + +# 搜番/acg api +animetrace_url = config['image_hosting']['animetrace']['url'] +""" +AI +""" +admin_password= config['ai']['admin']['password'] +# 图灵机器人相关配置 +v3_enabled = config['ai']['api']['v3']['enabled'] +v3url= config['ai']['api']['v3']['url'] +v3key= config['ai']['api']['v3']['key'] +# DeepSeek相关配置 +deepseek_enabled = config['ai']['api']['deepseek']['enabled'] +deepseek_url= config['ai']['api']['deepseek']['url'] +deepseek_key= config['ai']['api']['deepseek']['key'] + +#硅基流动 +silicon_flow_enabled = config['ai']['api']['silicon_flow']['enabled'] +silicon_flow_url = config['ai']['api']['silicon_flow']['url'] +silicon_flow_key = config['ai']['api']['silicon_flow']['key'] +silicon_flow_model = config['ai']['api']['silicon_flow']['model'] + +""" +Wenku8账号 +""" +wenku8_username = config['wenku8']['user_name'] +wenku8_password = config['wenku8']['password'] + +""" +多米HTTP代理api +""" +proxy_enabled = config['proxy']['enabled'] +proxy_api = config['proxy']['key'] + +""" +二维码生成 API 参数 +""" +qrserver_url = config['qr']['url'] +qrserver_size= config['qr']['size'] + +""" +CodeForces API +""" +codeforces_key = config['codeforces']['key'] +codeforces_secret = config['codeforces']['secret'] \ No newline at end of file diff --git a/src/configs/api_config_example.py b/src/configs/api_config_example.py deleted file mode 100644 index 9c990a3..0000000 --- a/src/configs/api_config_example.py +++ /dev/null @@ -1,75 +0,0 @@ -app_id="" -bot_account= "" -""" -谷歌邮箱配置 -""" -google_smtp_server = "smtp.gmail.com" -google_email ="xxxxxx@gmail.com" -google_password = "1234567891234567" #16位应用码 -""" -qq 邮箱配置 -""" -qq_smtp_server = "smtp.qq.com" -qq_email = "xxxxxxxxxx@qq.com" -qq_password = "123456789123456789" #应用码 - -""" -自建邮箱配置 -""" -server_smtp_server = "example.com" -server_email = "" -server_password = "xxx" -server_port = 587 - -""" -图床配置 -""" -# SMMS图床相关配置 -smms_token= "" # sm.ms图床的token -smms_image_upload_history= "https://sm.ms/api/v2/upload_history" # sm.ms图床获取上传图片历史API地址 - -# 聚合图床相关配置 -ju_he_token= "" # 聚合图床的token -ju_he_image_list= "https://api.superbed.cn/timeline" # 聚合图床获取上传图片历史API地址 - -#随机图 anosu -anosu_url = "https://image.anosu.top/pixiv/json" - -# 搜番/acg api -animetrace_url = "https://api.animetrace.com/v1/search" -""" -AI -""" -admin_password= "123456" # 默认注册管理员密码 -# 图灵机器人相关配置 -v3url= "https://api.vveai.com/v1/chat/completions" -v3key= "" -# DeepSeek相关配置 -deepseek_url= "https://api.deepseek.com" -deepseek_key= "" - -#硅基流动 -silicon_flow_key = "" - -""" -Wenku8账号 -""" -wenku8_username = "" -wenku8_password = "" - -""" -多米HTTP代理api -""" -proxy_api = "" - -""" -二维码生成 API 参数 -""" -qrserver_url = "https://api.qrserver.com/v1/create-qr-code/" -qrserver_size= "200x200" - -""" -CodeForces API -""" -codeforces_key = "" -codeforces_secret = "" \ No newline at end of file