From 31022a653de85aece3826b64e92fb25b7931df65 Mon Sep 17 00:00:00 2001 From: AkiraXie Date: Sun, 18 Sep 2022 22:33:36 +0800 Subject: [PATCH] =?UTF-8?q?Feature:=20`SUPERUSER`=20=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E4=BB=BB=E6=84=8F=E8=B6=85=E7=AE=A1=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=20(#1275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- nonebot/permission.py | 4 ++-- tests/test_permission.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nonebot/permission.py b/nonebot/permission.py index 46a1f3de..49226f6f 100644 --- a/nonebot/permission.py +++ b/nonebot/permission.py @@ -94,7 +94,7 @@ class SuperUser: return "Superuser()" async def __call__(self, bot: Bot, event: Event) -> bool: - return event.get_type() == "message" and ( + return ( f"{bot.adapter.get_name().split(maxsplit=1)[0].lower()}:{event.get_user_id()}" in bot.config.superusers or event.get_user_id() in bot.config.superusers # 兼容旧配置 @@ -102,7 +102,7 @@ class SuperUser: SUPERUSER: Permission = Permission(SuperUser()) -"""匹配任意超级用户消息类型事件""" +"""匹配任意超级用户事件""" __autodoc__ = { "Permission": True, diff --git a/tests/test_permission.py b/tests/test_permission.py index 965d2607..bea16e33 100644 --- a/tests/test_permission.py +++ b/tests/test_permission.py @@ -144,7 +144,7 @@ async def test_metaevent( ("message", "test", True), ("message", "foo", False), ("message", "faketest", True), - ("notice", "test", False), + ("notice", "test", True), ], ) async def test_superuser(