feat(onebot): send saved custom faces with sticker presentation

Resolve saved stickers by resource ID or MD5, support group and private destinations with optional replies, and preserve presentation in upload and message metadata.

Fixes #468
This commit is contained in:
DrSmoothl committed 2026-09-26 16:19:45 +08:00
1 parent e05d3176a2
commit 0cc06b6b5e
12 files changed
+358 -31

No files matched your search

+13 -8
View File
@@ -1,4 +1,6 @@
import { createLogger } from '@snowluma/common/logger';
import { protobuf_encode } from '@snowluma/proton';
import type { NotOnlineImagePbReserve, PicExtBizInfo } from '@snowluma/proto-defs/element';
import type { BridgeContext } from '../bridge-context';
import type { MessageElement } from '../events';
import { GROUP_IMAGE_CMD_ID, PRIVATE_IMAGE_CMD_ID } from './highway-client';
@@ -117,6 +119,15 @@ export async function uploadImageMsgInfo(
): Promise<Uint8Array> {
const log = loggerFor(bridge);
const image = await loadImage(element);
const pic: PicExtBizInfo = {
bizType: image.subType,
textSummary: image.summary,
...(isGroup
? { extData: { subType: image.subType, textSummary: image.summary } }
: { bytesPbReserveC2c: protobuf_encode<NotOnlineImagePbReserve>({
subType: image.subType, summary: image.summary,
}) }),
};
log.debug('uploading %d bytes md5=%s... → %s %s',
image.fileSize,
image.md5Hex.slice(0, 8),
@@ -156,13 +167,7 @@ export async function uploadImageMsgInfo(
}],
compatQmsgSceneType: isGroup ? 2 : 1,
extBizInfo: {
pic: {
bizType: image.subType,
textSummary: image.summary,
...(isGroup
? { reserveTroop: { subType: image.subType } }
: { reserveC2c: { subType: image.subType } }),
},
pic,
video: { bytesPbReserve: new Uint8Array(0) },
ptt: {
bytesReserve: new Uint8Array(0),
@@ -174,5 +179,5 @@ export async function uploadImageMsgInfo(
label: 'image',
});
return finalizeMediaMsgInfo(upload, { bizType: image.subType, textSummary: image.summary });
return finalizeMediaMsgInfo(upload, pic);
}