代码拉取完成,页面将自动刷新
import json
import logging
import os
class EnvConfig:
def __init__(self):
wxConf = self.load_config()
for key, value in wxConf.items():
setattr(self, key, value)
@staticmethod
def load_config() -> dict | None:
try:
config_path = ['./config.json', './config_template.json']
for path in config_path:
if os.path.exists(path):
with open(path, 'r', encoding='utf-8') as f:
config_str = f.read()
res_config = json.loads(config_str)
for name, value in os.environ.items():
name = name.upper()
if name in res_config:
try:
res_config[name] = eval(value)
except:
if value == "false":
res_config[name] = False
elif value == "true":
res_config[name] = True
else:
res_config[name] = value
logging.info(f"[config] Override the config by env conf {name}={value}")
logging.info("[INIT] Load config: {}".format(res_config))
return res_config
except Exception as e:
logging.critical("[config] Failed to load config json file, or path not exists. Process exit.")
logging.critical(e)
exit(1)
def reload_config(self):
wxConf = self.load_config()
for key, value in wxConf.items():
setattr(self, key, value)
envConfig = EnvConfig()
SERVER_HOST: str = 'http://192.168.3.3' if os.getenv("SERVER_HOST") is None else os.getenv("SERVER_HOST")
SERVER_PORT: int = 5005 if os.getenv("SERVER_PORT") is None else int(os.getenv("SERVER_PORT"))
DEFAULT_DATE_FORMAT: str = '%Y-%m-%d'
DEFAULT_TIME_FORMAT: str = DEFAULT_DATE_FORMAT + ' %H:%M:%S'
FILENAME_TIME_FORMAT: str = '%Y%M%d%H%M%S'
ROOT_PATH: str = os.path.dirname(__file__)
APP_DATA_DIR: str = os.path.join(ROOT_PATH, 'data')
GEN_FILE_DIR: str = os.path.join(APP_DATA_DIR, 'gen')
TEMPLATE_DIR: str = os.path.join(APP_DATA_DIR, 'templates')
TMP_FILE_ROOT_DIR: str = os.path.join(os.path.dirname(__file__), 'data', 'tmp')
LOG_DIR: str = os.path.join(ROOT_PATH, 'logs')
MINIO_BUCKET_NAME = 'kqk-bucket'
# ---WX---
HOT_RELOAD = True
GROUP_CHAT_PREFIX = [
"@咕噜蛋",
"咕噜蛋",
"金桔王"
]
SINGLE_CHAT_PREFIX = [
"咕噜蛋",
"金桔王",
]
GROUP_CHAT_REPLY_PREFIX = os.getenv("GROUP_CHAT_REPLY_PREFIX") if os.getenv("GROUP_CHAT_REPLY_PREFIX") is not None else ""
GROUP_CHAT_REPLY_SUFFIX = os.getenv("GROUP_CHAT_REPLY_SUFFIX") if os.getenv("GROUP_CHAT_REPLY_SUFFIX") is not None else ""
SINGLE_CHAT_REPLY_PREFIX = os.getenv("SINGLE_CHAT_REPLY_PREFIX") if os.getenv("SINGLE_CHAT_REPLY_PREFIX") is not None else ""
SINGLE_CHAT_REPLY_SUFFIX = os.getenv("SINGLE_CHAT_REPLY_SUFFIX") if os.getenv("SINGLE_CHAT_REPLY_SUFFIX") is not None else ""
GROUP_NAME_WHITE_LIST = os.getenv("GROUP_NAME_WHITE_LIST") if os.getenv("GROUP_NAME_WHITE_LIST") is not None else [
"鑫茂园",
"测试群"
]
# NICK_NAME_BLACK_LIST = []
NO_NEED_AT = False
ACCEPT_FILE_TYPE = [
"xlsx",
"xls"
]
FILE_MSG_SPLITER = ";;;"
CONCURRENCY_IN_SESSION = 1
EXPIRED_IN_SECONDS = 3600
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。