Repository navigation
Conversation
…review and summary [Core] Parse forwarded messages without resolving contacts and keep the content carried by replies
Collaborator
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
get_forwarded_messages没有实现,拿不到合并转发里的内容。forward段里,title、preview和summary都是空的。原因
LongMsgRecvService下载转发内容后,用和普通消息相同的流程解析每条消息:MessagePacker会去好友列表或群成员列表里查找发送者。转发里的发送者通常不是 bot 的联系人,查找失败会导致整条转发解析失败。ReplyEntity.Postprocess里查找原消息。原消息一般不在 bot 能访问的会话里,同样会失败。修改
Core
MessagePacker.Parse增加isForwarded参数:GroupCard/CommonC2C.Name) 构造发送者;BotMessage增加IsForwarded。Postprocess抛出异常时只记录 warning,不再导致整条消息丢失。例如转发里的图片拿不到 url时,只影响这张图片。ReplyEntity:SourceEntities和SourceTime,保存引用里自带的内容;Postprocess。MultiMsgEntity:Title、Preview和Summary;Postprocess里递归下载,改为需要时再获取。BotContext.GetForwardedMessages(resId)。res id 本身不带场景信息,所以先按群聊请求,失败后再按私聊请求。Milky
get_forwarded_messages,返回IncomingForwardedMessage列表,并取消注释IncomingForwardedMessage。forward接收段填充title、preview和summary。reply段改用引用里自带的内容 (seq、发送者、时间和消息段)。测试
在 linux-x64 AOT 构建上,用群聊和私聊里收到的合并转发测试:
forward段的title、preview和summary与 QQ 客户端显示一致;get_forwarded_messages能返回完整内容,包括文字、图片和引用回复;forward_id可以再次通过get_forwarded_messages获取。