* 获取防撤回图片,支持缓存
()
| 62 | const dir = path.dirname(CONFIG.TROLL_IMAGE_PATH); |
| 63 | if (!fs.existsSync(dir)) { |
| 64 | fs.mkdirSync(dir, { recursive: true }); |
| 65 | } |
| 66 | |
| 67 | try { |
| 68 | const response = await fetch(CONFIG.TROLL_IMAGE_URL); |
| 69 | if (response.ok) { |
| 70 | const buffer = Buffer.from(await response.arrayBuffer()); |
| 71 | fs.writeFileSync(CONFIG.TROLL_IMAGE_PATH, buffer); |
| 72 | return CONFIG.TROLL_IMAGE_PATH; |
| 73 | } |
| 74 | return null; |
| 75 | } catch (error) { |
| 76 | console.error("[DME] 下载防撤回图片失败:", error); |
| 77 | return null; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * 带重试机制的删除消息函数 |
| 83 | */ |
| 84 | async function deleteMessagesWithRetry( |
| 85 | client: TelegramClient, |
| 86 | chatEntity: any, |
| 87 | messageIds: number[], |
| 88 | retryCount: number = 0 |
| 89 | ): Promise<number> { |
no test coverage detected