Feat: 发送图文ark卡片 (#355)

* feat(onebot): implement send tuwen ark

* test: add unit tests for send_ark action

* test(onebot): update canonical action docs count expectation to 191

* refactor(protocol,onebot): update 0xdc2_34 ark implementation and test coverage

- Rename action send_ark -> send_tuwen_ark to distinguish from structmsg and contact-share arks.
- Clarify SSO command mapping (OidbSvcTrpcTcp.0xdc2_34) and default param behavior in comments/docs.
- Adjust peerType, field3, and previewUrl to pb_optional to preserve 0/empty values during proton encoding.
- Update OneBot handler, tests, and auto-generated MCP tool catalog specs.

* style(protocol): fix indentation in rich-body-decoder tests
This commit is contained in:
H3CoF6 authored and GitHub committed 2026-08-20 12:12:39 +08:00
1 parent 62256ee816
commit 8fbddf67bf
11 files changed
+734 -137

No files matched your search

@@ -0,0 +1,67 @@
// 0xdc2_34 — send a custom 图文 (URL-share) ark card to a C2C peer or group.
// RE'd from QQ Android 9.3.25 captures. Default SSO: OidbSvcTrpcTcp.0xdc2_34.
// Fixed fields: appId = 100446242, field2 = 1, field3 = 0, field5 = {1:1}
// targetId appears at AppInfo[11] and Meta[2]; Meta.peerType: 0=C2C, 1=group.
// peerType, field3, and previewUrl are pb_optional — proton preserves 0/empty on wire.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
Oidb0xdc2_34Req,
Oidb0xdc2_34Resp,
} from '@snowluma/proto-defs/oidb-actions/contact-ark';
import { invokeOidb, type OidbSender } from '../../oidb-service';
const TUWEN_ARK_APPID = 100446242;
export type SendTuwenArkParams = {
targetId: number;
peerType: 0 | 1;
title: string;
desc: string;
summary: string;
jumpUrl: string;
previewUrl: string;
};
export namespace SendTuwenArk {
export const command = 0xDC2;
export const subCommand = 34;
export const uinForm = false;
export type Params = SendTuwenArkParams;
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): Oidb0xdc2_34Req => ({
appInfo: {
appId: TUWEN_ARK_APPID,
field2: 1,
field3: 0,
field5: { field1: 1 },
targetId: p.targetId,
content: {
flag: 1,
title: p.title,
desc: p.desc,
summary: p.summary,
jumpUrl: p.jumpUrl,
previewUrl: p.previewUrl,
},
},
meta: {
peerType: p.peerType,
targetId: p.targetId,
},
});
export const deserialize = (_ctx: Deps, _body: Oidb0xdc2_34Resp): void => undefined;
export const encode = (env: OidbBase<Oidb0xdc2_34Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0xdc2_34Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0xdc2_34Resp> =>
protobuf_decode<OidbBase<Oidb0xdc2_34Resp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SendTuwenArk, params);
}