feat(onebot): query group todo messages

Fixes #332
This commit is contained in:
DrSmoothl committed 2026-08-09 13:36:41 +08:00
1 parent 4aba81ec6b
commit c08150fc0c
12 files changed
+1066 -11

No files matched your search

@@ -90,9 +90,9 @@ describe('compileActionRegistry namespace conflicts', () => {
});
describe('compiled production Action registry', () => {
it('preserves all 187 canonical Action docs', () => {
expect(ACTION_REGISTRY.actions).toHaveLength(187);
expect(collectActionDocs()).toHaveLength(187);
it('preserves all 190 canonical Action docs', () => {
expect(ACTION_REGISTRY.actions).toHaveLength(190);
expect(collectActionDocs()).toHaveLength(190);
});
it('resolves every executable name to exactly one canonical doc', () => {
@@ -72,6 +72,7 @@ const APIS_ROUTING: Record<string, [string, string]> = {
setGroupTodo: ['extras', 'setGroupTodo'],
completeGroupTodo: ['extras', 'completeGroupTodo'],
cancelGroupTodo: ['extras', 'cancelGroupTodo'],
getGroupTodoList: ['extras', 'getGroupTodoList'],
getStrangerStatus: ['extras', 'getStrangerStatus'],
fetchAiVoiceList: ['extras', 'fetchAiVoiceList'],
fetchAiVoice: ['extras', 'fetchAiVoice'],
@@ -1176,6 +1177,82 @@ describe('extended-actions / set_/complete_/cancel_group_todo', () => {
});
});
describe('extended-actions / get_group_todo_list', () => {
it('maps QQ identities to OneBot ids, caches metadata, and includes cached content', async () => {
const getGroupTodoList = vi.fn(async () => [{
sourceId: '5631_0',
sequence: 5631,
random: 0,
text: '测试待办',
createdAt: 1735000000,
updatedAt: 1735000001,
}]);
const bridge = fakeBridge({ getGroupTodoList });
const messageId = hashMessageIdInt32(5631, 100, GROUP_MESSAGE_EVENT);
const cacheMessageMetas = vi.fn();
const message = [{ type: 'text', data: { text: '原消息' } }];
const ctx = fakeCtx(bridge, {
cacheMessageMetas,
getMessage: (id) => id === messageId ? { message } : null,
});
const response = await makeHandler(ctx).handle('get_group_todo_list', { group_id: 100 });
expect(getGroupTodoList).toHaveBeenCalledWith(100);
expect(cacheMessageMetas).toHaveBeenCalledWith([{
messageId,
meta: {
isGroup: true,
targetId: 100,
sequence: 5631,
sequenceAuthoritative: true,
eventName: GROUP_MESSAGE_EVENT,
clientSequence: 0,
random: 0,
timestamp: 1735000000,
},
}]);
expect(response).toMatchObject({
status: 'ok',
data: [{
message_id: messageId,
message_seq: 5631,
message_random: 0,
message,
text: '测试待办',
create_time: 1735000000,
update_time: 1735000001,
}],
});
});
it('still returns a usable message id when the original body is not cached', async () => {
const bridge = fakeBridge({
getGroupTodoList: vi.fn(async () => [{
sourceId: '88_0',
sequence: 88,
random: 0,
text: '',
createdAt: 0,
updatedAt: 0,
}]),
});
const response = await makeHandler(fakeCtx(bridge)).handle(
'get_group_todo_list',
{ group_id: 100 },
);
expect(response).toMatchObject({
status: 'ok',
data: [{
message_id: hashMessageIdInt32(88, 100, GROUP_MESSAGE_EVENT),
message_seq: 88,
message: null,
}],
});
});
});
describe('extended-actions / set_group_reaction', () => {
it('rejects a local-only message id without calling the reaction protocol', async () => {
const setGroupReaction = vi.fn(async () => {});