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

+49
View File
@@ -1739,6 +1739,55 @@ export const actions = [
},
}),
// send_tuwen_ark — send a custom 图文 (URL-share) ark card to a C2C peer or group (0xdc2_34).
// targetId at AppInfo[11] and Meta[2]; Meta.peerType: 0=C2C, 1=group.
// 与 send_ark_share 的区别:send_ark_share 只获取推荐联系人 JSON 不发送;
// 与 send_msg share/json 的区别:后者发送 structmsg 图文卡且有 message_id,
// 本 action 发送固定图文 ark 模板,返回 null(无法用于撤回/设精华)。
defineAction({
name: 'send_tuwen_ark',
summary: '发送图文 Ark 卡片(私聊/群聊)',
readOnly: false,
returns: 'null',
returnsSchema: { type: 'null' },
params: {
user_id: f.userId().optional(),
group_id: f.groupId().optional(),
title: f.string(),
desc: f.string(),
summary: f.string().default('[分享]'),
preview_url: f.string().default('https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png'),
jump_url: f.string(),
},
run: async (p, ctx) => {
if (p.group_id) {
await ctx.bridge.apis.contacts.sendTuwenArk({
targetId: p.group_id,
peerType: 1,
title: p.title,
desc: p.desc,
summary: p.summary,
previewUrl: p.preview_url,
jumpUrl: p.jump_url,
});
return okResponse(null);
}
if (p.user_id) {
await ctx.bridge.apis.contacts.sendTuwenArk({
targetId: p.user_id,
peerType: 0,
title: p.title,
desc: p.desc,
summary: p.summary,
previewUrl: p.preview_url,
jumpUrl: p.jump_url,
});
return okResponse(null);
}
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
},
}),
// share_group_ex / send_group_ark_share — group-only Ark share. NapCat uses
// a distinct kernel API (getArkJsonGroupShare) we did NOT RE; we route to
// the fully-RE'd group recommend-contact ark (0x8b7_5), the closest