mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-30 01:00:02 +08:00
fix(admin/plugin_switch): 移除冗余的return语句并修正逻辑判断 (#2109)
* fix(admin-plugin_switch): 修复插件名称处理逻辑 当plugin_name不可用时,将name设置为空字符串, 避免在后续逻辑中使用未定义的变量导致错误。 * fix(admin/plugin_switch): 移除冗余的return语句并修正逻辑判断 移除了_handle_switch_command函数中多处冗余的return语句, 修正了超级用户权限检查的逻辑条件, 调整了状态设置时的block_type默认值处理逻辑。
This commit is contained in:
@@ -174,11 +174,9 @@ async def _handle_switch_command(
|
||||
await MessageUtils.build_message(
|
||||
"被动技能不支持指定禁用范围,请直接使用 开启/关闭"
|
||||
).finish(reply_to=True)
|
||||
return
|
||||
|
||||
if not all_plugins_flag.result and not plugin_names.available:
|
||||
await MessageUtils.build_message("请输入功能/被动名称").finish(reply_to=True)
|
||||
return
|
||||
|
||||
targets = await get_target_groups(
|
||||
bot,
|
||||
@@ -206,7 +204,6 @@ async def _handle_switch_command(
|
||||
)
|
||||
)
|
||||
await MessageUtils.build_message("\n".join(messages)).finish(reply_to=True)
|
||||
return
|
||||
if is_superuser and not session.group:
|
||||
result = await PluginManager.set_all_plugin_status(
|
||||
status=status,
|
||||
@@ -217,9 +214,7 @@ async def _handle_switch_command(
|
||||
use_su_field=use_su_field_final,
|
||||
)
|
||||
await MessageUtils.build_message(result).finish(reply_to=True)
|
||||
return
|
||||
await MessageUtils.build_message("请输入目标群组").finish(reply_to=True)
|
||||
return
|
||||
|
||||
names = plugin_names.result if plugin_names.available else ()
|
||||
if isinstance(names, str):
|
||||
@@ -227,12 +222,11 @@ async def _handle_switch_command(
|
||||
|
||||
if (
|
||||
not targets
|
||||
and not (is_superuser and not session.group)
|
||||
and (not is_superuser or session.group)
|
||||
and not default_status.result
|
||||
and block_type_val is None
|
||||
):
|
||||
await MessageUtils.build_message("请选择一个目标群组").finish(reply_to=True)
|
||||
return
|
||||
|
||||
messages = []
|
||||
for name in names:
|
||||
@@ -258,7 +252,7 @@ async def _handle_switch_command(
|
||||
|
||||
if not targets:
|
||||
if is_superuser and not session.group:
|
||||
target_block_type = BlockType.ALL if not status else None
|
||||
target_block_type = None if status else BlockType.ALL
|
||||
result = await PluginManager.superuser_set_status(
|
||||
name_str, status, target_block_type, None, is_task=task.result
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user