From 8ece82e43a0ecc5bd8731b172325a03c1de50ad2 Mon Sep 17 00:00:00 2001 From: Dong_master <2213070223@qq.com> Date: Fri, 14 Mar 2025 02:33:52 +0800 Subject: [PATCH] =?UTF-8?q?'=E5=A2=9E=E5=8A=A0=E4=BA=86=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E5=8F=91=E9=80=81at=E4=BF=A1=E6=81=AF'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/platform/sources/gewechat.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/platform/sources/gewechat.py b/pkg/platform/sources/gewechat.py index 1de2e3ef..e73b85a8 100644 --- a/pkg/platform/sources/gewechat.py +++ b/pkg/platform/sources/gewechat.py @@ -257,11 +257,23 @@ class GeWeChatAdapter(adapter.MessagePlatformAdapter): ): geweap_msg = await self.message_converter.yiri2target(message) # 此处加上群消息at处理 - # ats = [item["target"] for item in geweap_msg if item["type"] == "at"] + ats = [item["target"] for item in geweap_msg if item["type"] == "at"] + for msg in geweap_msg: + # at主动发送消息 if msg['type'] == 'text': - self.bot.post_text(app_id=self.config['app_id'], to_wxid=target_id, content=msg['content']) + if ats: + member_info = self.bot.get_chatroom_member_detail( + self.config["app_id"], + target_id, + ats[::-1] + )["data"] + + for member in member_info: + msg['content'] = f'@{member["nickName"]} {msg["content"]}' + self.bot.post_text(app_id=self.config['app_id'], to_wxid=target_id, content=msg['content'], + ats=",".join(ats)) elif msg['type'] == 'image': @@ -296,7 +308,7 @@ class GeWeChatAdapter(adapter.MessagePlatformAdapter): app_id=self.config["app_id"], to_wxid=message_source.source_platform_object["Data"]["FromUserName"]["string"], content=msg["content"], - ats=','.join(ats) + ats=",".join(ats) ) async def is_muted(self, group_id: int) -> bool: