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
@@ -453,9 +453,23 @@ describe('convertEvent — message elements (13 segment types)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('mface: text + tab_id + sub_type', async () => {
|
||||
const seg = await segment({ type: 'mface', text: 'sticker', faceId: 7, subType: 2 });
|
||||
expect(seg).toEqual({ type: 'mface', data: { name: 'sticker', tab_id: 7, sub_type: 2 } });
|
||||
it('mface: unified to an image segment carrying market-face markers', async () => {
|
||||
const emojiId = '235a82d9c0acd2e2db6e0b94e1a1c4f3';
|
||||
const seg = await segment({
|
||||
type: 'mface', text: '可爱', emojiId, emojiPackageId: 12, emojiKey: 'abc',
|
||||
});
|
||||
expect(seg).toEqual({
|
||||
type: 'image',
|
||||
data: {
|
||||
file: `23-${emojiId}.gif`,
|
||||
url: `https://gxh.vip.qq.com/club/item/parcel/item/23/${emojiId}/raw300.gif`,
|
||||
summary: '可爱',
|
||||
sub_type: 0,
|
||||
emoji_id: emojiId,
|
||||
emoji_package_id: 12,
|
||||
key: 'abc',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('poke: subType forwarded as data.type', async () => {
|
||||
|
||||
Reference in new issue
Block a user