MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / downloadTelegramFile

Method downloadTelegramFile

src/runtime/adapters/telegram.ts:396–417  ·  view source on GitHub ↗

* Download a file from Telegram and save it locally.

(
    fileId: string,
    channelId: string,
    filename: string,
    mimeType?: string,
  )

Source from the content-addressed store, hash-verified

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.

Callers 1

extractAttachmentsMethod · 0.95

Calls 1

Tested by

no test coverage detected