From 167555016ab4c8ea990b4df09b9e035ae1906d70 Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Sat, 20 Jul 2024 00:46:21 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20:=20=E6=89=80=E6=9C=89=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=AE=A1=E7=90=86=E5=85=81=E8=AE=B8=E7=BE=A4=E7=BB=84?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/plugin_switch/__init__.py | 51 ++++++++++--------- .../admin/plugin_switch/command.py | 16 +++--- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py b/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py index 5d84f2b0..36e57c41 100644 --- a/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py +++ b/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py @@ -12,7 +12,7 @@ from zhenxun.utils.enum import BlockType, PluginType from ._data_source import PluginManage, build_plugin, build_task from .command import _group_status_matcher, _status_matcher -base_config = Config.get("admin_bot_manage") +base_config = Config.get("plugin_switch") __plugin_meta__ = PluginMetadata( @@ -23,6 +23,7 @@ __plugin_meta__ = PluginMetadata( 格式: 开启/关闭[功能名称] : 开关功能 开启/关闭群被动[被动名称] : 群被动开关 + 开启/关闭所有插件 : 开启/关闭当前群组所有插件状态 群被动状态 : 查看被动技能开关状态 醒来 : 结束休眠 休息吧 : 群组休眠, 不会再响应命令 @@ -112,30 +113,30 @@ async def _( result = await PluginManage.unblock_group_task(name, gid) logger.info(f"开启群组被动 {name}", arparma.header_result, session=session) else: - if session.id1 in bot.config.superusers and ( - all.result or default_status.result - ): + if session.id1 in bot.config.superusers and default_status.result: + """单个插件的进群默认修改""" + result = await PluginManage.set_default_status(name, True) + logger.info( + f"超级用户开启 {name} 功能进群默认开关", + arparma.header_result, + session=session, + ) + else: if all.result: """所有插件""" result = await PluginManage.set_all_plugin_status( True, default_status.result, gid ) logger.info( - f"超级用户开启群组中全部功能", + f"开启群组中全部功能", arparma.header_result, session=session, ) else: - """单个插件的进群默认修改""" - result = await PluginManage.set_default_status(name, True) + result = await PluginManage.block_group_plugin(name, gid) logger.info( - f"超级用户开启 {name} 功能进群默认开关", - arparma.header_result, - session=session, + f"开启功能 {name}", arparma.header_result, session=session ) - else: - result = await PluginManage.block_group_plugin(name, gid) - logger.info(f"开启功能 {name}", arparma.header_result, session=session) await Text(result).send(reply=True) elif session.id1 in bot.config.superusers: """私聊""" @@ -199,30 +200,30 @@ async def _( if task.result: result = await PluginManage.block_group_task(name, gid) else: - if session.id1 in bot.config.superusers and ( - all.result or default_status.result - ): + if session.id1 in bot.config.superusers and default_status.result: + """单个插件的进群默认修改""" + result = await PluginManage.set_default_status(name, False) + logger.info( + f"超级用户开启 {name} 功能进群默认开关", + arparma.header_result, + session=session, + ) + else: if all.result: """所有插件""" result = await PluginManage.set_all_plugin_status( False, default_status.result, gid ) logger.info( - f"超级用户开启群组中全部功能", + f"关闭群组中全部功能", arparma.header_result, session=session, ) else: - """单个插件的进群默认修改""" - result = await PluginManage.set_default_status(name, False) + result = await PluginManage.unblock_group_plugin(name, gid) logger.info( - f"超级用户开启 {name} 功能进群默认开关", - arparma.header_result, - session=session, + f"关闭功能 {name}", arparma.header_result, session=session ) - else: - result = await PluginManage.unblock_group_plugin(name, gid) - logger.info(f"关闭功能 {name}", arparma.header_result, session=session) await Text(result).send(reply=True) elif session.id1 in bot.config.superusers: group_id = group.result if group.available else None diff --git a/zhenxun/builtin_plugins/admin/plugin_switch/command.py b/zhenxun/builtin_plugins/admin/plugin_switch/command.py index 13f13999..ddbdb535 100644 --- a/zhenxun/builtin_plugins/admin/plugin_switch/command.py +++ b/zhenxun/builtin_plugins/admin/plugin_switch/command.py @@ -37,14 +37,14 @@ _status_matcher = on_alconna( ), ), ), - rule=admin_check("admin_bot_manage", "CHANGE_GROUP_SWITCH_LEVEL"), + rule=admin_check("plugin_switch", "CHANGE_GROUP_SWITCH_LEVEL"), priority=5, block=True, ) _group_status_matcher = on_alconna( Alconna("group-status", Args["status", ["sleep", "wake"]]), - rule=admin_check("admin_bot_manage", "CHANGE_GROUP_SWITCH_LEVEL") + rule=admin_check("plugin_switch", "CHANGE_GROUP_SWITCH_LEVEL") & ensure_group & to_me(), priority=5, @@ -75,21 +75,21 @@ _status_matcher.shortcut( _status_matcher.shortcut( - r"开启所有插件", + r"开启所有(插件|功能)", command="switch", arguments=["open", "s", "--all"], prefix=True, ) _status_matcher.shortcut( - r"开启所有插件df", + r"开启所有(插件|功能)df", command="switch", arguments=["open", "s", "-df", "--all"], prefix=True, ) _status_matcher.shortcut( - r"开启插件df(?P.+)", + r"开启(插件|功能)df(?P.+)", command="switch", arguments=["open", "{name}", "-df"], prefix=True, @@ -112,21 +112,21 @@ _status_matcher.shortcut( _status_matcher.shortcut( - r"关闭所有插件", + r"关闭所有(插件|功能)", command="switch", arguments=["close", "s", "--all"], prefix=True, ) _status_matcher.shortcut( - r"关闭所有插件df", + r"关闭所有(插件|功能)df", command="switch", arguments=["close", "s", "-df", "--all"], prefix=True, ) _status_matcher.shortcut( - r"关闭插件df(?P.+)", + r"关闭(插件|功能)df(?P.+)", command="switch", arguments=["close", "{name}", "-df"], prefix=True,