Telegram.Api (telegram v2.1.0)
View SourceTelegram Bot API - HTTP-based interface
Summary
Types
Functions
@spec file(Telegram.Types.token(), String.t()) :: request_result()
Download a file.
Reference: BOT Api
Example:
# send a photo
{:ok, res} = Telegram.Api.request(token, "sendPhoto", chat_id: 12345, photo: {:file, "example/photo.jpg"})
# pick the 'file_obj' with the desired resolution
[file_obj | _] = res["photo"]
# get the 'file_id'
file_id = file_obj["file_id"]
# obtain the 'file_path' to download the file identified by 'file_id'
{:ok, %{"file_path" => file_path}} = Telegram.Api.request(token, "getFile", file_id: file_id)
{:ok, file} = Telegram.Api.file(token, file_path)
@spec request(Telegram.Types.token(), Telegram.Types.method(), parameters()) :: request_result()
Send a Telegram Bot API request.
The request parameters
map to the bots API parameters.
Integer String Boolean Float
: Elixir native data typeJSON-serialized
:{:json, _}
tupleInputFile
:{:file, _}
or{:file_content, _, _}
tuple
Reference: BOT Api