diff --git a/packages/mcp/src/generated/catalog.json b/packages/mcp/src/generated/catalog.json index 9c16cea2..d3e98a53 100644 --- a/packages/mcp/src/generated/catalog.json +++ b/packages/mcp/src/generated/catalog.json @@ -5080,6 +5080,10 @@ "type": "integer", "description": "最后发言时间戳(秒)" }, + "shut_up_timestamp": { + "type": "integer", + "description": "禁言结束时间戳(秒,未禁言时为 0)" + }, "level": { "type": "string", "description": "群等级" @@ -5235,6 +5239,10 @@ "type": "integer", "description": "最后发言时间戳(秒)" }, + "shut_up_timestamp": { + "type": "integer", + "description": "禁言结束时间戳(秒,未禁言时为 0)" + }, "level": { "type": "string", "description": "群等级" diff --git a/packages/mcp/src/generated/catalog.ts b/packages/mcp/src/generated/catalog.ts index b4c03fd8..1825618e 100644 --- a/packages/mcp/src/generated/catalog.ts +++ b/packages/mcp/src/generated/catalog.ts @@ -5083,6 +5083,10 @@ export const ACTIONS: CatalogAction[] = [ "type": "integer", "description": "最后发言时间戳(秒)" }, + "shut_up_timestamp": { + "type": "integer", + "description": "禁言结束时间戳(秒,未禁言时为 0)" + }, "level": { "type": "string", "description": "群等级" @@ -5238,6 +5242,10 @@ export const ACTIONS: CatalogAction[] = [ "type": "integer", "description": "最后发言时间戳(秒)" }, + "shut_up_timestamp": { + "type": "integer", + "description": "禁言结束时间戳(秒,未禁言时为 0)" + }, "level": { "type": "string", "description": "群等级" diff --git a/packages/onebot/src/actions/group-info.ts b/packages/onebot/src/actions/group-info.ts index 1fea93f4..3df2324f 100644 --- a/packages/onebot/src/actions/group-info.ts +++ b/packages/onebot/src/actions/group-info.ts @@ -107,6 +107,7 @@ export const actions = [ age: { type: 'integer', description: '年龄' }, join_time: { type: 'integer', description: '入群时间戳(秒)' }, last_sent_time: { type: 'integer', description: '最后发言时间戳(秒)' }, + shut_up_timestamp: { type: 'integer', description: '禁言结束时间戳(秒,未禁言时为 0)' }, level: { type: 'string', description: '群等级' }, role: { type: 'string', enum: ['owner', 'admin', 'member'], description: '角色' }, title: { type: 'string', description: '专属头衔' }, @@ -146,6 +147,7 @@ export const actions = [ age: { type: 'integer', description: '年龄' }, join_time: { type: 'integer', description: '入群时间戳(秒)' }, last_sent_time: { type: 'integer', description: '最后发言时间戳(秒)' }, + shut_up_timestamp: { type: 'integer', description: '禁言结束时间戳(秒,未禁言时为 0)' }, level: { type: 'string', description: '群等级' }, role: { type: 'string', enum: ['owner', 'admin', 'member'], description: '角色' }, title: { type: 'string', description: '专属头衔' }, @@ -167,6 +169,7 @@ export const actions = [ group_id: groupId, user_id: userId, nickname: '', card: '', is_robot: false, sex: 'unknown', age: 0, join_time: 0, last_sent_time: 0, + shut_up_timestamp: 0, level: '0', role: 'member', title: '', }); } @@ -174,6 +177,7 @@ export const actions = [ group_id: groupId, user_id: userId, nickname: '', card: '', is_robot: false, sex: 'unknown', age: 0, join_time: 0, last_sent_time: 0, + shut_up_timestamp: 0, level: '0', role: 'member', title: '', }); }, diff --git a/packages/onebot/src/modules/contact-actions.ts b/packages/onebot/src/modules/contact-actions.ts index 88d0d89c..71625b1e 100644 --- a/packages/onebot/src/modules/contact-actions.ts +++ b/packages/onebot/src/modules/contact-actions.ts @@ -431,6 +431,7 @@ function formatGroupMember( age: 0, join_time: member.joinTime, last_sent_time: member.lastSentTime, + shut_up_timestamp: member.shutUpTime, level: String(member.level), role: member.role, title: member.title, diff --git a/packages/onebot/tests/group-info-actions.test.ts b/packages/onebot/tests/group-info-actions.test.ts index 8f6d719a..da654995 100644 --- a/packages/onebot/tests/group-info-actions.test.ts +++ b/packages/onebot/tests/group-info-actions.test.ts @@ -1,15 +1,42 @@ import { describe, expect, it, vi } from 'vitest'; +import type { GroupMemberInfo } from '@snowluma/protocol/qq-info'; import { ACTION_REGISTRY } from '../src/actions'; +import { + getGroupMemberInfo as readGroupMemberInfo, + getGroupMemberList as readGroupMemberList, +} from '../src/modules/contact-actions'; const getGroupInfo = ACTION_REGISTRY.actions.find(action => action.canonical === 'get_group_info')?.spec; const getGroupList = ACTION_REGISTRY.actions.find(action => action.canonical === 'get_group_list')?.spec; const getGroupInfoEx = ACTION_REGISTRY.actions.find(action => action.canonical === 'get_group_info_ex')?.spec; const getGroupDetailInfo = ACTION_REGISTRY.actions.find(action => action.canonical === 'get_group_detail_info')?.spec; -if (!getGroupInfo || !getGroupList || !getGroupInfoEx || !getGroupDetailInfo) { +const getGroupMemberList = ACTION_REGISTRY.actions.find(action => action.canonical === 'get_group_member_list')?.spec; +const getGroupMemberInfo = ACTION_REGISTRY.actions.find(action => action.canonical === 'get_group_member_info')?.spec; +if ( + !getGroupInfo || !getGroupList || !getGroupInfoEx || !getGroupDetailInfo + || !getGroupMemberList || !getGroupMemberInfo +) { throw new Error('group info actions missing'); } +function makeMember(overrides: Partial): GroupMemberInfo { + return { + uin: 654321, + uid: 'u_member', + nickname: 'Member', + card: '', + isRobot: false, + role: 'member', + level: 1, + title: '', + joinTime: 0, + lastSentTime: 0, + shutUpTime: 0, + ...overrides, + }; +} + describe('group information actions', () => { it('returns and documents the group-wide mute state', async () => { const response = await getGroupInfo.toHandler({} as any)({ group_id: 123456 }); @@ -44,4 +71,49 @@ describe('group information actions', () => { expect(getGroupInfoProvider).toHaveBeenCalledWith(123456, true); expect(action.describe().returnsSchema?.properties).toHaveProperty('group_all_shut'); }); + + it('returns and documents member mute expiry across member actions', async () => { + const mutedUntil = 2_000_000_000; + const member = makeMember({ nickname: 'Muted Member', shutUpTime: mutedUntil }); + const bridge = { + identity: { + uin: '123456', + findGroupMember: (groupId: number, userId: number) => + groupId === 123456 && userId === member.uin ? member : null, + }, + apis: { contacts: { fetchGroupMemberList: vi.fn(async () => [member]) } }, + } as any; + const listResponse = await getGroupMemberList.toHandler({ + getGroupMemberList: (groupId: number, noCache?: boolean) => + readGroupMemberList(bridge, groupId, noCache), + } as any)({ group_id: 123456 }); + const infoResponse = await getGroupMemberInfo.toHandler({ + getGroupMemberInfo: (groupId: number, userId: number, noCache?: boolean) => + readGroupMemberInfo(bridge, groupId, userId, noCache), + } as any)({ group_id: 123456, user_id: member.uin }); + + expect(listResponse).toMatchObject({ + status: 'ok', + data: [{ user_id: member.uin, shut_up_timestamp: mutedUntil }], + }); + expect(infoResponse).toMatchObject({ + status: 'ok', + data: { user_id: member.uin, shut_up_timestamp: mutedUntil }, + }); + expect(getGroupMemberList.describe().returnsSchema?.items?.properties) + .toHaveProperty('shut_up_timestamp'); + expect(getGroupMemberInfo.describe().returnsSchema?.properties) + .toHaveProperty('shut_up_timestamp'); + }); + + it('returns a zero mute expiry when the member is unavailable', async () => { + const response = await getGroupMemberInfo.toHandler({ + getGroupMemberInfo: vi.fn(async () => null), + } as any)({ group_id: 123456, user_id: 654323 }); + + expect(response).toMatchObject({ + status: 'ok', + data: { user_id: 654323, shut_up_timestamp: 0 }, + }); + }); });