mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-01 00:00:26 +00:00
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.
30 lines
1000 B
TypeScript
30 lines
1000 B
TypeScript
import { ActionName } from '@/onebot/action/router';
|
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|
import { MessageUnique } from '@/common/message-unique';
|
|
import { Static, Type } from '@sinclair/typebox';
|
|
|
|
const SchemaData = Type.Object({
|
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
|
});
|
|
|
|
type Payload = Static<typeof SchemaData>;
|
|
|
|
class DeleteMsg extends OneBotAction<Payload, void> {
|
|
override actionName = ActionName.DeleteMsg;
|
|
override payloadSchema = SchemaData;
|
|
|
|
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');
|
|
}
|
|
}
|
|
}
|
|
|
|
export default DeleteMsg;
|