/** * File helper functions for Telegram Bot API * @module helpers/file-helpers */ import type { TelegramBotClient } from '../client/TelegramBotClient.js'; import type { HttpRequestOptions } from '../types/http-client.types.js'; /** * Get Telegram file download URL * Retrieves file_path from Telegram API and constructs download URL * * @param fileId - Telegram file_id * @param client - TelegramBotClient instance * @param routeId - Route ID for multi-token setup (optional) * @returns Download URL for the file * * @throws {Error} If file_path is not available in response * * @example * ```typescript * const url = await getFileUrl(fileId, bot); * console.log('Download from:', url); * // "https://api.telegram.org/file/bot/photos/file_123.jpg" * ``` */ export declare function getFileUrl(fileId: string, client: TelegramBotClient, routeId?: string): Promise; /** * Download Telegram file as Buffer * Combines getFile API call with file download using HTTP client * * @param fileId - Telegram file_id * @param client - TelegramBotClient instance * @param routeId - Route ID for multi-token setup (optional) * @param options - Download options (timeout, retries) * @returns File content as Buffer * * @example * ```typescript * // With default settings * const buffer = await getTelegramFileBuffer(fileId, bot); * await fs.writeFile('photo.jpg', buffer); * * // With custom timeout for large files * const buffer = await getTelegramFileBuffer(fileId, bot, undefined, { * timeout: 120000, // 2 minutes * retries: 5 * }); * ``` */ export declare function getTelegramFileBuffer(fileId: string, client: TelegramBotClient, routeId?: string, options?: HttpRequestOptions): Promise; /** * Download Telegram file as ReadableStream * Useful for large files or streaming to destination * * @param fileId - Telegram file_id * @param client - TelegramBotClient instance * @param routeId - Route ID for multi-token setup (optional) * @param options - Download options (only timeout is used for streams) * @returns File content as ReadableStream * * @example * ```typescript * import { pipeline } from 'stream/promises'; * import { Readable } from 'stream'; * * const stream = await getTelegramFileStream(fileId, bot); * await pipeline( * Readable.fromWeb(stream), * fs.createWriteStream('video.mp4') * ); * ``` */ export declare function getTelegramFileStream(fileId: string, client: TelegramBotClient, routeId?: string, options?: HttpRequestOptions): Promise; /** * Download file from any URL as Buffer * Not Telegram-specific, uses HTTP client for retry/timeout logic * * @param url - File URL to download * @param client - TelegramBotClient instance (for HTTP client access) * @param options - Download options (timeout, retries) * @returns File content as Buffer * * @example * ```typescript * // Download external file * const buffer = await downloadFileBuffer( * 'https://example.com/report.pdf', * bot, * { timeout: 60000, retries: 3 } * ); * ``` */ export declare function downloadFileBuffer(url: string, client: TelegramBotClient, options?: HttpRequestOptions): Promise; /** * Download file from any URL as ReadableStream * Not Telegram-specific * * @param url - File URL to download * @param client - TelegramBotClient instance * @param options - Download options (only timeout) * @returns File content as ReadableStream * * @example * ```typescript * import { pipeline } from 'stream/promises'; * import { Readable } from 'stream'; * * const stream = await downloadFileStream(url, bot); * await pipeline( * Readable.fromWeb(stream), * fs.createWriteStream('file.pdf') * ); * ``` */ export declare function downloadFileStream(url: string, client: TelegramBotClient, options?: HttpRequestOptions): Promise; /** @deprecated Use getTelegramFileBuffer instead */ export declare const getFileBuffer: typeof getTelegramFileBuffer; /** @deprecated Use getTelegramFileStream instead */ export declare const getFileStream: typeof getTelegramFileStream;