Feature: SUPERUSER 权限匹配任意超管事件 (#1275)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
AkiraXie 2022-09-18 22:33:36 +08:00 committed by GitHub
parent ba77443dde
commit 31022a653d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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,

View File

@ -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(