From 32df6d5911ce8e0c84b6391fb869538b23ad4e5c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 10:17:20 +0000 Subject: [PATCH] Fix intermittent recall event loss in high-frequency scenarios Co-authored-by: sj817 <74231782+sj817@users.noreply.github.com> --- src/onebot/index.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/onebot/index.ts b/src/onebot/index.ts index bbbd4c6a..744e4807 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -347,21 +347,19 @@ export class NapCatOneBot11Adapter { peerUid: uid, guildId: '', }; - let msg = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeq(peer, msgSeq)).msgList.find(e => e.msgType === NTMsgType.KMSGTYPEGRAYTIPS); + const msg = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeq(peer, msgSeq)).msgList.find(e => e.msgType === NTMsgType.KMSGTYPEGRAYTIPS); const element = msg?.elements.find(e => !!e.grayTipElement?.revokeElement); + + // Clean up recall event cache if this is a self-device operation if (msg && element?.grayTipElement?.revokeElement.isSelfOperate) { - const isSelfDevice = this.recallEventCache.has(msg.msgId); - if (isSelfDevice) { - await this.core.eventWrapper.registerListen('NodeIKernelMsgListener/onMsgRecall', - (chatType: ChatType, uid: string, msgSeq: string) => { - return chatType === msg?.chatType && uid === msg?.peerUid && msgSeq === msg?.msgSeq; - } - ).catch(() => { - msg = undefined; - this.context.logger.logDebug('自操作消息撤回事件'); - }); + const cachedTimeout = this.recallEventCache.get(msg.msgId); + if (cachedTimeout) { + clearTimeout(cachedTimeout); + this.recallEventCache.delete(msg.msgId); + this.context.logger.logDebug('自操作消息撤回事件'); } } + if (msg && element) { const recallEvent = await this.emitRecallMsg(msg, element); try {