From fe9eff923e3975e89fdde085c5f8fb4833c527ec Mon Sep 17 00:00:00 2001 From: Dong_master <2213070223@qq.com> Date: Mon, 17 Mar 2025 23:23:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=95=E7=94=A8=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=9B=9E=E5=A4=8D=EF=BC=88=E6=9A=82=E6=97=B6=E5=8F=AA?= =?UTF-8?q?=E6=98=AF=E5=BC=95=E7=94=A8=E6=98=AF=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=97=B6=E5=80=99=E6=9E=84=E5=BB=BAat?= =?UTF-8?q?=E5=B9=B6=E4=BC=A0=E5=85=A5=E6=B6=88=E6=81=AF=EF=BC=89=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=8F=E7=A8=8B=E5=BA=8F=EF=BC=8C=E8=BD=AC?= =?UTF-8?q?=E8=B4=A6=EF=BC=8C=E7=BA=A2=E5=8C=85=EF=BC=8C=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=8F=B7=E7=AD=89=E6=B6=88=E6=81=AF=E7=9A=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/platform/sources/gewechat.py | 76 +++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/pkg/platform/sources/gewechat.py b/pkg/platform/sources/gewechat.py index 5227a52d..a7039e95 100644 --- a/pkg/platform/sources/gewechat.py +++ b/pkg/platform/sources/gewechat.py @@ -25,6 +25,7 @@ from ..types import message as platform_message from ..types import events as platform_events from ..types import entities as platform_entities from ...utils import image +import xml.etree.ElementTree as ET class GewechatMessageConverter(adapter.MessageConverter): @@ -74,6 +75,7 @@ class GewechatMessageConverter(adapter.MessageConverter): if len(line_split) > 0 and regex.match(line_split[0]): message["Data"]["Content"]["string"] = "\n".join(line_split[1:]) + # 正则表达式模式,匹配'@'后跟任意数量的非空白字符 pattern = r'@\S+' at_string = f"@{bot_account_id}" @@ -127,17 +129,77 @@ class GewechatMessageConverter(adapter.MessageConverter): # 支持微信聊天记录的消息类型,将 XML 内容转换为 MessageChain 传递 try: content = message["Data"]["Content"]["string"] + # 有三种可能的消息结构weid开头,私聊直接和直接 + if content.startswith('wxid'): + xml_list = content.split('\n')[2:] + xml_data = '\n'.join(xml_list) + elif content.startswith('