mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-20 21:50:10 +08:00
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.
This commit is contained in:
parent
ecd7012eee
commit
a64779684e
@ -191,7 +191,7 @@ export class NTQQMsgApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async recallMsg(peer: Peer, msgId: string) {
|
async recallMsg(peer: Peer, msgId: string) {
|
||||||
await this.core.eventWrapper.callNormalEventV2(
|
return await this.core.eventWrapper.callNormalEventV2(
|
||||||
'NodeIKernelMsgService/recallMsg',
|
'NodeIKernelMsgService/recallMsg',
|
||||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
[peer, [msgId]],
|
[peer, [msgId]],
|
||||||
|
|||||||
@ -16,6 +16,9 @@ class DeleteMsg extends OneBotAction<Payload, void> {
|
|||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id));
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id));
|
||||||
if (msg) {
|
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);
|
await this.core.apis.MsgApi.recallMsg(msg.Peer, msg.MsgId);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Recall failed');
|
throw new Error('Recall failed');
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import { PluginConfig } from '../config/config';
|
|||||||
import { plugin_onmessage } from '@/plugin';
|
import { plugin_onmessage } from '@/plugin';
|
||||||
import { ActionMap } from '../action';
|
import { ActionMap } from '../action';
|
||||||
import { IOB11NetworkAdapter } from '@/onebot/network/adapter';
|
import { IOB11NetworkAdapter } from '@/onebot/network/adapter';
|
||||||
|
|
||||||
export class OB11PluginAdapter extends IOB11NetworkAdapter<PluginConfig> {
|
export class OB11PluginAdapter extends IOB11NetworkAdapter<PluginConfig> {
|
||||||
constructor(
|
constructor(
|
||||||
name: string, core: NapCatCore, obContext: NapCatOneBot11Adapter, actions: ActionMap
|
name: string, core: NapCatCore, obContext: NapCatOneBot11Adapter, actions: ActionMap
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user