feat(onebot): TierB ③ — RE'd OIDB actions (ark share / doubt friends / robot-add)
All recovered from QQNT wrapper.linux.node via IDA — NapCat ships these as
kernel-only with no portable packet wire, so each cmd + protobuf was traced
from the binary (worker ctor cmd/subcmd via BaseOidbWorker::DoSendOidbReq;
field tags from the per-feature EncodeRequest). All uin-form OIDB (envelope
reserved=1, matching the NT worker flag=1). One commit for easy rollback.
New OIDB services + byte-oracle tests (fixed-wire, mutation-resistant):
- 0x9130_0 getBuddyRecommendContactArkJson → share_peer/send_ark_share (user)
- 0x8b7_5 getGroupRecommendContactArkJson → share_peer/send_ark_share (group),
share_group_ex/send_group_ark_share (NapCat's getArkJsonGroupShare
was NOT RE'd; routed to this confident equivalent — documented)
- 0xd69_0 getDoubtBuddyReq → get_doubt_friends_add_request
- 0xd69_0 approvalDoubtBuddyReq → set_doubt_friends_add_request (approve only)
- 0xf00_3 modifyGroupExtInfoV2 → set_group_robot_add_option (EXTInfo tags
30/31; GroupExtFilter is client-side gating, not on the wire)
NOT shipped (kernel-.so-side, no static cmd recoverable from this binary —
honest, no guessed packets): get_robot_uin_range (trpc method-routed),
create_collection/get_collection_list (Weiyun multi-step), trans_group_file.
Doubt-list string field NAMES (nick/source/msg) are medium-confidence
(generic serializer); uid+reqTime are high. READ path, so a mislabel is
cosmetic, never a wire/ban risk. Wired through bridge friend/contacts/
groupAdmin apis; proto-defs + per-file subpath exports registered.
This commit is contained in:
21 files changed
+931
No files matched your search
@@ -978,6 +978,155 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
|
||||
// ─── TierB ③: RE'd OIDB-backed actions (self-constructed packets) ───
|
||||
// Recovered from QQNT wrapper.linux.node via IDA (no NapCat packet wire
|
||||
// existed to port). All low-frequency/benign ops. See each OIDB service
|
||||
// file for the cmd + protobuf provenance.
|
||||
|
||||
// share_peer / send_ark_share — get a "recommend contact" Ark card for a
|
||||
// friend (0x9130_0) or group (0x8b7_5). NapCat's SharePeerBase routes by
|
||||
// which id is present; we mirror that. Returns the server-built ark JSON.
|
||||
defineAction({
|
||||
name: 'share_peer',
|
||||
summary: '分享用户/群 Ark 卡片',
|
||||
readOnly: true,
|
||||
params: {
|
||||
user_id: f.uint().optional(),
|
||||
group_id: f.uint().optional(),
|
||||
phone_number: f.string().default(''),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
try {
|
||||
if (p.group_id) {
|
||||
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id) });
|
||||
}
|
||||
if (p.user_id) {
|
||||
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getBuddyRecommendArk(p.user_id, p.phone_number) });
|
||||
}
|
||||
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
},
|
||||
}),
|
||||
defineAction({
|
||||
name: 'send_ark_share',
|
||||
summary: '分享用户/群 Ark 卡片(NapCat 标准名)',
|
||||
readOnly: true,
|
||||
params: {
|
||||
user_id: f.uint().optional(),
|
||||
group_id: f.uint().optional(),
|
||||
phone_number: f.string().default(''),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
try {
|
||||
if (p.group_id) {
|
||||
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id) });
|
||||
}
|
||||
if (p.user_id) {
|
||||
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getBuddyRecommendArk(p.user_id, p.phone_number) });
|
||||
}
|
||||
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
// 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
|
||||
// confident equivalent. The card may differ slightly from NapCat's.
|
||||
defineAction({
|
||||
name: 'share_group_ex',
|
||||
summary: '分享群 Ark 卡片',
|
||||
readOnly: true,
|
||||
params: { group_id: f.uint() },
|
||||
run: async (p, ctx) => {
|
||||
try {
|
||||
return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id));
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
},
|
||||
}),
|
||||
defineAction({
|
||||
name: 'send_group_ark_share',
|
||||
summary: '分享群 Ark 卡片(NapCat 标准名)',
|
||||
readOnly: true,
|
||||
params: { group_id: f.uint() },
|
||||
run: async (p, ctx) => {
|
||||
try {
|
||||
return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id));
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
// get_doubt_friends_add_request — list 可能认识的人 / 被过滤好友申请 (0xd69_0).
|
||||
// The list item's `uid` is what set_doubt_friends_add_request takes as flag.
|
||||
defineAction({
|
||||
name: 'get_doubt_friends_add_request',
|
||||
summary: '获取可疑好友申请',
|
||||
readOnly: true,
|
||||
params: { count: f.int({ min: 0 }).default(50) },
|
||||
run: async (p, ctx) => {
|
||||
try {
|
||||
const list = await ctx.bridge.apis.friend.getDoubtRequests(p.count);
|
||||
return okResponse(list);
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
},
|
||||
}),
|
||||
// set_doubt_friends_add_request — approve a 可疑好友申请 (0xd69_0). `flag` is
|
||||
// the uid from the get list. NapCat only supports approve (no reject path).
|
||||
defineAction({
|
||||
name: 'set_doubt_friends_add_request',
|
||||
summary: '处理可疑好友申请',
|
||||
params: {
|
||||
flag: f.string({ allowEmpty: false }),
|
||||
approve: f.bool().default(true),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
// Only approve is RE'd (reject would be a separate delDoubtBuddyReq cmd
|
||||
// we haven't recovered). Reject explicitly rather than silently approve
|
||||
// — accepting approve:false then approving anyway would be the opposite
|
||||
// of the caller's intent.
|
||||
if (!p.approve) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, 'rejecting a doubt request (delDoubtBuddyReq) is not implemented');
|
||||
}
|
||||
try {
|
||||
await ctx.bridge.apis.friend.approveDoubtRequest(p.flag);
|
||||
return okResponse();
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
// set_group_robot_add_option — group robot-add switch/examine via group
|
||||
// ext-info (0xf00_3). Omitted params leave the field unchanged.
|
||||
groupAction({
|
||||
name: 'set_group_robot_add_option',
|
||||
summary: '设置群机器人加群选项',
|
||||
run: async (p, ctx) => {
|
||||
try {
|
||||
await ctx.bridge.apis.groupAdmin.setRobotAddOption(
|
||||
p.group_id, p.robot_member_switch, p.robot_member_examine,
|
||||
);
|
||||
return okResponse();
|
||||
} catch (e) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
},
|
||||
params: {
|
||||
robot_member_switch: f.int({ min: 0 }).optional(),
|
||||
robot_member_examine: f.int({ min: 0 }).optional(),
|
||||
},
|
||||
}),
|
||||
|
||||
defineAction({
|
||||
name: 'get_collection_list',
|
||||
summary: '获取收藏列表(占位)',
|
||||
|
||||
@@ -884,3 +884,78 @@ describe('extended-actions / get_recent_contact stub', () => {
|
||||
expect(res).toMatchObject({ status: 'ok', data: [] });
|
||||
});
|
||||
});
|
||||
|
||||
// ─── TierB ③: RE'd OIDB-backed actions (wiring through handle) ───
|
||||
describe('extended-actions / TierB ③ share + doubt + robot-option', () => {
|
||||
it('share_peer with user_id calls getBuddyRecommendArk and wraps the ark', async () => {
|
||||
const getBuddyRecommendArk = vi.fn(async () => '{"app":"x"}');
|
||||
const bridge = fakeBridge({ apis: { contacts: { getBuddyRecommendArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('share_peer', { user_id: 10000 });
|
||||
expect(getBuddyRecommendArk).toHaveBeenCalledWith(10000, '');
|
||||
expect(res).toMatchObject({ status: 'ok', data: { arkMsg: '{"app":"x"}' } });
|
||||
});
|
||||
|
||||
it('share_peer with group_id calls getGroupRecommendArk', async () => {
|
||||
const getGroupRecommendArk = vi.fn(async () => '{"app":"g"}');
|
||||
const bridge = fakeBridge({ apis: { contacts: { getGroupRecommendArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('share_peer', { group_id: 555 });
|
||||
expect(getGroupRecommendArk).toHaveBeenCalledWith(555);
|
||||
expect(res).toMatchObject({ status: 'ok', data: { arkMsg: '{"app":"g"}' } });
|
||||
});
|
||||
|
||||
it('share_peer with neither id fails', async () => {
|
||||
const res = await makeHandler(fakeCtx(fakeBridge())).handle('share_peer', {});
|
||||
expect(res.status).toBe('failed');
|
||||
});
|
||||
|
||||
it('send_ark_share shares the buddy/group routing', async () => {
|
||||
const getBuddyRecommendArk = vi.fn(async () => 'ARK');
|
||||
const bridge = fakeBridge({ apis: { contacts: { getBuddyRecommendArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('send_ark_share', { user_id: 1, phone_number: '99' });
|
||||
expect(getBuddyRecommendArk).toHaveBeenCalledWith(1, '99');
|
||||
expect(res).toMatchObject({ status: 'ok', data: { arkMsg: 'ARK' } });
|
||||
});
|
||||
|
||||
it('share_group_ex / send_group_ark_share return the group ark string', async () => {
|
||||
const getGroupRecommendArk = vi.fn(async () => 'GROUP_ARK');
|
||||
const bridge = fakeBridge({ apis: { contacts: { getGroupRecommendArk } } });
|
||||
for (const name of ['share_group_ex', 'send_group_ark_share']) {
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle(name, { group_id: 42 });
|
||||
expect(res).toMatchObject({ status: 'ok', data: 'GROUP_ARK' });
|
||||
}
|
||||
expect(getGroupRecommendArk).toHaveBeenCalledWith(42);
|
||||
});
|
||||
|
||||
it('get_doubt_friends_add_request returns the mapped list', async () => {
|
||||
const list = [{ uid: 'u1', nick: 'A', source: 's', msg: 'm', reqTime: 123 }];
|
||||
const getDoubtRequests = vi.fn(async () => list);
|
||||
const bridge = fakeBridge({ apis: { friend: { getDoubtRequests } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('get_doubt_friends_add_request', { count: 5 });
|
||||
expect(getDoubtRequests).toHaveBeenCalledWith(5);
|
||||
expect(res).toMatchObject({ status: 'ok', data: list });
|
||||
});
|
||||
|
||||
it('set_doubt_friends_add_request approves by flag (uid)', async () => {
|
||||
const approveDoubtRequest = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { friend: { approveDoubtRequest } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('set_doubt_friends_add_request', { flag: 'u_abc', approve: true });
|
||||
expect(approveDoubtRequest).toHaveBeenCalledWith('u_abc');
|
||||
expect(res).toMatchObject({ status: 'ok' });
|
||||
});
|
||||
|
||||
it('set_doubt_friends_add_request rejects approve:false instead of silently approving', async () => {
|
||||
const approveDoubtRequest = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { friend: { approveDoubtRequest } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('set_doubt_friends_add_request', { flag: 'u_abc', approve: false });
|
||||
expect(res.status).toBe('failed');
|
||||
expect(approveDoubtRequest).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('set_group_robot_add_option forwards group + switch/examine', async () => {
|
||||
const setRobotAddOption = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { groupAdmin: { setRobotAddOption } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('set_group_robot_add_option', { group_id: 12345, robot_member_switch: 1, robot_member_examine: 2 });
|
||||
expect(setRobotAddOption).toHaveBeenCalledWith(12345, 1, 2);
|
||||
expect(res).toMatchObject({ status: 'ok' });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user