feat(onebot): unify market faces to image segments + add send support
Market faces (商城表情) now decode to an OneBot `image` segment carrying
NapCat-style markers (emoji_id/emoji_package_id/key/summary) plus a gxh
gif URL, so clients that don't special-case `mface` still render the
sticker while aware clients can reproduce it.
Adds the previously-missing send path: a dedicated `mface` segment OR an
`image` segment carrying `emoji_id` rebuilds the wire `marketFace`
(faceId=hex(emoji_id), itemType 6 / subType 3 / 300×300 /
pbReserve.field8=1) — byte-matched against NapCat and Lagrange.Core.
- proto-defs: MarketFace.key bytes→string; +MarketFacePbReserve{field8@8}
- protocol: decode faceId→emojiId(hex)/tabId/key; makeMarketFaceElem +
buildSendElems 'mface' case; format preview keeps the sticker name
- onebot: to-segment mface→image; message-parser mface + image(emoji_id)
- tests: wire decode + full proton round-trip; parse→build; segment shape
Reply/forward round-trips preserved (element keeps type 'mface' + text).
This commit is contained in:
10 files changed
+247
-16
No files matched your search
@@ -89,7 +89,13 @@ export function formatMessageSegments(message: JsonValue): string {
|
||||
function renderSegment(type: string, data: Record<string, unknown>): string {
|
||||
switch (type) {
|
||||
case 'text': return truncate(String(data.text ?? ''), MAX_TEXT_PREVIEW);
|
||||
case 'image': return '[图片]';
|
||||
// Market faces (商城表情) are surfaced as `image` segments carrying an
|
||||
// `emoji_id` marker (+ `summary` = face name). Keep the sticker readable in
|
||||
// previews instead of collapsing it to a generic "[图片]".
|
||||
case 'image':
|
||||
return data.emoji_id
|
||||
? (data.summary ? `[${String(data.summary)}]` : '[表情]')
|
||||
: '[图片]';
|
||||
case 'face': return '[表情]';
|
||||
case 'mface': return data.text ? `[${String(data.text)}]` : '[表情]';
|
||||
case 'at': return data.qq === 'all' ? '@全体成员' : `@${data.qq ?? ''}`;
|
||||
|
||||
Reference in new issue
Block a user