From 5aeca9662b30a246ed637062bd4acff10a042c1a Mon Sep 17 00:00:00 2001 From: anka <1350989414@qq.com> Date: Sun, 11 May 2025 22:57:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=B9aiocqhttp=E4=B8=AD,=20At?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=96=B0=E5=A2=9E=E5=A4=84=E7=90=86:=20?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8At=E5=AD=97=E6=AE=B5=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E4=B9=9F=E4=BC=9A=E8=A2=AB=E8=A7=A3=E6=9E=90=E4=B8=BA=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E4=BF=A1=E6=81=AF(=E4=BD=86=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=93=BE=E5=B9=B6=E6=B2=A1=E6=9C=89=E4=BF=AE=E6=94=B9,=20?= =?UTF-8?q?=E5=8F=AA=E6=98=AF=E5=9C=A8=E7=94=A8=E4=BA=8Ellm=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=9A=84=E6=96=87=E6=9C=AC=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86At=E4=BF=A1=E6=81=AF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiocqhttp/aiocqhttp_platform_adapter.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py index 97754f2c9..4786b996c 100644 --- a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py +++ b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py @@ -287,6 +287,31 @@ class AiocqhttpAdapter(Platform): logger.error(f"获取引用消息失败: {e}。") a = ComponentTypes[t](**m["data"]) # noqa: F405 abm.message.append(a) + elif t == "at": + for m in m_group: + try: + at_info = await self.bot.call_action( + action="get_stranger_info", + user_id=int(m["data"]["qq"]), + ) + if at_info: + nickname = at_info.get("nick", "") + abm.message.append( + At( + qq=m["data"]["qq"], + name=nickname, + ) + ) + # 兼容文本消息 + message_str += f"@{nickname} " + else: + abm.message.append( + At(qq=m["data"]["qq"], name="") + ) # noqa: F405 + except ActionFailed as e: + logger.error(f"获取 @ 用户信息失败: {e},此消息段将被忽略。") + except BaseException as e: + logger.error(f"获取 @ 用户信息失败: {e},此消息段将被忽略。") else: for m in m_group: a = ComponentTypes[t](**m["data"]) # noqa: F405