From a64779684e644d86ad33b4469c7cda7e0f73ccdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Mon, 25 Aug 2025 15:50:05 +0800 Subject: [PATCH] fix #1171 && Improve message recall handling and cleanup Changed recallMsg to return the result of the event call. Added a 5-second cache cleanup for recall events in DeleteMsg. Removed an unnecessary blank line in plugin.ts. --- src/core/apis/msg.ts | 2 +- src/onebot/action/msg/DeleteMsg.ts | 3 +++ src/onebot/network/plugin.ts | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/apis/msg.ts b/src/core/apis/msg.ts index 3dd1e365..5edb20bf 100644 --- a/src/core/apis/msg.ts +++ b/src/core/apis/msg.ts @@ -191,7 +191,7 @@ export class NTQQMsgApi { } async recallMsg(peer: Peer, msgId: string) { - await this.core.eventWrapper.callNormalEventV2( + return await this.core.eventWrapper.callNormalEventV2( 'NodeIKernelMsgService/recallMsg', 'NodeIKernelMsgListener/onMsgInfoListUpdate', [peer, [msgId]], diff --git a/src/onebot/action/msg/DeleteMsg.ts b/src/onebot/action/msg/DeleteMsg.ts index a4b27aa2..4b8acdb8 100644 --- a/src/onebot/action/msg/DeleteMsg.ts +++ b/src/onebot/action/msg/DeleteMsg.ts @@ -16,6 +16,9 @@ class DeleteMsg extends OneBotAction { async _handle(payload: Payload) { const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id)); if (msg) { + this.obContext.recallEventCache.set(msg.MsgId, setTimeout(() => { + this.obContext.recallEventCache.delete(msg.MsgId); + }, 5000)); await this.core.apis.MsgApi.recallMsg(msg.Peer, msg.MsgId); } else { throw new Error('Recall failed'); diff --git a/src/onebot/network/plugin.ts b/src/onebot/network/plugin.ts index 717276d9..257da85d 100644 --- a/src/onebot/network/plugin.ts +++ b/src/onebot/network/plugin.ts @@ -5,7 +5,6 @@ import { PluginConfig } from '../config/config'; import { plugin_onmessage } from '@/plugin'; import { ActionMap } from '../action'; import { IOB11NetworkAdapter } from '@/onebot/network/adapter'; - export class OB11PluginAdapter extends IOB11NetworkAdapter { constructor( name: string, core: NapCatCore, obContext: NapCatOneBot11Adapter, actions: ActionMap