fix(image): use Chinese summary defaults to match QQ ecosystem
Mobile QQ, Lagrange.Core, and NapCat all use the literal Chinese
bubble-preview strings `[图片]` / `[动画表情]`. SnowLuma was emitting
English `[image]` / `[sticker]` as fallback, so QQ clients showed
"[image]" in chat-list previews instead of the expected Chinese.
Cross-checked against:
dev/NapCatQQ/.../packet/message/element.ts:367-371
dev/Lagrange.Core/.../Message/Entity/ImageEntity.cs:186-192
Both branch the same way: subType=1 → `[动画表情]`, else → `[图片]`.
Changes:
- `bridge/highway/image-upload.ts`: both code paths (fingerprint +
load-from-source) now emit the Chinese defaults. Subtype branch
flipped to `subType === 1 ? '[动画表情]' : '[图片]'` to match the
upstream convention (our old check was `subType === 0` →
`[image]`, which would label any non-zero subType — not just
stickers — as `[sticker]`).
- `bridge/msg-push/rich-body-decoder.ts`: all three decode paths
(NotOnlineImage / CustomFace / commonElem image) now substitute
the Chinese default when the server omits `textSummary`. Empty-
string is also treated as missing (matches NapCat's `=== ''`).
- Tests updated to assert the Chinese defaults; new test pins
that a caller-supplied summary still overrides verdef.
The OneBot caller's `summary` field on the MessageElement still
wins when set, so downstream clients passing custom bubble text
(e.g. for accessibility) keep working.
This commit is contained in:
3 files changed
+34
-10
No files matched your search
@@ -46,7 +46,14 @@ function imageDataFromFingerprint(element: MessageElement): ImageData {
|
||||
sha1Hex: element.sha1Hex ?? '',
|
||||
fileName: element.fileName || `${element.md5Hex ?? 'image'}.jpg`,
|
||||
fileSize: element.fileSize ?? 0,
|
||||
summary: element.summary || (element.subType === 0 ? '[image]' : '[sticker]'),
|
||||
// QQ ecosystem convention — mobile QQ + Lagrange.Core + NapCat all
|
||||
// surface these exact Chinese strings as the chat-list bubble
|
||||
// preview text. English fallbacks would render `[image]` /
|
||||
// `[sticker]` in QQ users' chat lists instead of the expected
|
||||
// `[图片]` / `[动画表情]`. Cross-checked against:
|
||||
// dev/NapCatQQ/.../packet/message/element.ts:367-371
|
||||
// dev/Lagrange.Core/.../Message/Entity/ImageEntity.cs:186-192
|
||||
summary: element.summary || (element.subType === 1 ? '[动画表情]' : '[图片]'),
|
||||
subType: element.subType ?? 0,
|
||||
width: element.width ?? 0,
|
||||
height: element.height ?? 0,
|
||||
@@ -89,7 +96,7 @@ async function loadImageFromSource(source: string, fileName: string, subType: nu
|
||||
sha1Hex: hashes.sha1Hex,
|
||||
fileName: finalName,
|
||||
fileSize: loaded.bytes.length,
|
||||
summary: summary || (subType === 0 ? '[image]' : '[sticker]'),
|
||||
summary: summary || (subType === 1 ? '[动画表情]' : '[图片]'),
|
||||
subType,
|
||||
width: fmt.width,
|
||||
height: fmt.height,
|
||||
|
||||
@@ -97,7 +97,11 @@ function convertElements(elems: ElemDecoded[]): MessageElement[] {
|
||||
width: img.picWidth ?? 0,
|
||||
height: img.picHeight ?? 0,
|
||||
subType: img.pbRes?.subType ?? 0,
|
||||
summary: img.pbRes?.summary ?? '[image]',
|
||||
// `[图片]` / `[动画表情]` are the QQ-ecosystem default
|
||||
// bubble texts; mobile QQ + Lagrange.Core + NapCat all
|
||||
// expect these literal Chinese strings when the wire
|
||||
// doesn't carry a per-image override.
|
||||
summary: img.pbRes?.summary || (img.pbRes?.subType === 1 ? '[动画表情]' : '[图片]'),
|
||||
md5Hex: toHexUpper(img.picMd5),
|
||||
});
|
||||
}
|
||||
@@ -115,7 +119,7 @@ function convertElements(elems: ElemDecoded[]): MessageElement[] {
|
||||
width: img.width ?? 0,
|
||||
height: img.height ?? 0,
|
||||
subType: img.pbRes?.subType ?? 0,
|
||||
summary: img.pbRes?.summary ?? '[image]',
|
||||
summary: img.pbRes?.summary || (img.pbRes?.subType === 1 ? '[动画表情]' : '[图片]'),
|
||||
md5Hex: toHexUpper(img.md5),
|
||||
});
|
||||
}
|
||||
@@ -311,7 +315,8 @@ function convertElements(elems: ElemDecoded[]): MessageElement[] {
|
||||
if (fi.type?.picFormat) me.picFormat = fi.type.picFormat;
|
||||
if (info.extBizInfo?.pic) {
|
||||
me.subType = info.extBizInfo.pic.bizType ?? 0;
|
||||
me.summary = info.extBizInfo.pic.textSummary || '[image]';
|
||||
me.summary = info.extBizInfo.pic.textSummary
|
||||
|| (me.subType === 1 ? '[动画表情]' : '[图片]');
|
||||
}
|
||||
result.push(me);
|
||||
} else if (bizType === 12 || bizType === 22) {
|
||||
|
||||
Reference in new issue
Block a user