mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 00:32:06 +08:00
🎨 功能开关代码优化 (#1680)
* 🎨 功能开关代码优化 * chore(version): Update version to v0.2.3-5f361ff --------- Co-authored-by: HibiKier <HibiKier@users.noreply.github.com>
This commit is contained in:
@@ -133,7 +133,7 @@ async def build_task(group_id: str | None) -> BuildImage:
|
||||
task.id,
|
||||
task.module,
|
||||
task.name,
|
||||
"开启" if task.module not in group.block_task else "关闭",
|
||||
"开启" if f"<{task.module}," not in group.block_task else "关闭",
|
||||
"开启" if task.status else "关闭",
|
||||
task.run_time or "-",
|
||||
]
|
||||
@@ -214,9 +214,6 @@ class PluginManage:
|
||||
f"<{module},", ""
|
||||
)
|
||||
else:
|
||||
module_list = await PluginInfo.filter(
|
||||
plugin_type=PluginType.NORMAL
|
||||
).values_list("module", flat=True)
|
||||
module_list = [f"<{module}" for module in module_list]
|
||||
group.block_plugin = ",".join(module_list) + "," # type: ignore
|
||||
await group.save(update_fields=["block_plugin"])
|
||||
|
||||
@@ -70,16 +70,20 @@ async def _():
|
||||
data_list = []
|
||||
for group in await GroupConsole.all():
|
||||
if group.block_plugin:
|
||||
if modules := group.block_plugin.split(",")[:-1]:
|
||||
if modules := group.block_plugin.split(","):
|
||||
if block_plugin := [
|
||||
f"<{module}" for module in modules if not module.startswith("<")
|
||||
]:
|
||||
group.block_plugin = ",".join(block_plugin) + ","
|
||||
group.block_plugin = (",".join(block_plugin) + ",").replace(
|
||||
"<,", ""
|
||||
)
|
||||
if group.block_task:
|
||||
if modules := group.block_task.split(",")[:-1]:
|
||||
if modules := group.block_task.split(","):
|
||||
if block_task := [
|
||||
f"<{module}" for module in modules if not module.startswith("<")
|
||||
]:
|
||||
group.block_task = ",".join(block_task) + ","
|
||||
group.block_task = (",".join(block_task) + ",").replace(
|
||||
"<,", ""
|
||||
)
|
||||
data_list.append(group)
|
||||
await GroupConsole.bulk_update(data_list, ["block_plugin", "block_task"], 10)
|
||||
|
||||
Reference in New Issue
Block a user