* 带重试机制的删除消息函数
( client: TelegramClient, chatEntity: any, messageIds: number[], retryCount: number = 0 )
| 89 | ): Promise<number> { |
| 90 | try { |
| 91 | await client.deleteMessages(chatEntity, messageIds, { revoke: true }); |
| 92 | |
| 93 | // 强制刷新更新状态,确保跨平台同步 |
| 94 | try { |
| 95 | await client.invoke(new Api.updates.GetState()); |
| 96 | console.log(`[DME] 已触发跨平台同步刷新`); |
| 97 | } catch (syncError) { |
| 98 | console.log(`[DME] 同步刷新失败,但不影响删除操作:`, syncError); |
| 99 | } |
| 100 | |
| 101 | return messageIds.length; |
| 102 | } catch (error: any) { |
| 103 | if (retryCount < CONFIG.RETRY_ATTEMPTS) { |
| 104 | console.log(`[DME] 删除失败,第 ${retryCount + 1} 次重试:`, error.message); |
| 105 | await sleep(CONFIG.DELAYS.RETRY * (retryCount + 1)); |
| 106 | return deleteMessagesWithRetry(client, chatEntity, messageIds, retryCount + 1); |
| 107 | } |
| 108 | throw error; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * 通用删除消息函数 - 增强版本 |
| 114 | */ |
| 115 | async function deleteMessagesUniversal( |
| 116 | client: TelegramClient, |
| 117 | chatEntity: any, |
| 118 | messageIds: number[] |
| 119 | ): Promise<number> { |
| 120 | return deleteMessagesWithRetry(client, chatEntity, messageIds); |
no test coverage detected