feat(onebot): expose friend remarks in stranger info

Return the already-decoded profile remark from fetched and cached get_stranger_info results, document its fallback shape, and regenerate the MCP action catalog.

Fixes #290
This commit is contained in:
DrSmoothl committed 2026-07-28 23:59:25 +08:00
1 parent eeaa5436fd
commit 19e3135e63
6 files changed
+38 -10

No files matched your search

+15 -3
View File
@@ -101,9 +101,10 @@ function makeProfile(
sex: 'male' | 'female' | 'unknown' = 'unknown',
age = 0,
sign = '',
remark = '',
): UserProfileInfo {
return {
uin, uid: `u_${uin}`, nickname, remark: '', qid: '', sex, age, sign, avatar: '',
uin, uid: `u_${uin}`, nickname, remark, qid: '', sex, age, sign, avatar: '',
};
}
@@ -448,7 +449,14 @@ describe('onebot/contact-actions / getGroupMemberInfo', () => {
describe('onebot/contact-actions / getStrangerInfo', () => {
it('returns a fetched profile', async () => {
const bridge = fakeBridge({
fetchUserProfile: vi.fn(async () => makeProfile(55555, 'Eve', 'female', 25, 'Stay curious')),
fetchUserProfile: vi.fn(async () => makeProfile(
55555,
'Eve',
'female',
25,
'Stay curious',
'Teammate',
)),
});
const out = await getStrangerInfo(bridge, 55555);
expect(out).toMatchObject({
@@ -456,6 +464,7 @@ describe('onebot/contact-actions / getStrangerInfo', () => {
nickname: 'Eve',
sex: 'female',
age: 25,
remark: 'Teammate',
long_nick: 'Stay curious',
});
});
@@ -465,13 +474,16 @@ describe('onebot/contact-actions / getStrangerInfo', () => {
fetchUserProfile: vi.fn(async () => { throw new Error('net'); }),
identity: fakeIdentity({
findUserProfile: (uin: number) =>
uin === 66666 ? makeProfile(66666, 'Frank', 'male', 30, 'Cached signature') : null,
uin === 66666
? makeProfile(66666, 'Frank', 'male', 30, 'Cached signature', 'Cached remark')
: null,
}),
});
const out = await getStrangerInfo(bridge, 66666);
expect(out).toMatchObject({
user_id: 66666,
nickname: 'Frank',
remark: 'Cached remark',
long_nick: 'Cached signature',
});
});
+4 -1
View File
@@ -15,6 +15,7 @@ describe('get_stranger_info action', () => {
data: {
user_id: 123456,
nickname: '',
remark: '',
sex: 'unknown',
age: 0,
long_nick: '',
@@ -22,15 +23,17 @@ describe('get_stranger_info action', () => {
});
});
it('documents long_nick as a required string response field', () => {
it('documents remark and long_nick as required string response fields', () => {
const schema = getStrangerInfo.describe().returnsSchema;
expect(schema).toMatchObject({
type: 'object',
properties: {
remark: { type: 'string', description: '好友备注;非好友或未设置时为空字符串' },
long_nick: { type: 'string', description: '个性签名' },
},
});
expect(schema?.required).toContain('remark');
expect(schema?.required).toContain('long_nick');
});
});