From 94262588fceba298281526b6d8fbf5ce1ec70b52 Mon Sep 17 00:00:00 2001 From: Il Harper Date: Tue, 5 Mar 2024 21:58:34 +0800 Subject: [PATCH] feat(event): implement `message-deleted` event --- packages/engine-chronocat-event/src/index.ts | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/engine-chronocat-event/src/index.ts b/packages/engine-chronocat-event/src/index.ts index 722cdcb..bb48d06 100644 --- a/packages/engine-chronocat-event/src/index.ts +++ b/packages/engine-chronocat-event/src/index.ts @@ -3,6 +3,7 @@ import type { OnBuddyReqChange, OnMemberInfoChange, OnMemberListChange, + OnMsgInfoListUpdate, OnProfileChanged, OnRecvMsg, Peer, @@ -19,6 +20,7 @@ import { emittedBuddyReqList, requestMethodMap } from './globalVars' import { FriendRequestDispatchMessage, MessageCreatedDispatchMessage, + MessageDeletedDispatchMessage, } from './messages' declare const __DEFINE_CHRONO_VERSION__: string @@ -127,6 +129,34 @@ export const apply = async (ctx: ChronocatContext) => { return } + + case 'nodeIKernelMsgListener/onMsgInfoListUpdate': { + const { msgList } = payload as OnMsgInfoListUpdate + + const filteredPayload = await Promise.all( + msgList + .filter( + (x) => + x.msgType === MsgType.System && + x.subMsgType === 4 && + !x.isOnlineMsg && + Number(x.recallTime) && + x.elements[0]!.elementType === 8 && + x.elements[0]!.grayTipElement?.subElementType === 1, + ) + .filter(filterMessage) + .map(async (msg) => { + // await prepareRole(msg) + // msg = await uixCache.preprocessObject(msg) + // setMsgCache(msg) + // fillRole(msg) + return msg + }), + ) + if (filteredPayload.length) + ctx.chronocat.emit(new MessageDeletedDispatchMessage(filteredPayload)) + return + } } }