feat(core,onebot): implement trans_group_file action (#161)

This commit is contained in:
Airline233 authored and GitHub committed 2026-07-01 02:13:35 +08:00
1 parent 2f374ea8c9
commit 9ca64bed10
11 files changed
+260 -10

No files matched your search

+9 -4
View File
@@ -1636,10 +1636,15 @@ export const actions = [
defineAction({
name: 'trans_group_file',
summary: '转存群文件(未实现)',
params: {},
run: async () => {
return failedResponse(RETCODE.ACTION_FAILED, 'not yet implemented');
summary: '转存群文件',
returns: '{ ok: true }',
params: {
group_id: f.uint(),
file_id: f.string({ allowEmpty: false }),
},
run: async (p, ctx) => {
await ctx.bridge.apis.groupFile.trans(p.group_id, p.file_id);
return okResponse({ ok: true });
},
}),
@@ -641,6 +641,31 @@ describe('extended-actions / get_group_shut_list', () => {
});
});
// ─── Wave 1: trans_group_file (0x6D9_0) ───
describe('extended-actions / trans_group_file', () => {
it('forwards group_id + file_id to apis.groupFile.trans and returns ok:true', async () => {
const trans = vi.fn(async () => ({ saveBusId: 102, saveFilePath: '/saved/path' }));
const bridge = fakeBridge({ apis: { groupFile: { trans } } });
const res = await makeHandler(fakeCtx(bridge)).handle('trans_group_file', {
group_id: 12345,
file_id: 'fid-trans',
});
expect(trans).toHaveBeenCalledWith(12345, 'fid-trans');
expect(res).toMatchObject({ status: 'ok', retcode: 0, data: { ok: true } });
});
it('rejects missing required params', async () => {
const trans = vi.fn();
const bridge = fakeBridge({ apis: { groupFile: { trans } } });
const r1 = await makeHandler(fakeCtx(bridge)).handle('trans_group_file', { file_id: 'fid' });
const r2 = await makeHandler(fakeCtx(bridge)).handle('trans_group_file', { group_id: 12345 });
expect(r1).toMatchObject({ status: 'failed', retcode: 1400 });
expect(r2).toMatchObject({ status: 'failed', retcode: 1400 });
expect(trans).not.toHaveBeenCalled();
});
});
// ─── Wave 1: get_file (compose image→record cache) ───
describe('extended-actions / get_file', () => {