feat(onebot): expose extended account profile information

Add account identifiers, compatible level names, available registration and membership details, and documented account age for group members. Keep unavailable values absent and refresh the action documentation.

Fixes #496
This commit is contained in:
DrSmoothl committed 2026-10-04 13:04:42 +08:00
1 parent b69108e1cc
commit 3068d3ef60
11 files changed
+243 -8

No files matched your search

@@ -467,6 +467,24 @@ describe('onebot/contact-actions / getGroupMemberList', () => {
});
describe('onebot/contact-actions / getGroupMemberInfo', () => {
it('includes account level and completed account years without changing group level', async () => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2026-10-04T00:00:00Z'));
try {
const profile = { ...makeProfile(88, 'member'), level: 64, regTime: Date.parse('2016-10-05T00:00:00Z') / 1000 };
const fetchUserProfile = vi.fn(async () => profile);
const bridge = fakeBridge({
fetchUserProfile,
identity: fakeIdentity({ findGroupMember: () => makeMember(88, 'member') }),
});
expect(await getGroupMemberInfo(bridge, 1400, 88)).toMatchObject({ level: '1', qq_level: 64, qage: 9 });
vi.setSystemTime(new Date('2026-10-05T00:00:00Z'));
expect(await getGroupMemberInfo(bridge, 1400, 88)).toMatchObject({ qage: 10 });
} finally {
vi.useRealTimers();
}
});
it('returns the cached member when present and noCache is false', async () => {
const member = makeMember(44, 'dave', 'D');
const bridge = fakeBridge({
@@ -581,6 +599,27 @@ describe('onebot/contact-actions / getGroupMemberInfo', () => {
});
describe('onebot/contact-actions / getStrangerInfo', () => {
it('exposes available compatibility fields without fabricating login days', async () => {
const bridge = fakeBridge({ fetchUserProfile: vi.fn(async () => ({
...makeProfile(55555, 'member'), qid: 'my_qid', level: 64, regTime: 1_200_000_000,
svipFlag: true, yearVipFlag: false, vipLevel: 7,
})) });
const out = await getStrangerInfo(bridge, 55555);
expect(out).toMatchObject({
uid: 'u_55555', qid: 'my_qid', qq_level: 64, qqLevel: 64, level: 64,
reg_time: 1_200_000_000, is_vip: true, is_years_vip: false, vip_level: 7,
});
expect(out).not.toHaveProperty('login_days');
});
it('omits unavailable registration and membership values', async () => {
const bridge = fakeBridge({ fetchUserProfile: vi.fn(async () => makeProfile(55555, 'member')) });
const out = await getStrangerInfo(bridge, 55555);
for (const field of ['reg_time', 'is_vip', 'is_years_vip', 'vip_level']) {
expect(out).not.toHaveProperty(field);
}
});
it('returns a fetched profile', async () => {
const bridge = fakeBridge({
fetchUserProfile: vi.fn(async () => makeProfile(
@@ -810,6 +810,7 @@ describe('buildApiContext contact reads', () => {
uin: 20002,
uid: 'u_20002',
nickname: 'stranger',
qid: 'qid_20002',
remark: 'r',
sex: 'female',
age: 21,
@@ -822,12 +823,15 @@ describe('buildApiContext contact reads', () => {
await expect(api.getStrangerInfo(20002)).resolves.toEqual({
user_id: 20002,
uid: 'u_20002',
qid: 'qid_20002',
nickname: 'stranger',
remark: 'r',
sex: 'female',
age: 21,
long_nick: 'hello sign',
qq_level: 17,
qqLevel: 17,
level: 17,
status: 0,
extStatus: 0,