nadia v0.4.3 Nadia
Provides access to Telegram Bot API.
Reference
Summary
Functions
Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned
Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed
Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned
Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned
Use this method to edit text messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned
Use this method to forward messages of any kind. On success, the sent Message is returned
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.) Returns a Chat object on success
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned
Use this method to get information about a member of a chat. Returns a ChatMember object on success
Use this method to get the number of members in a chat. Returns Int on success
Use this method to get basic info about a file and prepare it for downloading.
For the moment, bots can download files of up to 20MB in size.
On success, a File object is returned.
The file can then be downloaded via the link
https://api.telegram.org/file/bot<token>/<file_path>
, where get_file
again
Use this method to get link for file for subsequent use.
This method is an extension of the get_file
method
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
Use this method to receive incoming updates using long polling. An Array of Update objects is returned
Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object
Use this method to kick a user from a group or a supergroup. In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the group for this to work. Returns True on success
Use this method for your bot to leave a group, supergroup or channel. Returns True on success
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
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)
Use this method to send phone contacts. On success, the sent Message is returned
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
Use this method to send point on the map. On success, the sent Message is returned
Use this method to send text messages. On success, the sent Message is returned
Use this method to send photos. On success, the sent Message is returned
Use this method to send .webp stickers. On success, the sent Message is returned
Use this method to send information about a venue. On success, the sent Message is returned
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
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
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
Use this method to unban a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work. Returns True on success
Functions
Specs
answer_callback_query(binary, [{atom, any}]) ::
:ok |
{:error, Nadia.Model.Error.t}
Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
Args:
callback_query_id
- Unique identifier for the query to be answeredoptions
- orddict of options
Options:
:text
- Text of the notification. If not specified, nothing will be shown to the user:show_alert
- If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
Specs
answer_inline_query(binary, [Nadia.Model.InlineQueryResult.t], [{atom, any}]) ::
:ok |
{:error, Nadia.Model.Error.t}
Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.
Args:
inline_query_id
- Unique identifier for the answered queryresults
- An array of results for the inline queryoptions
- orddict of options
Options:
cache_time
- The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.is_personal
- Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same querynext_offset
- Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.switch_pm_text
- If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter.switch_pm_parameter
- Parameter for the start message sent to the bot when user presses the switch button.
Specs
edit_message_caption(integer | binary, integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.Error.t}
Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned.
Args:
chat_id
- Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)message_id
- Required if inline_message_id is not specified. Unique identifier of the sent messageinline_message_id
- Required ifchat_id
andmessage_id
are not specified. Identifier of the inline messageoptions
- orddict of options
Options:
:caption
- New caption of the message:reply_markup
- A JSON-serialized object for an inline keyboard -Nadia.Model.InlineKeyboardMarkup
Specs
edit_message_reply_markup(integer | binary, integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.Error.t}
Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned.
Args:
chat_id
- Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)message_id
- Required if inline_message_id is not specified. Unique identifier of the sent messageinline_message_id
- Required ifchat_id
andmessage_id
are not specified. Identifier of the inline messageoptions
- orddict of options
Options:
:reply_markup
- A JSON-serialized object for an inline keyboard -Nadia.Model.InlineKeyboardMarkup
Use this method to edit text messages sent by the bot or via the bot (for inline bots). On success, the edited Message is returned
Args:
chat_id
- Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)message_id
- Required if inline_message_id is not specified. Unique identifier of the sent messageinline_message_id
- Required ifchat_id
andmessage_id
are not specified. Identifier of the inline messagetext
- New text of the messageoptions
- orddict of options
Options:
:parse_mode
- Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot’s message.:disable_web_page_preview
- Disables link previews for links in this message:reply_markup
- A JSON-serialized object for an inline keyboard -Nadia.Model.InlineKeyboardMarkup
Specs
forward_message(integer, integer, integer) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.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 target chat or username of the target channel (in the format @channelusername)from_chat_id
- Unique identifier for the chat where the original message was sent or username of the target channel (in the format @channelusername):disable_notification
- Sends the message silently or without notificationmessage_id
- Unique message identifier
Specs
get_chat(integer | binary) ::
{:ok, Chat.t} |
{:error, Nadia.Model.Error.t}
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.) Returns a Chat object on success.
Args:
chat_id
- Unique identifier for the target chat or username of the target supergroup or channel (in the format @supergroupusername)
Specs
get_chat_administrators(integer | binary) ::
{:ok, [ChatMember.t]} |
{:error, Nadia.Model.Error.t}
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
Args:
chat_id
- Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
Specs
get_chat_member(integer | binary, integer) ::
{:ok, ChatMember.t} |
{:error, Nadia.Model.Error.t}
Use this method to get information about a member of a chat. Returns a ChatMember object on success.
Args:
chat_id
- Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)user_id
- Unique identifier of the target user
Specs
get_chat_members_count(integer | binary) ::
{:ok, integer} |
{:error, Nadia.Model.Error.t}
Use this method to get the number of members in a chat. Returns Int on success.
Args:
chat_id
- Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
Specs
get_file(binary) ::
{:ok, Nadia.Model.File.t} |
{:error, Nadia.Model.Error.t}
Use this method to get basic info about a file and prepare it for downloading.
For the moment, bots can download files of up to 20MB in size.
On success, a File object is returned.
The file can then be downloaded via the link
https://api.telegram.org/file/bot<token>/<file_path>
, where get_file
again.
Args:
file_id
- File identifier to get info about
Specs
get_file_link(Nadia.Model.File.t) ::
{:ok, binary} |
{:error, Nadia.Model.Error.t}
Use this method to get link for file for subsequent use.
This method is an extension of the get_file
method.
iex> Nadia.get_file_link(%Nadia.Model.File{file_id: "BQADBQADBgADmEjsA1aqdSxtzvvVAg",
...> file_path: "document/file_10", file_size: 17680})
{:ok,
"https://api.telegram.org/file/bot#{Application.get_env(:nadia, :token)}/document/file_10"}
Specs
get_me ::
{:ok, Nadia.Model.User.t} |
{:error, Nadia.Model.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.Model.Update.t]} |
{:error, Nadia.Model.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_updates
is called with anoffset
higher 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.Model.UserProfilePhotos.t} |
{:error, Nadia.Model.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
kick_chat_member(integer | binary, integer) ::
:ok |
{:error, Nadia.Model.Error.t}
Use this method to kick a user from a group or a supergroup. In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the group for this to work. Returns True on success.
Note: This will method only work if the ‘All Members Are Admins’ setting is off in the target group. Otherwise members may only be removed by the group’s creator or by the member that added them.
Args:
chat_id
- Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)user_id
- Unique identifier of the target user
Specs
leave_chat(integer | binary) ::
:ok |
{:error, Nadia.Model.Error.t}
Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
Args:
chat_id
- Unique identifier for the target chat or username of the target supergroup or channel (in the format @supergroupusername)
Specs
send_audio(integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.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 target chat or username of the target channel (in the format @channelusername)audio
- Audio to send. Either afile_id
to resend an audio that is already on the Telegram servers, or afile_path
to upload a new audiooptions
- orddict of options
Options:
:duration
- Duration of the audio in seconds:performer
- Performer:title
- Track name:disable_notification
- Sends the message silently or without notification: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 -Nadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_chat_action(integer, binary) ::
:ok |
{:error, Nadia.Model.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 target chat or username of the target channel (in the format @channelusername)action
- Type of action to broadcast. Choose one, depending on what the user is about to receive:typing
for text messagesupload_photo
for photosrecord_video
orupload_video
for videosrecord_audio
orupload_audio
for audio filesupload_document
for general filesfind_location
for location data
Specs
send_contact(integer, binary, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.Error.t}
Use this method to send phone contacts. On success, the sent Message is returned.
Args:
chat_id
- Unique identifier for the target chat or username of the target channel (in the format @channelusername)phone_number
- Contact’s phone numberfirst_name
- Contact’s first nameoptions
- orddict of options
Options:
:last_name
- Contact’s last name:disable_notification
- Sends the message silently or without notification:reply_to_message_id
- If the message is a reply, ID of the original message:reply_markup
- Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to hide reply keyboard or to force a reply from the user. -Nadia.Model.InlineKeyboardMarkup
orNadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_document(integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.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 target chat or username of the target channel (in the format @channelusername)document
- File to send. Either afile_id
to resend a file that is already on the Telegram servers, or afile_path
to upload a new fileoptions
- orddict of options
Options:
:disable_notification
- Sends the message silently or without notification: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 -Nadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_location(integer, float, float, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.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 target chat or username of the target channel (in the format @channelusername)latitude
- Latitude of locationlongitude
- Longitude of locationoptions
- orddict of options
Options:
:disable_notification
- Sends the message silently or without notification: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 -Nadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_message(integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.Error.t}
Use this method to send text messages. On success, the sent Message is returned.
Args:
chat_id
- Unique identifier for the target chat or username of the target channel (in the format @channelusername)text
- Text of the message to be sentoptions
- orddict of options
Options:
:parse_mode
- UseMarkdown
, if you want Telegram apps to show bold, italic and inline URLs in your bot’s message:disable_web_page_preview
- Disables link previews for links in this message:disable_notification
- Sends the message silently or without notification: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 -Nadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_photo(integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.Error.t}
Use this method to send photos. On success, the sent Message is returned.
Args:
chat_id
- Unique identifier for the target chat or username of the target channel (in the format @channelusername)photo
- Photo to send. Either afile_id
to resend a photo that is already on the Telegram servers, or afile_path
to upload a new photooptions
- orddict of options
Options:
:caption
- Photo caption (may also be used when resending photos byfile_id
):disable_notification
- Sends the message silently or without notification: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 -Nadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_sticker(integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.Error.t}
Use this method to send .webp stickers. On success, the sent Message is returned.
Args:
chat_id
- Unique identifier for the target chat or username of the target channel (in the format @channelusername)sticker
- File to send. Either afile_id
to resend a sticker that is already on the Telegram servers, or afile_path
to upload a new stickeroptions
- orddict of options
Options:
:disable_notification
- Sends the message silently or without notification: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 -Nadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_venue(integer, float, float, binary, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.Error.t}
Use this method to send information about a venue. On success, the sent Message is returned.
Args:
chat_id
- Unique identifier for the target chat or username of the target channel (in the format @channelusername)latitude
- Latitude of locationlongitude
- Longitude of locationtitle
- Name of the venueaddress
- Address of the venueoptions
- orddict of options
Options:
:foursquare_id
- Foursquare identifier of the venue:disable_notification
- Sends the message silently or without notification:reply_to_message_id
- If the message is a reply, ID of the original message:reply_markup
- Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to hide reply keyboard or to force a reply from the user. -Nadia.Model.InlineKeyboardMarkup
orNadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_video(integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.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 target chat or username of the target channel (in the format @channelusername)video
- Video to send. Either afile_id
to resend a video that is already on the Telegram servers, or afile_path
to 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
):disable_notification
- Sends the message silently or without notification: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 -Nadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
send_voice(integer, binary, [{atom, any}]) ::
{:ok, Nadia.Model.Message.t} |
{:error, Nadia.Model.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 target chat or username of the target channel (in the format @channelusername)voice
- Audio to send. Either afile_id
to resend an audio that is already on the Telegram servers, or afile_path
to upload a new audiooptions
- orddict of options
Options:
:duration
- Duration of the audio in seconds:disable_notification
- Sends the message silently or without notification: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 -Nadia.Model.ReplyKeyboardMarkup
orNadia.Model.ReplyKeyboardHide
orNadia.Model.ForceReply
Specs
set_webhook([{atom, any}]) ::
:ok |
{:error, Nadia.Model.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
Specs
unban_chat_member(integer | binary, integer) ::
:ok |
{:error, Nadia.Model.Error.t}
Use this method to unban a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work. Returns True on success.
Args:
chat_id
- Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)user_id
- Unique identifier of the target user