From 2c47abea95b2166754fdbab38209ebb70ec7404c Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 16 Jun 2025 23:36:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20WeChatPadPro=20?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E5=BC=80=E5=90=AF=E4=BA=86=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E9=9A=94=E7=A6=BB=E5=90=8E=EF=BC=8C=E6=97=A0=E6=B3=95=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=BE=A4=E8=81=8A=E6=B6=88=E6=81=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes: #1766 --- .../platform/sources/wechatpadpro/wechatpadpro_adapter.py | 7 +++++-- .../sources/wechatpadpro/wechatpadpro_message_event.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py index 7746ba889..58e3c9b19 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py @@ -505,7 +505,7 @@ class WeChatPadProAdapter(Platform): # 对于群聊,session_id 可以是群聊 ID 或发送者 ID + 群聊 ID (如果 unique_session 为 True) if self.unique_session: - abm.session_id = f"{from_user_name}_{abm.sender.user_id}" + abm.session_id = f"{from_user_name}#{abm.sender.user_id}" else: abm.session_id = from_user_name @@ -832,7 +832,10 @@ class WeChatPadProAdapter(Platform): # 根据 session_id 判断消息类型 if "@chatroom" in session.session_id: dummy_message_obj.type = MessageType.GROUP_MESSAGE - dummy_message_obj.group_id = session.session_id + if "#" in session.session_id: + dummy_message_obj.group_id = session.session_id.split("#")[0] + else: + dummy_message_obj.group_id = session.session_id dummy_message_obj.sender = MessageMember(user_id="", nickname="") else: dummy_message_obj.type = MessageType.FRIEND_MESSAGE diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py index ab836ad28..3bb753dd4 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py @@ -81,12 +81,16 @@ class WeChatPadProMessageEvent(AstrMessageEvent): # logger.info(f"已添加 @ 信息: {message_text}") else: message_text = text + if self.get_group_id() and "#" in self.session_id: + session_id = self.session_id.split("#")[0] + else: + session_id = self.session_id payload = { "MsgItem": [ { "MsgType": 1, "TextContent": message_text, - "ToUserName": self.session_id, + "ToUserName": session_id, } ] }