feat(onebot): add group_name to group message events (#212)

Group message events (message + message_sent) now carry group_name — a
non-standard but common OneBot extension. The name comes from the
message's own wire field (ResponseGrp field 7, accurate even right after
a rename), falling back to the identity group cache, else '' when neither
is available. It's resolved in the group-message decoder, where both the
wire head and the identity cache are already at hand, so the converter
just passes it through (no ConverterContext change).

Verified live (tempserver): real inbound group messages from a non-self
account carry group_name set to the actual group name.
This commit is contained in:
DrSmoothl committed 2026-07-09 18:50:54 +08:00
1 parent 7ab91c81e9
commit 9b470d0412
5 files changed
+15 -3

No files matched your search

@@ -12,6 +12,7 @@ export const decodeGroupMessage: MsgPushDecoder = (ctx) => {
msgId: ctx.head.msgId & 0x7FFFFFFF,
elements: decodeRichBody(ctx.body, true),
groupId: 0,
groupName: '',
senderNick: '',
senderCard: '',
senderRole: '',
@@ -43,5 +44,9 @@ export const decodeGroupMessage: MsgPushDecoder = (ctx) => {
} else if (!ev.senderNick && grp?.memberCard) {
ev.senderNick = grp.memberCard;
}
// Group name: prefer the message's own wire field (ResponseGrp field 7 —
// fresh even right after a rename), fall back to the cached group list, else
// leave it empty. `ev.groupId` is set above from grp.groupUin.
ev.groupName = grp?.groupName || ctx.identity.findGroup(ev.groupId)?.groupName || '';
return [ev];
};