修复群消息被MaiBot归类为私聊的会话结构歧义
变更项:\n1. 调整 outbound APIMessage 构建逻辑:群聊场景下 receiver_info 仅保留 group_info,不再携带 receiver_info.user_info。\n2. 保留 sender_info.user_info 作为发言人身份来源,避免丢失‘是谁说的’上下文。\n3. 通过结构去歧义,避免下游服务将群消息优先按用户私聊会话归档。\n4. 增补详细中文注释,明确该约束的原因与协议意图。
This commit is contained in:
@@ -533,15 +533,11 @@ class MaiBotAdapterPlugin(MessagePluginInterface):
|
||||
"group_id": roomid,
|
||||
"group_name": group_name,
|
||||
}
|
||||
# 群聊里额外把 user_info 也带上,目的是给 MaiBot 提供“当前这句话到底是谁说的”:
|
||||
# 1. sender_info 是纯发送者视角;
|
||||
# 2. receiver_info.group_info 是群路由视角;
|
||||
# 3. receiver_info.user_info 则能帮助服务端在需要时直接知道“被路由回群时应 @ 谁”。
|
||||
receiver_info["user_info"] = {
|
||||
"platform": self._platform_name,
|
||||
"user_id": sender,
|
||||
"user_nickname": sender_name,
|
||||
}
|
||||
# 群聊场景只保留 group_info,不再混入 receiver.user_info:
|
||||
# 1. sender 身份已经通过 sender_info.user_info 完整表达;
|
||||
# 2. 若群聊再附带 receiver.user_info,部分下游会优先按“用户会话”归类;
|
||||
# 3. 这正是你目前看到“群消息被显示成私聊”的高概率根因。
|
||||
# 4. 因此这里明确约束:群聊 receiver 只承载群维度路由信息。
|
||||
else:
|
||||
receiver_info["user_info"] = {
|
||||
"platform": self._platform_name,
|
||||
|
||||
Reference in New Issue
Block a user