MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / delayDelete

Method delayDelete

autodelcmd/autodelcmd.ts:354–381  ·  view source on GitHub ↗
(msg: Api.Message, seconds: number)

Source from the content-addressed store, hash-verified

352
353 // 保存退出消息信息,以便程序重启后能继续删除
354 try {
355 const chatId = this.getChatId(msg);
356 if (chatId) {
357 await this.saveExitMessage(chatId, msg.id);
358 }
359 } catch (error) {
360 console.error(`[autodelcmd] 保存删除任务失败:`, error);
361 }
362
363 this.scheduleTimeout(async () => {
364 try {
365 console.log(`[autodelcmd] 正在删除消息 ID ${msg.id}`);
366 await msg.delete({ revoke: true });
367
368 // 删除成功后,从退出消息记录中移除此条记录
369 await this.removeExitMessage(msg);
370 } catch (error: any) {
371 console.error(`[autodelcmd] 删除消息 ID ${msg.id} 失败:`, error.message);
372
373 // 删除失败也要从记录中移除,避免重复尝试
374 await this.removeExitMessage(msg);
375 }
376 }, seconds * 1000);
377 }
378
379 public async handleCommandPostprocess(
380 msg: Api.Message,
381 command: string,
382 parameters?: string[]
383 ) {
384

Callers 1

Calls 6

getChatIdMethod · 0.95
saveExitMessageMethod · 0.95
scheduleTimeoutMethod · 0.95
removeExitMessageMethod · 0.95
errorMethod · 0.80
deleteMethod · 0.45

Tested by

no test coverage detected