Nadia
Provides access to Telegram Bot API.
Summary
| forward_message(chat_id, from_chat_id, message_id) | Use this method to forward messages of any kind. On success, the sent Message is returned |
| get_me() | A simple method for testing your bot’s auth token. Requires no parameters. Returns basic information about the bot in form of a User object |
| get_updates(options \\ []) | Use this method to receive incoming updates using long polling. An Array of Update objects is returned |
| get_user_profile_photos(user_id, options \\ []) | Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object |
| send_audio(chat_id, audio, options \\ []) | Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future |
| send_chat_action(chat_id, action) | Use this method when you need to tell the user that something is happening on the bot’s side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status) |
| send_document(chat_id, document, options \\ []) | Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future |
| send_location(chat_id, latitude, longitude, options \\ []) | Use this method to send point on the map. On success, the sent Message is returned |
| send_message(chat_id, text, options \\ []) | Use this method to send text messages. On success, the sent Message is returned |
| send_photo(chat_id, photo, options \\ []) | Use this method to send photos. On success, the sent Message is returned |
| send_sticker(chat_id, sticker, options \\ []) | Use this method to send .webp stickers. On success, the sent Message is returned |
| send_video(chat_id, video, options \\ []) | Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future |
| send_voice(chat_id, voice, options \\ []) | Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future |
| set_webhook(options \\ []) | Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts |
Functions
Specs:
- forward_message(integer, integer, integer) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to forward messages of any kind. On success, the sent Message is returned.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidfrom_chat_id- Unique identifier for the chat where the original message was sent —Nadia.UserorNadia.GroupChatidmessage_id- Unique message identifier
Specs:
- get_me :: {:ok, Nadia.User.t} | {:error, Nadia.Error.t}
A simple method for testing your bot’s auth token. Requires no parameters. Returns basic information about the bot in form of a User object.
Specs:
- get_updates([{atom, any}]) :: {:ok, [Nadia.Update.t]} | {:error, Nadia.Error.t}
Use this method to receive incoming updates using long polling. An Array of Update objects is returned.
Args:
options- orddict of options
Options:
:offset- Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon asget_updatesis called with anoffsethigher than itsupdate_id.:limit- Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100:timeout- Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling
Specs:
- get_user_profile_photos(integer, [{atom, any}]) :: {:ok, Nadia.UserProfilePhotos.t} | {:error, Nadia.Error.t}
Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
Args:
user_id- Unique identifier of the target useroptions- orddict of options
Options:
:offset- Sequential number of the first photo to be returned. By default, all photos are returned:limit- Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100
Specs:
- send_audio(integer, binary, [{atom, any}]) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
For backward compatibility, when the fields title and performer are both empty and the mime-type of the file to be sent is not audio/mpeg, the file will be sent as a playable voice message. For this to work, the audio must be in an .ogg file encoded with OPUS. This behavior will be phased out in the future. For sending voice messages, use the sendVoice method instead.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidaudio- Audio to send. Either afile_idto resend an audio that is already on the Telegram servers, or afile_pathto upload a new audiooptions- orddict of options
Options:
:duration- Duration of the audio in seconds:performer- Performer:title- Track name:reply_to_message_id- If the message is a reply, ID of the original message:reply_markup- Additional interface options. Instructions to hide keyboard or to force a reply from the user
Specs:
- send_chat_action(integer, binary) :: :ok | {:error, Nadia.Error.t}
Use this method when you need to tell the user that something is happening on the bot’s side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidaction- Type of action to broadcast. Choose one, depending on what the user is about to receive:typingfor text messagesupload_photofor photosrecord_videoorupload_videofor videosrecord_audioorupload_audiofor audio filesupload_documentfor general filesfind_locationfor location data
Specs:
- send_document(integer, binary, [{atom, any}]) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatiddocument- File to send. Either afile_idto resend a file that is already on the Telegram servers, or afile_pathto upload a new fileoptions- orddict of options
Options:
:reply_to_message_id- If the message is a reply, ID of the original message:reply_markup- Additional interface options. Instructions to hide keyboard or to force a reply from the user
Specs:
- send_location(integer, float, float, [{atom, any}]) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to send point on the map. On success, the sent Message is returned.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidlatitude- Latitude of locationlongitude- Longitude of locationoptions- orddict of options
Options:
:reply_to_message_id- If the message is a reply, ID of the original message:reply_markup- Additional interface options. Instructions to hide keyboard or to force a reply from the user
Specs:
- send_message(integer, binary, [{atom, any}]) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to send text messages. On success, the sent Message is returned.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidtext- Text of the message to be sentoptions- orddict of options
Options:
:disable_web_page_preview- Disables link previews for links in this message:reply_to_message_id- If the message is a reply, ID of the original message:reply_markup- Additional interface options. Instructions to hide keyboard or to force a reply from the user.
Specs:
- send_photo(integer, binary, [{atom, any}]) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to send photos. On success, the sent Message is returned.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidphoto- Photo to send. Either afile_idto resend a photo that is already on the Telegram servers, or afile_pathto upload a new photooptions- orddict of options
Options:
:caption- Photo caption (may also be used when resending photos byfile_id):reply_to_message_id- If the message is a reply, ID of the original message:reply_markup- Additional interface options. Instructions to hide keyboard or to force a reply from the user
Specs:
- send_sticker(integer, binary, [{atom, any}]) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to send .webp stickers. On success, the sent Message is returned.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidsticker- File to send. Either afile_idto resend a sticker that is already on the Telegram servers, or afile_pathto upload a new stickeroptions- orddict of options
Options:
:reply_to_message_id- If the message is a reply, ID of the original message:reply_markup- Additional interface options. Instructions to hide keyboard or to force a reply from the user
Specs:
- send_video(integer, binary, [{atom, any}]) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidvideo- Video to send. Either afile_idto resend a video that is already on the Telegram servers, or afile_pathto upload a new videooptions- orddict of options
Options:
:duration- Duration of the video in seconds:caption- Video caption (may also be used when resending videos byfile_id):reply_to_message_id- If the message is a reply, ID of the original message:reply_markup- Additional interface options. Instructions to hide keyboard or to force a reply from the user
Specs:
- send_voice(integer, binary, [{atom, any}]) :: {:ok, Nadia.Message.t} | {:error, Nadia.Error.t}
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
Args:
chat_id- Unique identifier for the message recipient —Nadia.UserorNadia.GroupChatidvoice- Audio to send. Either afile_idto resend an audio that is already on the Telegram servers, or afile_pathto upload a new audiooptions- orddict of options
Options:
:duration- Duration of the audio in seconds:reply_to_message_id- If the message is a reply, ID of the original message:reply_markup- Additional interface options. Instructions to hide keyboard or to force a reply from the user
Specs:
- set_webhook([{atom, any}]) :: :ok | {:error, Nadia.Error.t}
Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
Args:
options- orddict of options
Options:
:url- HTTPS url to send updates to. Use an empty string to remove webhook integration