(msg: Api.Message, seconds: number)
| 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 |
no test coverage detected