From 3acd7d7d413f8cc0cb94bab6a032413a05e8820a Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Sat, 24 Dec 2022 18:57:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BE=A4=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=9D=83=E9=99=90=E6=A3=80=E6=B5=8B=E4=BC=9A=E9=98=BB?= =?UTF-8?q?=E6=8C=A1=E8=B6=85=E7=BA=A7=E7=94=A8=E6=88=B7=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ basic_plugins/hooks/_utils.py | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4481cda2..199b8d45 100644 --- a/README.md +++ b/README.md @@ -296,6 +296,10 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能 ## 更新 +## 2022/12/24 + +* 修复群管理员权限检测会阻挡超级用户权限 + ### 2022/12/23 * 优化`管理员帮助`,`超级用户帮助`图片 diff --git a/basic_plugins/hooks/_utils.py b/basic_plugins/hooks/_utils.py index c32906f8..0219b6be 100644 --- a/basic_plugins/hooks/_utils.py +++ b/basic_plugins/hooks/_utils.py @@ -116,7 +116,7 @@ async def send_msg(msg: str, bot: Bot, event: MessageEvent): pass -class ReturnException(Exception): +class IsSuperuserException(Exception): pass @@ -144,14 +144,15 @@ class AuthChecker: try: plugin_name = matcher.plugin_name cost_gold = await self.auth_cost(plugin_name, bot, event) - await self.auth_basic(plugin_name, bot, event) - self.auth_group(plugin_name, bot, event) - await self.auth_admin(plugin_name, matcher, bot, event) - await self.auth_plugin(plugin_name, matcher, bot, event) - await self.auth_limit(plugin_name, bot, event) - if cost_gold and str(event.user_id) not in bot.config.superusers: - await BagUser.spend_gold(event.user_id, event.group_id, cost_gold) - except ReturnException: + if str(event.user_id) not in bot.config.superusers: + await self.auth_basic(plugin_name, bot, event) + self.auth_group(plugin_name, bot, event) + await self.auth_admin(plugin_name, matcher, bot, event) + await self.auth_plugin(plugin_name, matcher, bot, event) + await self.auth_limit(plugin_name, bot, event) + if cost_gold: + await BagUser.spend_gold(event.user_id, event.group_id, cost_gold) + except IsSuperuserException: return async def auth_limit(self, plugin_name: str, bot: Bot, event: Event): @@ -336,7 +337,7 @@ class AuthChecker: if isinstance( event, GroupMessageEvent ) and group_manager.check_group_is_white(event.group_id): - raise ReturnException() + raise IsSuperuserException() try: if isinstance(event, GroupMessageEvent): if ( @@ -463,7 +464,7 @@ class AuthChecker: plugin_name ).limit_superuser ): - raise ReturnException() + raise IsSuperuserException() _plugin = nonebot.plugin.get_plugin(plugin_name) _module = _plugin.module _plugin_name = _module.__getattribute__("__zx_plugin_name__") @@ -471,7 +472,7 @@ class AuthChecker: "[superuser]" in _plugin_name.lower() and str(event.user_id) in bot.config.superusers ): - raise ReturnException() + raise IsSuperuserException() except AttributeError: pass