fix(send): resolve at-mention display name from the group roster
OneBot clients commonly send [CQ:at,qq=12345] without a name field; we were piping `@12345` into the text element so QQ rendered the bare uin instead of the member's card/nickname (napcat resolves via getGroupMember before encoding). Move the fallback into the element builder so it consults the IdentityService roster and only falls back to the uin when the roster has nothing.
This commit is contained in:
3 files changed
+41
-12
No files matched your search
@@ -105,12 +105,13 @@ async function segmentToElement(type: string, data: Record<string, unknown>, opt
|
||||
uid = (await options.resolveMentionUid(uin))?.trim() ?? '';
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'at',
|
||||
targetUin: uin,
|
||||
uid: uid || undefined,
|
||||
text: name ? `@${name} ` : `@${uin} `,
|
||||
};
|
||||
// Leave `text` undefined when the caller didn't supply a display
|
||||
// name. The element-builder then resolves it from the group roster
|
||||
// (so QQ renders `@昵称` instead of `@QQ号`).
|
||||
const element: MessageElement = { type: 'at', targetUin: uin };
|
||||
if (uid) element.uid = uid;
|
||||
if (name) element.text = `@${name} `;
|
||||
return element;
|
||||
}
|
||||
case 'reply': {
|
||||
const id = parseInt(String(data.id ?? '0'), 10);
|
||||
|
||||
Reference in new issue
Block a user