From d1e32cd820e29c2aac854a469b054905f372f988 Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Tue, 7 Apr 2026 08:37:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin/plugin=5Fswitch):=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=86=97=E4=BD=99=E7=9A=84return=E8=AF=AD=E5=8F=A5?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E6=AD=A3=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD?= =?UTF-8?q?=20(#2109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(admin-plugin_switch): 修复插件名称处理逻辑 当plugin_name不可用时,将name设置为空字符串, 避免在后续逻辑中使用未定义的变量导致错误。 * fix(admin/plugin_switch): 移除冗余的return语句并修正逻辑判断 移除了_handle_switch_command函数中多处冗余的return语句, 修正了超级用户权限检查的逻辑条件, 调整了状态设置时的block_type默认值处理逻辑。 --- .../builtin_plugins/admin/plugin_switch/__init__.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py b/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py index 2fe9f2aa..ad5ea9e3 100644 --- a/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py +++ b/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py @@ -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 )