mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-05 03:39:59 +08:00
✨ 资源下载分离 (#1814)
* 🚀 资源文件单独下载,分离被动任务初始化 * 🔥 移除resources文件夹 * 🚀 优化版本更新逻辑,增加资源下载异常处理 * 🚀 增加资源下载失败异常处理及提示信息 * 🚀 增加资源下载选项及异常处理优化 * 🚀 移除空ID检查及资源更新条件处理 * ✨ 简易配置中未加载的配置将被移除 * 🐛 测试更新 * ✨ 修复更新完成消息格式 --------- Co-authored-by: Flern <cb56ec362bbbfb5272eb941281299d8d-qq_connect@git.osc>
This commit is contained in:
@@ -25,7 +25,7 @@ if old_config_file.exists():
|
||||
old_config_file.rename(SIMPLE_CONFIG_FILE)
|
||||
|
||||
|
||||
def _handle_config(plugin: Plugin):
|
||||
def _handle_config(plugin: Plugin, exists_module: list[str]):
|
||||
"""处理配置项
|
||||
|
||||
参数:
|
||||
@@ -49,9 +49,10 @@ def _handle_config(plugin: Plugin):
|
||||
arg_parser=reg_config.arg_parser,
|
||||
_override=False,
|
||||
)
|
||||
exists_module.append(f"{module}:{reg_config.key}")
|
||||
|
||||
|
||||
def _generate_simple_config():
|
||||
def _generate_simple_config(exists_module: list[str]):
|
||||
"""
|
||||
生成简易配置
|
||||
|
||||
@@ -70,9 +71,12 @@ def _generate_simple_config():
|
||||
try:
|
||||
if _data.get(module) and k in _data[module].keys():
|
||||
Config.set_config(module, k, _data[module][k])
|
||||
_tmp_data[module][k] = Config.get_config(module, k)
|
||||
if f"{module}:{k}" in exists_module:
|
||||
_tmp_data[module][k] = Config.get_config(module, k)
|
||||
except AttributeError as e:
|
||||
raise AttributeError(f"{e}\n可能为config.yaml配置文件填写不规范") from e
|
||||
if not _tmp_data[module]:
|
||||
_tmp_data.pop(module)
|
||||
Config.save()
|
||||
temp_file = DATA_PATH / "temp_config.yaml"
|
||||
# 重新生成简易配置文件
|
||||
@@ -103,9 +107,10 @@ def _():
|
||||
初始化插件数据配置
|
||||
"""
|
||||
plugins2config_file = DATA_PATH / "configs" / "plugins2config.yaml"
|
||||
exists_module = []
|
||||
for plugin in get_loaded_plugins():
|
||||
if plugin.metadata:
|
||||
_handle_config(plugin)
|
||||
_handle_config(plugin, exists_module)
|
||||
if not Config.is_empty():
|
||||
Config.save()
|
||||
_data: CommentedMap = _yaml.load(plugins2config_file.open(encoding="utf8"))
|
||||
@@ -118,4 +123,4 @@ def _():
|
||||
# 存完插件基本设置
|
||||
with plugins2config_file.open("w", encoding="utf8") as wf:
|
||||
_yaml.dump(_data, wf)
|
||||
_generate_simple_config()
|
||||
_generate_simple_config(exists_module)
|
||||
|
||||
Reference in New Issue
Block a user