mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-19 05:05:44 +08:00
Fix spurious group_card events for forward messages
Prevent false group card change events when sending forward messages with comments. The issue occurred because forward messages sometimes have empty sendMemberName fields, triggering incorrect "name → empty" card change events. Solution: Skip card change detection when the new card name is empty but the old card name is not empty, as this indicates unreliable data (e.g., from forward messages). Co-authored-by: sj817 <74231782+sj817@users.noreply.github.com>
This commit is contained in:
parent
b930eea84f
commit
6a6a0e0539
@ -116,6 +116,16 @@ export class OneBotGroupApi {
|
||||
const member = await this.core.apis.GroupApi.getGroupMember(msg.peerUid, msg.senderUin);
|
||||
if (member && member.cardName !== msg.sendMemberName) {
|
||||
const newCardName = msg.sendMemberName ?? '';
|
||||
// 防止误触:如果新名片为空且旧名片不为空,不触发事件(可能是转发消息等场景的不可靠数据)
|
||||
if (newCardName === '' && member.cardName !== '') {
|
||||
this.core.context.logger.logDebug('忽略不可靠的群名片变更事件', {
|
||||
peerUid: msg.peerUid,
|
||||
senderUin: msg.senderUin,
|
||||
oldCard: member.cardName,
|
||||
newCard: newCardName
|
||||
});
|
||||
return undefined;
|
||||
}
|
||||
const event = new OB11GroupCardEvent(this.core, parseInt(msg.peerUid), parseInt(msg.senderUin), newCardName, member.cardName);
|
||||
member.cardName = newCardName;
|
||||
return event;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user