Skip to content

[Core] Support receiving images from clients before NTQQ - #925

Open
ilyfairy wants to merge 1 commit into
LagrangeDev:masterfrom
ilyfairy:fix/legacy-image
Open

ilyfairy wants to merge 1 commit into
LagrangeDev:masterfrom
ilyfairy:fix/legacy-image

Conversation

@ilyfairy

@ilyfairy ilyfairy commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

问题

在群聊里收到非 NTQQ 旧客户端发送的图片时,Milky 收到的是一条没有任何消息段的空消息。

原因

旧客户端发图时只发送旧的图片元素 CustomFace,没有 NTQQ 的 CommonElem (business type 10 / 20)。
ImageEntity.Parse 只解析 CommonElem,所以这些图片被丢掉了。

修改

  • ImageEntity.Parse:消息里没有 NTQQ 图片的 CommonElem 时,解析旧的图片元素 CustomFace / NotOnlineImage。
    • NTQQ 发图时也会附带这两种元素作为兼容,所以有 CommonElem 时不解析它们,同一张图不会出现两次。
    • url 使用元素里自带的 OrigUrl:带 &fileid= 的拼在 https://multimedia.nt.qq.com.cn 后面,其他的拼在 https://gchat.qpic.cn 后面。
    • 同时填充 FileName、FileMd5、FileSize、ImageSize、SubType 和 Summary。
  • NotOnlineImage 增加 PbReserve1,用来读取 SubType 和 Summary。PbReserve 本身仍然是 byte[],所以上传时返回的兼容元素会原样发回。
  • ImageEntity.Postprocess:没有 MsgInfo 时直接返回,因为旧图片的 url 已经从元素里得到了。

解析方式与 V1 的 ImageEntity 一致。

旧图片没有 NTQQ 的资源 id,所以 Milky 的 resource_id 为空,需要使用 temp_url。

测试

在 linux-x64 构建(trimmed,非 AOT)上,在群聊里接收旧客户端发送的图片和动画表情:

  • 事件中得到 image 段,动画表情的 sub_type 是 sticker,summary 是 [动画表情];
  • temp_url 可以下载到原图,md5 与元素里的一致。

@NoirHare
NoirHare requested a review from Linwenxuan04 November 6, 2026 05:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant