feat(onebot): expose stranger profile signatures
Return the NapCat-compatible long_nick field from get_stranger_info for both freshly fetched and cached user profiles. Keep the field present as an empty string when profile data is unavailable so callers receive a stable response shape. Document the response contract in the Action schema and generated MCP catalog, and cover fetched, cached, and empty fallback paths with regression tests. This change reuses the existing profile signature value and does not add QQ requests or alter protocol packets. Closes #246
This commit is contained in:
6 files changed
+83
-15
No files matched your search
@@ -32,7 +32,7 @@ export const actions = [
|
||||
name: 'get_stranger_info',
|
||||
summary: '获取陌生人信息',
|
||||
readOnly: true,
|
||||
returns: '陌生人资料:QQ 号、昵称、性别、年龄,命中资料时另含等级。',
|
||||
returns: '陌生人资料:QQ 号、昵称、性别、年龄与个性签名,命中资料时另含等级。',
|
||||
returnsSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
@@ -40,19 +40,24 @@ export const actions = [
|
||||
nickname: { type: 'string', description: '昵称' },
|
||||
sex: { type: 'string', description: '性别(male/female/unknown)' },
|
||||
age: { type: 'integer', description: '年龄' },
|
||||
long_nick: { type: 'string', description: '个性签名' },
|
||||
qq_level: { type: 'integer', description: 'QQ 等级(仅查到资料时返回)' },
|
||||
level: { type: 'integer', description: 'QQ 等级,同 qq_level(仅查到资料时返回)' },
|
||||
},
|
||||
required: ['user_id', 'nickname', 'sex', 'age'],
|
||||
required: ['user_id', 'nickname', 'sex', 'age', 'long_nick'],
|
||||
},
|
||||
params: { user_id: f.userId().describe('QQ 号') },
|
||||
run: async (p, ctx) => {
|
||||
const userId = p.user_id;
|
||||
if (ctx.getStrangerInfo) {
|
||||
const info = await ctx.getStrangerInfo(userId);
|
||||
return okResponse(info ?? { user_id: userId, nickname: '', sex: 'unknown', age: 0 });
|
||||
return okResponse(info ?? {
|
||||
user_id: userId, nickname: '', sex: 'unknown', age: 0, long_nick: '',
|
||||
});
|
||||
}
|
||||
return okResponse({ user_id: userId, nickname: '', sex: 'unknown', age: 0 });
|
||||
return okResponse({
|
||||
user_id: userId, nickname: '', sex: 'unknown', age: 0, long_nick: '',
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -66,4 +71,3 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -225,6 +225,7 @@ export async function getStrangerInfo(
|
||||
nickname: p.nickname,
|
||||
sex: p.sex,
|
||||
age: p.age,
|
||||
long_nick: p.sign,
|
||||
qq_level: p.level,
|
||||
level: p.level,
|
||||
};
|
||||
@@ -236,6 +237,7 @@ export async function getStrangerInfo(
|
||||
nickname: p.nickname,
|
||||
sex: p.sex,
|
||||
age: p.age,
|
||||
long_nick: p.sign,
|
||||
qq_level: p.level,
|
||||
level: p.level,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user