Functions

download-file

fn (file-id: Str): Bytes
fn (file-id: Str, opts: Map): Bytes

getFile, then download the file's content as Bytes (up to 20 MB).

Example

::files ::telegram::files

on-voice fn (message: Map): Bytes {
  ::files/download-file(message.voice.file_id)
}
Context Vars: telegram.bot.token

get-file

fn (file-id: Str): File
fn (file-id: Str, opts: Map): File

getFile - Resolve a file_id (from a message's photo, document, voice, ...) to a downloadable file_path. Bots can download files up to 20 MB.

Example

::files ::telegram::files

file ::files/get-file("AgACAgIAAxkBAAIB...")
file.file_path  // => "photos/file_12.jpg"
Context Vars: telegram.bot.token

Types

File

File type {
    file_id: Str,
    file_unique_id: Str?,
    file_size: Int?,
    file_path: Str?
}

A file ready to download. file_path is valid for at least an hour; fetch a fresh one with get-file after that.