From 7c1e8ce48c0290a2238939e5607bed5ce1648974 Mon Sep 17 00:00:00 2001
From: BigFace123 <30950532+BigFace123@users.noreply.github.com>
Date: Sat, 12 Apr 2025 10:17:42 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0gewechat=E8=A2=ABat?=
=?UTF-8?q?=E4=BA=BAwxid=E8=8E=B7=E5=8F=96=EF=BC=8CAstrBotMessage=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0be=5Fat=5Fwxid=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
astrbot/core/platform/astrbot_message.py | 2 ++
astrbot/core/platform/sources/gewechat/client.py | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/astrbot/core/platform/astrbot_message.py b/astrbot/core/platform/astrbot_message.py
index e7bd4bd9c..54ed51e80 100644
--- a/astrbot/core/platform/astrbot_message.py
+++ b/astrbot/core/platform/astrbot_message.py
@@ -62,6 +62,8 @@ class AstrBotMessage:
raw_message: object
timestamp: int # 消息时间戳
+ be_at_wxid: List[str] # gewechat用的群组内at信息,用于机器人获取被at的wxid
+
def __init__(self) -> None:
self.timestamp = int(time.time())
diff --git a/astrbot/core/platform/sources/gewechat/client.py b/astrbot/core/platform/sources/gewechat/client.py
index ccecc0c71..fb1f13663 100644
--- a/astrbot/core/platform/sources/gewechat/client.py
+++ b/astrbot/core/platform/sources/gewechat/client.py
@@ -152,9 +152,13 @@ class SimpleGewechatClient:
# at
# content = content.split('\u2005')[1]
content = re.sub(r"@[^\u2005]*\u2005", "", content)
+ abm.be_at_wxid = re.findall(r')',d["MsgSource"])
+
abm.group_id = from_user_name
# at
msg_source = d["MsgSource"]
+
+
if (
f"" in msg_source
or f"" in msg_source
From 45cb1432022ad78a3625d6cd5873a2a057a38022 Mon Sep 17 00:00:00 2001
From: Soulter <905617992@qq.com>
Date: Fri, 25 Apr 2025 00:46:40 +0800
Subject: [PATCH 2/2] =?UTF-8?q?perf:=20=E5=AE=9E=E7=8E=B0=E8=A7=A3?=
=?UTF-8?q?=E6=9E=90=E5=BE=AE=E4=BF=A1=E7=BE=A4=E8=81=8A=E4=B8=8B=E5=AF=B9?=
=?UTF-8?q?=E5=85=B6=E4=BB=96=E4=BA=BA=E7=9A=84=20At?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
astrbot/core/platform/astrbot_message.py | 2 --
.../core/platform/sources/gewechat/client.py | 24 ++++++++++++-------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/astrbot/core/platform/astrbot_message.py b/astrbot/core/platform/astrbot_message.py
index 54ed51e80..e7bd4bd9c 100644
--- a/astrbot/core/platform/astrbot_message.py
+++ b/astrbot/core/platform/astrbot_message.py
@@ -62,8 +62,6 @@ class AstrBotMessage:
raw_message: object
timestamp: int # 消息时间戳
- be_at_wxid: List[str] # gewechat用的群组内at信息,用于机器人获取被at的wxid
-
def __init__(self) -> None:
self.timestamp = int(time.time())
diff --git a/astrbot/core/platform/sources/gewechat/client.py b/astrbot/core/platform/sources/gewechat/client.py
index fb1f13663..f23e1b309 100644
--- a/astrbot/core/platform/sources/gewechat/client.py
+++ b/astrbot/core/platform/sources/gewechat/client.py
@@ -143,22 +143,25 @@ class SimpleGewechatClient:
content = d["Content"]["string"] # 消息内容
at_me = False
+ at_wxids = []
if "@chatroom" in from_user_name:
abm.type = MessageType.GROUP_MESSAGE
_t = content.split(":\n")
user_id = _t[0]
content = _t[1]
+ # at
+ msg_source = d["MsgSource"]
if "\u2005" in content:
# at
# content = content.split('\u2005')[1]
content = re.sub(r"@[^\u2005]*\u2005", "", content)
- abm.be_at_wxid = re.findall(r')',d["MsgSource"])
-
- abm.group_id = from_user_name
- # at
- msg_source = d["MsgSource"]
+ at_wxids = re.findall(
+ r")",
+ msg_source,
+ )
+
+ abm.group_id = from_user_name
-
if (
f"" in msg_source
or f"" in msg_source
@@ -176,8 +179,6 @@ class SimpleGewechatClient:
return None
abm.message = []
- if at_me:
- abm.message.insert(0, At(qq=abm.self_id))
# 解析用户真实名字
user_real_name = "unknown"
@@ -203,6 +204,13 @@ class SimpleGewechatClient:
else:
user_real_name = d.get("PushContent", "unknown : ").split(" : ")[0]
+ if at_me:
+ abm.message.insert(0, At(qq=abm.self_id, name=self.nickname))
+ for wxid in at_wxids:
+ # 群聊里 At 其他人的列表
+ _username = self.userrealnames.get(abm.group_id, {}).get(wxid, wxid)
+ abm.message.append(At(qq=wxid, name=_username))
+
abm.sender = MessageMember(user_id, user_real_name)
abm.raw_message = d
abm.message_str = ""