feat(onebot): expose group-wide mute status

Report whether group-wide mute is enabled through the existing group list and group information responses.

Keep standard and extended queries aligned, support explicit refreshes in the SDK, and update the generated action documentation without adding another endpoint.

Preserve established compatibility values, isolate cached non-member results by account, and add coverage across the request, mapping, action, and client layers.

Closes #313
This commit is contained in:
DrSmoothl committed 2026-08-04 23:27:58 +08:00
1 parent c6619fda0a
commit 634097460c
18 files changed
+687 -56

No files matched your search

@@ -293,6 +293,7 @@ export class ContactsApi {
// is not in the list (0x88D_0 detail only), so it stays undefined here.
createTime: raw.info?.createdTime ?? 0,
memo: raw.info?.announcement || raw.info?.description || '',
allMuted: (raw.info?.shutUpAllTimestamp ?? 0) > 0,
});
}
this.ctx.identity.rememberGroups(groups);
@@ -323,6 +324,7 @@ export class ContactsApi {
createTime: Number(r.createTime ?? 0n),
level: Number(r.level ?? 0n),
memo: r.noticePreview ?? '',
allMuted: (r.shutUpAllTimestamp ?? 0) > 0,
};
}
+41 -1
View File
@@ -7,6 +7,7 @@ import type {
OidbFriend,
OidbFriendCategory,
OidbRobotUinRangeResponse,
OidbSvcTrpcTcp0x88D_0Response,
OidbSvcTrpcTcp0xFD4_1Response,
OidbSvcTrpcTcp0xFE5_2Response,
OidbSvcTrpcTcp0xFE7_3Response,
@@ -99,6 +100,18 @@ function groupListPacket(body: OidbSvcTrpcTcp0xFE5_2Response): SendPacketResult
};
}
function groupDetailPacket(body: OidbSvcTrpcTcp0x88D_0Response): SendPacketResult {
return {
success: true,
gotResponse: true,
errorCode: 0,
errorMessage: '',
responseData: Buffer.from(
protobuf_encode<OidbBase<OidbSvcTrpcTcp0x88D_0Response>>({ body }),
),
};
}
function apiForPages(pages: OidbSvcTrpcTcp0xFD4_1Response[]) {
let index = 0;
const sendRawPacket = vi.fn(async (
@@ -150,7 +163,12 @@ describe('apis/contacts / group roster', () => {
const sendRawPacket = vi.fn(async () => groupListPacket({
groups: [{
groupUin: 123456789,
info: { groupName: 'Project', memberCount: 42, memberMax: 500 },
info: {
groupName: 'Project',
memberCount: 42,
memberMax: 500,
shutUpAllTimestamp: 4_294_967_295,
},
customInfo: { remark: ' My Project ' },
}],
}));
@@ -167,9 +185,31 @@ describe('apis/contacts / group roster', () => {
remark: ' My Project ',
memberCount: 42,
memberMax: 500,
allMuted: true,
})]);
expect(rememberGroups).toHaveBeenCalledWith(groups);
});
it('maps the group-wide mute timestamp from a single-group detail', async () => {
const sendRawPacket = vi.fn(async () => groupDetailPacket({
groupInfo: {
uin: 123456789n,
results: {
name: 'Muted Group',
shutUpAllTimestamp: 4_294_967_295,
},
},
}));
const api = new ContactsApi({ sendRawPacket, identity: {} } as any);
const detail = await api.fetchGroupDetail(123456789);
expect(detail).toEqual(expect.objectContaining({
groupId: 123456789,
groupName: 'Muted Group',
allMuted: true,
}));
});
});
describe('apis/contacts / categorized friend roster', () => {