mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 08:39:59 +08:00
✨ 资源下载分离 (#1814)
* 🚀 资源文件单独下载,分离被动任务初始化 * 🔥 移除resources文件夹 * 🚀 优化版本更新逻辑,增加资源下载异常处理 * 🚀 增加资源下载失败异常处理及提示信息 * 🚀 增加资源下载选项及异常处理优化 * 🚀 移除空ID检查及资源更新条件处理 * ✨ 简易配置中未加载的配置将被移除 * 🐛 测试更新 * ✨ 修复更新完成消息格式 --------- Co-authored-by: Flern <cb56ec362bbbfb5272eb941281299d8d-qq_connect@git.osc>
This commit is contained in:
@@ -34,7 +34,6 @@ async def _handle_setting(
|
||||
plugin: Plugin,
|
||||
plugin_list: list[PluginInfo],
|
||||
limit_list: list[PluginLimit],
|
||||
task_list: list[tuple[bool, TaskInfo]],
|
||||
):
|
||||
"""处理插件设置
|
||||
|
||||
@@ -91,20 +90,6 @@ async def _handle_setting(
|
||||
)
|
||||
for limit in extra_data.limits
|
||||
)
|
||||
if extra_data.tasks:
|
||||
task_list.extend(
|
||||
(
|
||||
task.create_status,
|
||||
TaskInfo(
|
||||
module=task.module,
|
||||
name=task.name,
|
||||
status=task.status,
|
||||
run_time=task.run_time,
|
||||
default_status=task.default_status,
|
||||
),
|
||||
)
|
||||
for task in extra_data.tasks
|
||||
)
|
||||
|
||||
|
||||
@driver.on_startup
|
||||
@@ -114,14 +99,13 @@ async def _():
|
||||
"""
|
||||
plugin_list: list[PluginInfo] = []
|
||||
limit_list: list[PluginLimit] = []
|
||||
task_list = []
|
||||
module2id = {}
|
||||
load_plugin = []
|
||||
if module_list := await PluginInfo.all().values("id", "module_path"):
|
||||
module2id = {m["module_path"]: m["id"] for m in module_list}
|
||||
for plugin in get_loaded_plugins():
|
||||
load_plugin.append(plugin.module_name)
|
||||
await _handle_setting(plugin, plugin_list, limit_list, task_list)
|
||||
await _handle_setting(plugin, plugin_list, limit_list)
|
||||
create_list = []
|
||||
update_list = []
|
||||
for plugin in plugin_list:
|
||||
@@ -170,33 +154,6 @@ async def _():
|
||||
# limit_create.append(limit)
|
||||
# if limit_create:
|
||||
# await PluginLimit.bulk_create(limit_create, 10)
|
||||
if task_list:
|
||||
module_dict = {
|
||||
t[1]: t[0] for t in await TaskInfo.all().values_list("id", "module")
|
||||
}
|
||||
create_list = []
|
||||
update_list = []
|
||||
for status, task in task_list:
|
||||
if task.module not in module_dict:
|
||||
create_list.append((status, task))
|
||||
else:
|
||||
task.id = module_dict[task.module]
|
||||
update_list.append(task)
|
||||
if create_list:
|
||||
_create_list = [t[1] for t in create_list]
|
||||
await TaskInfo.bulk_create(_create_list, 10)
|
||||
if block := [t[1].module for t in create_list if not t[0]]:
|
||||
block_task = ",".join(block) + ","
|
||||
if group_list := await GroupConsole.all():
|
||||
for group in group_list:
|
||||
group.block_task += block_task
|
||||
await GroupConsole.bulk_update(group_list, ["block_task"], 10)
|
||||
if update_list:
|
||||
await TaskInfo.bulk_update(
|
||||
update_list,
|
||||
["run_time", "name"],
|
||||
10,
|
||||
)
|
||||
await data_migration()
|
||||
await PluginInfo.filter(module_path__in=load_plugin).update(load_status=True)
|
||||
await PluginInfo.filter(module_path__not_in=load_plugin).update(load_status=False)
|
||||
|
||||
Reference in New Issue
Block a user