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
@@ -28,12 +28,16 @@ const forwardResCache = new Map<string, ForwardNodePayload[]>();
|
||||
async function buildForwardPushBody(
|
||||
bridge: Bridge,
|
||||
node: ForwardNodePayload,
|
||||
groupId?: number,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const fromUin = node.userUin > 0 ? node.userUin : toInt(bridge.identity.uin);
|
||||
if (fromUin <= 0) throw new Error('forward node user uin is invalid');
|
||||
|
||||
const nickname = node.nickname.trim() || String(fromUin);
|
||||
const elems = await buildSendElems(node.elements);
|
||||
const sendCtx = groupId !== undefined
|
||||
? { bridge, groupId }
|
||||
: { bridge };
|
||||
const elems = await buildSendElems(node.elements, sendCtx);
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const random = Math.floor(Math.random() * 0x7fffffff) >>> 0;
|
||||
const seq = Math.floor(Math.random() * 9000000) + 1000000;
|
||||
@@ -67,7 +71,7 @@ export async function uploadForwardNodes(bridge: Bridge, nodes: ForwardNodePaylo
|
||||
throw new Error('forward nodes are required');
|
||||
}
|
||||
|
||||
const msgBody = await Promise.all(nodes.map(node => buildForwardPushBody(bridge, node)));
|
||||
const msgBody = await Promise.all(nodes.map(node => buildForwardPushBody(bridge, node, groupId)));
|
||||
const longMsgResult = protoEncode({
|
||||
action: [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user