新增安全模式启动

This commit is contained in:
2024-04-20 12:46:49 +08:00
parent 7585a5473d
commit 18d9ac3249
4 changed files with 26 additions and 18 deletions

View File

@ -36,12 +36,18 @@ def load_from_yaml(file: str) -> dict:
return conf
def get_config(key: str, *, bot: T_Bot = None, default=None):
def get_config(key: str, default=None):
"""获取配置项优先级bot > config > db > yaml"""
try:
bot = nonebot.get_bot()
except:
bot = None
if bot is None:
bot_config = {}
else:
bot_config = bot.config.dict()
if key in bot_config:
return bot_config[key]