* Download a file from Telegram and save it locally.
(
fileId: string,
channelId: string,
filename: string,
mimeType?: string,
)
| 394 | * Download a file from Telegram and save it locally. |
| 395 | */ |
| 396 | private async downloadTelegramFile( |
| 397 | fileId: string, |
| 398 | channelId: string, |
| 399 | filename: string, |
| 400 | mimeType?: string, |
| 401 | ): Promise<ChannelAttachment | null> { |
| 402 | if (!this.bot) return null; |
| 403 | |
| 404 | try { |
| 405 | const fileLink = await this.bot.getFileLink(fileId); |
| 406 | return await downloadAndSaveAttachment( |
| 407 | this.rootDir, |
| 408 | channelId, |
| 409 | fileLink, |
| 410 | filename, |
| 411 | mimeType, |
| 412 | ); |
| 413 | } catch (err) { |
| 414 | console.error(`[Telegram] Failed to download file ${fileId}:`, err); |
| 415 | return null; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * Send a file to the Telegram chat. |
no test coverage detected