From ce56f796874c6b977585302d6245a64d73caadcb Mon Sep 17 00:00:00 2001 From: Tigrex Dai Date: Sun, 22 Sep 2024 15:39:48 +0800 Subject: [PATCH] Update aiocqhttp.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 针对报错对"role"做存在性检查 --- pkg/platform/sources/aiocqhttp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/platform/sources/aiocqhttp.py b/pkg/platform/sources/aiocqhttp.py index ebdd56e5..bd1b0677 100644 --- a/pkg/platform/sources/aiocqhttp.py +++ b/pkg/platform/sources/aiocqhttp.py @@ -173,10 +173,11 @@ def target2yiri(event: aiocqhttp.Event): if event.message_type == "group": permission = "MEMBER" - if event.sender["role"] == "admin": - permission = "ADMINISTRATOR" - elif event.sender["role"] == "owner": - permission = "OWNER" + if "role" in event.sender: + if event.sender["role"] == "admin": + permission = "ADMINISTRATOR" + elif event.sender["role"] == "owner": + permission = "OWNER" converted_event = mirai.GroupMessage( sender=mirai.models.entities.GroupMember( id=event.sender["user_id"], # message_seq 放哪?