mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
取消配置替换定时任务,统一存储
This commit is contained in:
parent
82fe59e469
commit
d2dccfebc5
@ -108,16 +108,16 @@ def init_plugins_config(data_path):
|
||||
_data, wf, indent=2, Dumper=yaml.RoundTripDumper, allow_unicode=True
|
||||
)
|
||||
user_config_file = Path() / "configs" / "config.yaml"
|
||||
if not user_config_file.exists():
|
||||
_replace_config()
|
||||
else:
|
||||
logger.info('五分钟后将进行配置数据替换,请注意...')
|
||||
scheduler.add_job(
|
||||
_replace_config,
|
||||
"date",
|
||||
run_date=datetime.now() + timedelta(minutes=5),
|
||||
id=f"_replace_config"
|
||||
)
|
||||
# if not user_config_file.exists():
|
||||
_replace_config()
|
||||
# else:
|
||||
# logger.info('五分钟后将进行配置数据替换,请注意...')
|
||||
# scheduler.add_job(
|
||||
# _replace_config,
|
||||
# "date",
|
||||
# run_date=datetime.now() + timedelta(minutes=5),
|
||||
# id=f"_replace_config"
|
||||
# )
|
||||
|
||||
|
||||
def _replace_config():
|
||||
|
||||
@ -94,13 +94,14 @@ class ConfigsManager:
|
||||
del self._data[module]
|
||||
self.save()
|
||||
|
||||
def set_config(self, module: str, key: str, value: Any, save_simple_data: bool = False):
|
||||
def set_config(self, module: str, key: str, value: Any, auto_save: bool = False, save_simple_data: bool = True):
|
||||
"""
|
||||
设置配置值
|
||||
:param module: 模块名
|
||||
:param key: 配置名称
|
||||
:param value: 值
|
||||
:param save_simple_data: 同时保存至config.yaml
|
||||
:param auto_save: 自动保存
|
||||
:param save_simple_data: 保存至config.yaml
|
||||
"""
|
||||
if module in self._data.keys():
|
||||
if (
|
||||
@ -109,6 +110,7 @@ class ConfigsManager:
|
||||
):
|
||||
self._data[module][key]["value"] = value
|
||||
self._simple_data[module][key] = value
|
||||
if auto_save:
|
||||
self.save(save_simple_data=save_simple_data)
|
||||
|
||||
def set_help(self, module: str, key: str, help_: str):
|
||||
@ -145,18 +147,12 @@ class ConfigsManager:
|
||||
:param default: 没有key值内容的默认返回值
|
||||
"""
|
||||
key = key.upper()
|
||||
# 优先使用simple_data
|
||||
if module in self._simple_data.keys():
|
||||
if module in self._data.keys():
|
||||
for key in [key, f"{key} [LEVEL]"]:
|
||||
if self._simple_data[module].get(key) is not None:
|
||||
return self._simple_data[module][key]
|
||||
# if module in self._data.keys():
|
||||
# if module in self._data.keys():
|
||||
# for key in [key, f"{key} [LEVEL]"]:
|
||||
# if self._data[module].get(key) is not None:
|
||||
# if self._data[module][key]["value"] is None:
|
||||
# return self._data[module][key]["value"]
|
||||
# return self._data[module][key]["default_value"]
|
||||
if self._data[module].get(key) is not None:
|
||||
if self._data[module][key]["value"] is None:
|
||||
return self._data[module][key]["default_value"]
|
||||
return self._data[module][key]["value"]
|
||||
if default is not None:
|
||||
return default
|
||||
return None
|
||||
|
||||
@ -53,6 +53,8 @@ async def _(event: MessageEvent, state: T_State, arg: Message = CommandArg()):
|
||||
if img_list:
|
||||
state["img_list"] = arg
|
||||
|
||||
print(Config.get_config("image_management", "IMAGE_DIR_LIST"))
|
||||
|
||||
|
||||
@upload_img.got(
|
||||
"path",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user