(chatId: number, messageId: number)
| 498 | |
| 499 | // 检查是否已经存在相同的记录,避免重复保存 |
| 500 | const exists = exitMsgs.some(msg => msg.cid === chatId && msg.mid === messageId); |
| 501 | if (exists) { |
| 502 | return; |
| 503 | } |
| 504 | |
| 505 | // 添加新的退出消息记录 |
| 506 | const exitMsg: ExitMessageData = { |
| 507 | cid: chatId, |
| 508 | mid: messageId, |
| 509 | timestamp: Date.now() |
| 510 | }; |
| 511 | |
| 512 | exitMsgs.push(exitMsg); |
| 513 | |
| 514 | // 清理超过24小时的旧记录,避免积累过多 |
| 515 | const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000; |
| 516 | const cleanedMsgs = exitMsgs.filter(msg => msg.timestamp > oneDayAgo); |
| 517 | |
| 518 | await this.saveExitMessages(cleanedMsgs); |
| 519 | } |
| 520 | |
| 521 | // 从退出消息记录中移除指定消息 |
| 522 | private async removeExitMessage(msg: Api.Message) { |
| 523 | try { |
| 524 | const chatId = this.getChatId(msg); |
| 525 | if (chatId) { |
| 526 | const exitMsgs = await this.loadExitMessages(); |
no test coverage detected