telega/model
Types
pub type AnswerCallbackQueryParameters {
AnswerCallbackQueryParameters(
callback_query_id: String,
text: Option(String),
show_alert: Option(Bool),
url: Option(String),
cache_time: Option(Int),
)
}
Constructors
-
AnswerCallbackQueryParameters( callback_query_id: String, text: Option(String), show_alert: Option(Bool), url: Option(String), cache_time: Option(Int), )
Arguments
-
callback_query_id
Unique identifier for the query to be answered
-
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.
-
url
URL that will be opened by the user’s client. If you have created a Game, you can use this field to redirect the player to your game
-
cache_time
The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
-
pub type BotCommand {
BotCommand(command: String, description: String)
}
Constructors
-
BotCommand(command: String, description: String)
Official reference: https://core.telegram.org/bots/api#botcommand
Arguments
-
command
Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.
-
description
Description of the command; 1-256 characters.
-
pub type BotCommandParameters {
BotCommandParameters(
scope: Option(BotCommandScope),
language_code: Option(String),
)
}
Constructors
-
BotCommandParameters( scope: Option(BotCommandScope), language_code: Option(String), )
Arguments
-
scope
An object, describing scope of users for which the commands are relevant. Defaults to
BotCommandScopeDefault
. -
language_code
A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
-
Official reference: https://core.telegram.org/bots/api#botcommandscope
pub type BotCommandScope {
BotCommandDefaultScope
BotCommandAllPrivateChatsScope
BotCommandScopeAllGroupChats
BotCommandScopeAllChatAdministrators
BotCommandScopeChat(chat_id: Int)
BotCommandScopeChatString(chat_id: IntOrString)
BotCommandScopeChatAdministrators(chat_id: IntOrString)
BotCommandScopeChatMember(chat_id: IntOrString, user_id: Int)
}
Constructors
-
BotCommandDefaultScope
Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user.
-
BotCommandAllPrivateChatsScope
Represents the scope of bot commands, covering all private chats.
-
BotCommandScopeAllGroupChats
Represents the scope of bot commands, covering all group and supergroup chats.
-
BotCommandScopeAllChatAdministrators
Represents the scope of bot commands, covering all group and supergroup chat administrators.
-
BotCommandScopeChat(chat_id: Int)
Represents the scope of bot commands, covering a specific chat.
Arguments
-
chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
-
-
BotCommandScopeChatString(chat_id: IntOrString)
Represents the scope of bot commands, covering a specific chat.
Arguments
-
chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
-
-
BotCommandScopeChatAdministrators(chat_id: IntOrString)
Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
Arguments
-
chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
-
-
BotCommandScopeChatMember(chat_id: IntOrString, user_id: Int)
Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
Arguments
-
chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
-
user_id
Unique identifier of the target user
-
pub type CallbackQuery {
CallbackQuery(
id: String,
from: User,
message: Option(MaybeInaccessibleMessage),
inline_message_id: Option(String),
chat_instance: Option(String),
data: Option(String),
game_short_name: Option(String),
)
}
Constructors
-
CallbackQuery( id: String, from: User, message: Option(MaybeInaccessibleMessage), inline_message_id: Option(String), chat_instance: Option(String), data: Option(String), game_short_name: Option(String), )
This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.
NOTE: After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery. It is, therefore, necessary to react by calling answerCallbackQuery even if no notification to the user is needed (e.g., without specifying any of the optional parameters).
Official reference: CallbackQuery
Arguments
-
id
Unique identifier for this query
-
from
Sender
-
message
Message sent by the bot with the callback button that originated the query
-
inline_message_id
Identifier of the message sent via the bot in inline mode, that originated the query.
-
chat_instance
Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.
-
data
Data associated with the callback button. Be aware that the message originated the query can contain no callback buttons with this data.
-
game_short_name
Short name of a Game to be returned, serves as the unique identifier for the game
-
pub type Chat {
Chat(
id: Int,
username: Option(String),
first_name: Option(String),
last_name: Option(String),
is_forum: Option(Bool),
)
}
Constructors
-
Chat( id: Int, username: Option(String), first_name: Option(String), last_name: Option(String), is_forum: Option(Bool), )
Official reference: https://core.telegram.org/bots/api#chat
Arguments
-
id
Unique identifier for this chat.
-
username
Username, for private chats, supergroups and channels if available
-
first_name
First name of the other party in a private chat
-
last_name
Last name of the other party in a private chat
-
is_forum
True, if the supergroup chat is a forum (has topics enabled)
-
pub type ChatAdministratorRights {
ChatAdministratorRights(
is_anonymous: Bool,
can_manage_chat: Bool,
can_delete_messages: Bool,
can_manage_voice_chats: Bool,
can_restrict_members: Bool,
can_promote_members: Bool,
can_change_info: Bool,
can_invite_users: Bool,
can_post_stories: Bool,
can_edit_stories: Bool,
can_delete_stories: Bool,
can_post_messages: Option(Bool),
can_edit_messages: Option(Bool),
can_pin_messages: Option(Bool),
can_manage_topics: Option(Bool),
)
}
Constructors
-
ChatAdministratorRights( is_anonymous: Bool, can_manage_chat: Bool, can_delete_messages: Bool, can_manage_voice_chats: Bool, can_restrict_members: Bool, can_promote_members: Bool, can_change_info: Bool, can_invite_users: Bool, can_post_stories: Bool, can_edit_stories: Bool, can_delete_stories: Bool, can_post_messages: Option(Bool), can_edit_messages: Option(Bool), can_pin_messages: Option(Bool), can_manage_topics: Option(Bool), )
Represents the rights of an administrator in a chat.
Official reference: ChatAdministratorRights
Arguments
-
is_anonymous
True, if the user’s presence in the chat is hidden
-
can_manage_chat
True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege.
-
can_delete_messages
True, if the administrator can delete messages of other users
-
can_manage_voice_chats
True, if the administrator can manage video chats
-
can_restrict_members
True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics
-
can_promote_members
True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user)
-
can_change_info
True, if the user is allowed to change the chat title, photo and other settings
-
can_invite_users
True, if the user is allowed to invite new users to the chat
-
can_post_stories
True, if the administrator can post stories to the chat
-
can_edit_stories
True, if the administrator can edit stories posted by other users
-
can_delete_stories
True, if the administrator can delete stories posted by other users
-
can_post_messages
True, if the administrator can post messages in the channel, or access channel statistics; for channels only
-
can_edit_messages
True, if the administrator can edit messages of other users and can pin messages; for channels only
-
can_pin_messages
True, if the user is allowed to pin messages; for groups and supergroups only
-
can_manage_topics
True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only
-
pub type EditMessageTextParameters {
EditMessageTextParameters(
chat_id: Option(IntOrString),
message_id: Option(Int),
inline_message_id: Option(String),
text: String,
parse_mode: Option(String),
entities: Option(List(MessageEntity)),
link_preview_options: Option(LinkPreviewOptions),
reply_markup: Option(InlineKeyboardMarkup),
)
}
Constructors
-
EditMessageTextParameters( chat_id: Option(IntOrString), message_id: Option(Int), inline_message_id: Option(String), text: String, parse_mode: Option(String), entities: Option(List(MessageEntity)), link_preview_options: Option(LinkPreviewOptions), reply_markup: Option(InlineKeyboardMarkup), )
Arguments
-
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. Identifier of the message to edit
-
inline_message_id
Required if chat_id and message_id are not specified. Identifier of the inline message
-
text
New text of the message, 1-4096 characters after entities parsing
-
parse_mode
Mode for parsing entities in the message text. See formatting options for more details.
-
entities
A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
-
link_preview_options
Link preview generation options for the message
-
reply_markup
A JSON-serialized object for an inline keyboard.
-
pub type EditMessageTextResult {
EditMessageTextMessage(Message)
EditMessageTextBool(Bool)
}
Constructors
-
EditMessageTextMessage(Message)
-
EditMessageTextBool(Bool)
pub type InaccessibleMessage {
InaccessibleMessage(chat: Chat, message_id: Int, date: Int)
}
Constructors
-
InaccessibleMessage(chat: Chat, message_id: Int, date: Int)
This object describes a message that was deleted or is otherwise inaccessible to the bot.
Official reference: InaccessibleMessage
Arguments
-
chat
Chat the message belonged to
-
message_id
Unique message identifier inside the chat
-
date
Always 0. The field can be used to differentiate regular and inaccessible messages.
-
pub type InlineKeyboardButton {
InlineKeyboardButton(
text: String,
url: Option(String),
callback_data: Option(String),
web_app: Option(WebAppInfo),
login_url: Option(LoginUrl),
switch_inline_query: Option(String),
switch_inline_query_current_chat: Option(String),
switch_inline_query_chosen_chat: Option(
SwitchInlineQueryChosenChat,
),
pay: Option(Bool),
)
}
Constructors
-
InlineKeyboardButton( text: String, url: Option(String), callback_data: Option(String), web_app: Option(WebAppInfo), login_url: Option(LoginUrl), switch_inline_query: Option(String), switch_inline_query_current_chat: Option(String), switch_inline_query_chosen_chat: Option( SwitchInlineQueryChosenChat, ), pay: Option(Bool), )
Official reference: https://core.telegram.org/bots/api#inlinekeyboardbutton
Arguments
-
text
Label text on the button
-
url
HTTP or
tg://
URL to be opened when the button is pressed. Linkstg://user?id=<user_id>
can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings. -
callback_data
Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes
-
web_app
Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot.
-
login_url
An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.
-
switch_inline_query
If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot’s username and the specified inline query in the input field. May be empty, in which case just the bot’s username will be inserted.
-
switch_inline_query_current_chat
set, pressing the button will insert the bot’s username and the specified inline query in the current chat’s input field. May be empty, in which case only the bot’s username will be inserted.
This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options.
-
switch_inline_query_chosen_chat
If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot’s username and the specified inline query in the input field
-
pay
Specify True, to send a Pay button.
NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.
-
pub type InlineKeyboardMarkup {
InlineKeyboardMarkup(
inline_keyboard: List(List(InlineKeyboardButton)),
)
}
Constructors
-
InlineKeyboardMarkup( inline_keyboard: List(List(InlineKeyboardButton)), )
Official reference: https://core.telegram.org/bots/api#inlinekeyboardmarkup
pub type IntOrString {
Inted(Int)
Stringed(String)
}
Constructors
-
Inted(Int)
-
Stringed(String)
pub type KeyboardButton {
KeyboardButton(
text: String,
request_users: Option(KeyboardButtonRequestUsers),
request_chat: Option(KeyboardButtonRequestChat),
request_contact: Option(Bool),
request_location: Option(Bool),
request_poll: Option(KeyboardButtonPollType),
web_app: Option(WebAppInfo),
)
}
Constructors
-
KeyboardButton( text: String, request_users: Option(KeyboardButtonRequestUsers), request_chat: Option(KeyboardButtonRequestChat), request_contact: Option(Bool), request_location: Option(Bool), request_poll: Option(KeyboardButtonPollType), web_app: Option(WebAppInfo), )
This object represents one button of the reply keyboard. For simple text buttons, String can be used instead of this object to specify the button text. The optional fields web_app, request_users, request_chat, request_contact, request_location, and request_poll are mutually exclusive.
Official reference: https://core.telegram.org/bots/api#keyboardbutton
Arguments
-
text
Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed
-
request_users
If specified, pressing the button will open a list of suitable users. Identifiers of selected users will be sent to the bot in a “users_shared” service message. Available in private chats only.
-
request_chat
If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. Available in private chats only.
-
request_contact
If True, the user’s phone number will be sent as a contact when the button is pressed. Available in private chats only.
-
request_location
If True, the user’s current location will be sent when the button is pressed. Available in private chats only.
-
request_poll
If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only.
-
web_app
If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private chats only.
-
pub type KeyboardButtonPollType {
KeyboardButtonPollType(poll_type: Option(String))
}
Constructors
-
KeyboardButtonPollType(poll_type: Option(String))
This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed.
Official reference: https://core.telegram.org/bots/api#keyboardbuttonpolltype
Arguments
-
poll_type
If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type.
Official reference: https://core.telegram.org/bots/api#polltype
Note: This type is a wrapper around the official type. The official field name is
type
.
-
pub type KeyboardButtonRequestChat {
KeyboardButtonRequestChat(
request_id: Int,
chat_is_channel: Bool,
chat_is_forum: Option(Bool),
chat_has_username: Option(Bool),
chat_is_created: Option(Bool),
user_administrator_rights: Option(ChatAdministratorRights),
bot_administrator_rights: Option(ChatAdministratorRights),
bot_is_member: Option(Bool),
request_title: Option(Bool),
request_username: Option(Bool),
request_photo: Option(Bool),
)
}
Constructors
-
KeyboardButtonRequestChat( request_id: Int, chat_is_channel: Bool, chat_is_forum: Option(Bool), chat_has_username: Option(Bool), chat_is_created: Option(Bool), user_administrator_rights: Option(ChatAdministratorRights), bot_administrator_rights: Option(ChatAdministratorRights), bot_is_member: Option(Bool), request_title: Option(Bool), request_username: Option(Bool), request_photo: Option(Bool), )
This object defines the criteria used to request a suitable chat. Information about the selected chat will be shared with the bot when the corresponding button is pressed. The bot will be granted requested rights in the сhat if appropriate
Official reference: https://core.telegram.org/bots/api#keyboardbuttonrequestchat
Arguments
-
request_id
Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message
-
chat_is_channel
Pass True to request a channel chat, pass False to request a group or a supergroup chat.
-
chat_is_forum
Pass True to request a forum supergroup, pass False to request a non-forum chat. If not specified, no additional restrictions are applied.
-
chat_has_username
Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. If not specified, no additional restrictions are applied.
-
chat_is_created
Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied.
-
user_administrator_rights
A JSON-serialized object listing the required administrator rights of the user in the chat. The rights must be a superset of bot_administrator_rights. If not specified, no additional restrictions are applied.
-
bot_administrator_rights
A JSON-serialized object listing the required administrator rights of the bot in the chat. The rights must be a subset of user_administrator_rights. If not specified, no additional restrictions are applied.
-
bot_is_member
Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied.
-
request_title
Pass True to request the chat’s title
-
request_username
Pass True to request the chat’s username
-
request_photo
Pass True to request the chat’s photo
-
pub type KeyboardButtonRequestUsers {
KeyboardButtonRequestUsers(
request_id: Int,
user_is_bot: Option(Bool),
user_is_premium: Option(Bool),
max_quantity: Option(Int),
request_name: Option(Bool),
request_username: Option(Bool),
request_photo: Option(Bool),
)
}
Constructors
-
KeyboardButtonRequestUsers( request_id: Int, user_is_bot: Option(Bool), user_is_premium: Option(Bool), max_quantity: Option(Int), request_name: Option(Bool), request_username: Option(Bool), request_photo: Option(Bool), )
This object defines the criteria used to request suitable users. Information about the selected users will be shared with the bot when the corresponding button is pressed.
Official reference: https://core.telegram.org/bots/api#keyboardbuttonrequestusers
Arguments
-
request_id
Signed 32-bit identifier of the request that will be received back in the UsersShared object. Must be unique within the message
-
user_is_bot
Pass True to request bots, pass False to request regular users. If not specified, no additional restrictions are applied.
-
user_is_premium
Pass True to request premium users, pass False to request non-premium users. If not specified, no additional restrictions are applied.
-
max_quantity
The maximum number of users to be selected; 1-10. Defaults to 1.
-
request_name
Pass True to request the users’ first and last name
-
request_username
Pass True to request the users’ username
-
request_photo
Pass True to request the users’ photo
-
pub type LinkPreviewOptions {
LinkPreviewOptions(
is_disabled: Option(Bool),
url: Option(String),
prefer_small_media: Option(Bool),
prefer_large_media: Option(Bool),
show_above_text: Option(Bool),
)
}
Constructors
-
LinkPreviewOptions( is_disabled: Option(Bool), url: Option(String), prefer_small_media: Option(Bool), prefer_large_media: Option(Bool), show_above_text: Option(Bool), )
Describes the options used for link preview generation.
Official reference: LinkPreviewOptions
Arguments
-
is_disabled
True, if the link preview is disabled
-
url
URL to use for the link preview. If empty, then the first URL found in the message text will be used
-
prefer_small_media
True, if the media in the link preview is supposed to be shrunk; ignored if the URL isn’t explicitly specified or media size change isn’t supported for the preview
-
prefer_large_media
True, if the media in the link preview is supposed to be enlarged; ignored if the URL isn’t explicitly specified or media size change isn’t supported for the preview
-
show_above_text
True, if the link preview must be shown above the message text; otherwise, the link preview will be shown below the message text
-
pub type LoginUrl {
LoginUrl(
url: String,
forward_text: Option(String),
bot_username: Option(String),
request_write_access: Option(Bool),
)
}
Constructors
-
LoginUrl( url: String, forward_text: Option(String), bot_username: Option(String), request_write_access: Option(Bool), )
This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in.
Arguments
-
url
An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data.
NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization.
-
forward_text
New text of the button in forwarded messages.
-
bot_username
Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot’s username will be assumed. The url’s domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details.
-
request_write_access
Pass True to request the permission for your bot to send messages to the user.
-
This object describes a message that can be inaccessible to the bot.
Official reference: MaybeInaccessibleMessage
pub type MaybeInaccessibleMessage {
MaybeInaccessibleMessageMessage(Message)
MaybeInaccessibleMessageInaccessible(InaccessibleMessage)
}
Constructors
-
MaybeInaccessibleMessageMessage(Message)
-
MaybeInaccessibleMessageInaccessible(InaccessibleMessage)
pub type Message {
Message(
message_id: Int,
message_thread_id: Option(Int),
from: Option(User),
sender_chat: Option(Chat),
sender_boost_count: Option(Int),
date: Int,
chat: Chat,
is_topic_message: Option(Bool),
is_automatic_forward: Option(Bool),
reply_to_message: Option(Message),
via_bot: Option(User),
edit_date: Option(Int),
has_protected_content: Option(Bool),
is_from_offline: Option(Bool),
media_group_id: Option(String),
author_signature: Option(String),
text: Option(String),
entities: Option(List(MessageEntity)),
caption: Option(String),
caption_entities: Option(List(MessageEntity)),
has_media_spoiler: Option(Bool),
new_chat_members: Option(List(User)),
left_chat_member: Option(User),
new_chat_title: Option(String),
delete_chat_photo: Option(Bool),
group_chat_created: Option(Bool),
supergroup_chat_created: Option(Bool),
channel_chat_created: Option(Bool),
migrate_to_chat_id: Option(Int),
migrate_from_chat_id: Option(Int),
connected_website: Option(String),
web_app_data: Option(WebAppData),
reply_markup: Option(InlineKeyboardMarkup),
)
}
Constructors
-
Message( message_id: Int, message_thread_id: Option(Int), from: Option(User), sender_chat: Option(Chat), sender_boost_count: Option(Int), date: Int, chat: Chat, is_topic_message: Option(Bool), is_automatic_forward: Option(Bool), reply_to_message: Option(Message), via_bot: Option(User), edit_date: Option(Int), has_protected_content: Option(Bool), is_from_offline: Option(Bool), media_group_id: Option(String), author_signature: Option(String), text: Option(String), entities: Option(List(MessageEntity)), caption: Option(String), caption_entities: Option(List(MessageEntity)), has_media_spoiler: Option(Bool), new_chat_members: Option(List(User)), left_chat_member: Option(User), new_chat_title: Option(String), delete_chat_photo: Option(Bool), group_chat_created: Option(Bool), supergroup_chat_created: Option(Bool), channel_chat_created: Option(Bool), migrate_to_chat_id: Option(Int), migrate_from_chat_id: Option(Int), connected_website: Option(String), web_app_data: Option(WebAppData), reply_markup: Option(InlineKeyboardMarkup), )
Official reference: https://core.telegram.org/bots/api#message
Arguments
-
message_id
Unique message identifier inside this chat
-
message_thread_id
Unique identifier of a message thread to which the message belongs; for supergroups only
-
from
Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
-
sender_chat
Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
-
sender_boost_count
If the sender of the message boosted the chat, the number of boosts added by the user
-
date
Date the message was sent in Unix time. It is always a positive number, representing a valid date.
-
chat
Chat the message belongs to
-
is_topic_message
True, if the message is sent to a forum topic
-
is_automatic_forward
True, if the message is a channel post that was automatically forwarded to the connected discussion group
-
reply_to_message
For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
-
edit_date
Date the message was last edited in Unix time
-
has_protected_content
True, if the message can’t be forwarded
-
is_from_offline
True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message
-
media_group_id
The unique identifier of a media message group this message belongs to
-
author_signature
Signature of the post author for messages in channels, or the custom title of an anonymous group administrator
-
text
For text messages, the actual UTF-8 text of the message
-
entities
For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
-
caption_entities
For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
-
has_media_spoiler
True, if the message media is covered by a spoiler animation
-
new_chat_members
New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
-
left_chat_member
A member was removed from the group, information about them (this member may be the bot itself)
-
new_chat_title
A chat title was changed to this value
-
delete_chat_photo
Service message: the chat photo was deleted
-
group_chat_created
Service message: the group has been created
-
supergroup_chat_created
Service message: the supergroup has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.
-
channel_chat_created
Service message: the channel has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.
-
migrate_to_chat_id
The group has been migrated to a supergroup with the specified identifier.
-
migrate_from_chat_id
The supergroup has been migrated from a group with the specified identifier.
-
connected_website
The domain name of the website on which the user has logged in. More about Telegram Login >>
-
reply_markup
Inline keyboard attached to the message.
login_url
buttons are represented as ordinaryurl
buttons.
-
pub type MessageEntity {
MessageEntity(
entity_type: String,
offset: Int,
length: Int,
url: Option(String),
user: Option(User),
language: Option(String),
custom_emoji_id: Option(String),
)
}
Constructors
-
MessageEntity( entity_type: String, offset: Int, length: Int, url: Option(String), user: Option(User), language: Option(String), custom_emoji_id: Option(String), )
Official reference: https://core.telegram.org/bots/api#messageentity
Arguments
-
entity_type
Type of the entity. Currently, can be “mention” (
@username
), “hashtag” (#hashtag
), “cashtag” ($USD
), “bot_command” (/start@jobs_bot
), “url” (https://telegram.org
), “email” (do-not-reply@telegram.org
), “phone_number” (+1-212-555-0123
), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers) -
offset
Offset in UTF-16 code units to the start of the entity
-
length
Length of the entity in UTF-16 code units
-
url
For “text_link” only, URL that will be opened after user taps on the text
-
user
For “text_mention” only, the mentioned user
-
language
For “pre” only, the programming language of the entity text
-
custom_emoji_id
For “custom_emoji” only, unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker
-
pub type ReplyMarkup {
ReplyInlineKeyboardMarkup(
inline_keyboard: List(List(InlineKeyboardButton)),
)
ReplyKeyboardMarkup(
keyboard: List(List(KeyboardButton)),
is_persistent: Option(Bool),
resize_keyboard: Option(Bool),
one_time_keyboard: Option(Bool),
input_field_placeholder: Option(String),
selective: Option(Bool),
)
ReplyKeyboardRemove(
remove_keyboard: Bool,
selective: Option(Bool),
)
ForceReply(
force_reply: Bool,
input_field_placeholder: String,
selective: Bool,
)
}
Constructors
-
ReplyInlineKeyboardMarkup( inline_keyboard: List(List(InlineKeyboardButton)), )
This object represents an inline keyboard that appears right next to the message it belongs to.
Official reference: https://core.telegram.org/bots/api#inlinekeyboardmarkup
Arguments
-
inline_keyboard
List of button rows, each represented by an List of InlineKeyboardButton objects
-
-
ReplyKeyboardMarkup( keyboard: List(List(KeyboardButton)), is_persistent: Option(Bool), resize_keyboard: Option(Bool), one_time_keyboard: Option(Bool), input_field_placeholder: Option(String), selective: Option(Bool), )
This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
Official reference: https://core.telegram.org/bots/api#replykeyboardmarkup
Arguments
-
keyboard
Array of button rows, each represented by an Array of KeyboardButton objects
-
is_persistent
Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon.
-
resize_keyboard
Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app’s standard keyboard.
-
one_time_keyboard
Requests clients to hide the keyboard as soon as it’s been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat - the user can press a special button in the input field to see the custom keyboard again. Defaults to false.
-
input_field_placeholder
The placeholder to be shown in the input field when the keyboard is active; 1-64 characters
-
selective
Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply to a message in the same chat and forum topic, sender of the original message.
Example: A user requests to change the bot’s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.
-
-
ReplyKeyboardRemove( remove_keyboard: Bool, selective: Option(Bool), )
Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup).
Official reference: https://core.telegram.org/bots/api#replykeyboardremove
Arguments
-
remove_keyboard
Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup)
-
selective
Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply to a message in the same chat and forum topic, sender of the original message.
Example: A user requests to change the bot’s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.
-
-
ForceReply( force_reply: Bool, input_field_placeholder: String, selective: Bool, )
Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot’s message and tapped ‘Reply’). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
Official reference: https://core.telegram.org/bots/api#forcereply
Arguments
-
force_reply
Shows reply interface to the user, as if they manually selected the bot’s message and tapped ‘Reply’
-
input_field_placeholder
The placeholder to be shown in the input field when the reply is active; 1-64 characters
-
selective
Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply to a message in the same chat and forum topic, sender of the original message.
-
pub type ReplyParameters {
ReplyParameters(
message_id: Int,
chat_id: Option(IntOrString),
allow_sending_without_reply: Option(Bool),
quote: Option(String),
quote_parse_mode: Option(String),
quote_entities: Option(List(MessageEntity)),
quote_position: Option(Int),
)
}
Constructors
-
ReplyParameters( message_id: Int, chat_id: Option(IntOrString), allow_sending_without_reply: Option(Bool), quote: Option(String), quote_parse_mode: Option(String), quote_entities: Option(List(MessageEntity)), quote_position: Option(Int), )
Describes reply parameters for the message that is being sent.
Official reference: https://core.telegram.org/bots/api#replyparameters
Arguments
-
message_id
Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specified
-
chat_id
If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format
@channelusername
) -
allow_sending_without_reply
Pass True if the message should be sent even if the specified message to be replied to is not found; can be used only for replies in the same chat and forum topic.
-
quote
Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, and custom_emoji entities. The message will fail to send if the quote isn’t found in the original message.
-
quote_parse_mode
Mode for parsing entities in the quote. See formatting options for more details.
-
quote_entities
A JSON-serialized list of special entities that appear in the quote. It can be specified instead of quote_parse_mode.
-
quote_position
Position of the quote in the original message in UTF-16 code units
-
pub type SendDiceParameters {
SendDiceParameters(
chat_id: IntOrString,
message_thread_id: Option(Int),
emoji: Option(String),
disable_notification: Option(Bool),
protect_content: Option(Bool),
reply_parameters: Option(ReplyParameters),
)
}
Constructors
-
SendDiceParameters( chat_id: IntOrString, message_thread_id: Option(Int), emoji: Option(String), disable_notification: Option(Bool), protect_content: Option(Bool), reply_parameters: Option(ReplyParameters), )
Arguments
-
message_thread_id
Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
-
emoji
Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”
-
disable_notification
Sends the message silently. Users will receive a notification with no sound.
-
protect_content
Protects the contents of the sent message from forwarding
-
reply_parameters
Description of the message to reply to
-
pub type SendMessageParameters {
SendMessageParameters(
business_connection_id: Option(String),
chat_id: IntOrString,
message_thread_id: Option(Int),
text: String,
parse_mode: Option(String),
entities: Option(List(MessageEntity)),
link_preview_options: Option(LinkPreviewOptions),
disable_notification: Option(Bool),
protect_content: Option(Bool),
reply_parameters: Option(ReplyParameters),
reply_markup: Option(ReplyMarkup),
)
}
Constructors
-
SendMessageParameters( business_connection_id: Option(String), chat_id: IntOrString, message_thread_id: Option(Int), text: String, parse_mode: Option(String), entities: Option(List(MessageEntity)), link_preview_options: Option(LinkPreviewOptions), disable_notification: Option(Bool), protect_content: Option(Bool), reply_parameters: Option(ReplyParameters), reply_markup: Option(ReplyMarkup), )
Parameters to send using the sendMessage method
Arguments
-
business_connection_id
Unique identifier of the business connection on behalf of which the message will be sent
-
chat_id
Unique identifier for the target chat or username of the target channel (in the format
@channelusername
) -
message_thread_id
Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
-
text
Text of the message to be sent, 1-4096 characters after entities parsing
-
parse_mode
Mode for parsing entities in the message text. See formatting options for more details.
-
entities
A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
-
link_preview_options
Link preview generation options for the message
-
disable_notification
Sends the message silently. Users will receive a notification with no sound.
-
protect_content
Protects the contents of the sent message from forwarding and saving
-
reply_parameters
Description of the message to reply to
-
reply_markup
Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account
-
pub type SwitchInlineQueryChosenChat {
SwitchInlineQueryChosenChat(
query: Option(String),
allow_user_chats: Option(Bool),
allow_bot_chats: Option(Bool),
allow_group_chats: Option(Bool),
allow_channel_chats: Option(Bool),
)
}
Constructors
-
SwitchInlineQueryChosenChat( query: Option(String), allow_user_chats: Option(Bool), allow_bot_chats: Option(Bool), allow_group_chats: Option(Bool), allow_channel_chats: Option(Bool), )
This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.
Arguments
-
query
The default inline query to be inserted in the input field. If left empty, only the bot’s username will be inserted
-
allow_user_chats
True, if private chats with users can be chosen
-
allow_bot_chats
True, if private chats with bots can be chosen
-
allow_group_chats
True, if group and supergroup chats can be chosen
-
allow_channel_chats
True, if channel chats can be chosen
-
pub type Update {
Update(
update_id: Int,
message: Option(Message),
edited_message: Option(Message),
callback_query: Option(CallbackQuery),
)
}
Constructors
-
Update( update_id: Int, message: Option(Message), edited_message: Option(Message), callback_query: Option(CallbackQuery), )
Official reference: https://core.telegram.org/bots/api#update
Arguments
-
update_id
The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This identifier becomes especially handy if you’re using webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.
-
message
New incoming message of any kind - text, photo, sticker, etc.
-
edited_message
New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.
-
callback_query
New incoming callback query
-
pub type User {
User(
id: Int,
is_bot: Bool,
first_name: String,
last_name: Option(String),
username: Option(String),
language_code: Option(String),
is_premium: Option(Bool),
added_to_attachment_menu: Option(Bool),
)
}
Constructors
-
User( id: Int, is_bot: Bool, first_name: String, last_name: Option(String), username: Option(String), language_code: Option(String), is_premium: Option(Bool), added_to_attachment_menu: Option(Bool), )
Official reference: https://core.telegram.org/bots/api#user
Arguments
-
id
Unique identifier for this user or bot.
-
first_name
User’s or bot’s first name
-
last_name
User’s or bot’s last name
-
username
Username, for private chats, supergroups and channels if available
-
language_code
IETF language tag of the user’s language
-
is_premium
True, if this user is a Telegram Premium user
-
added_to_attachment_menu
True, if this user added the bot to the attachment menu
-
pub type WebAppData {
WebAppData(data: String, button_text: String)
}
Constructors
-
WebAppData(data: String, button_text: String)
Describes data sent from a Web App to the bot.
Arguments
-
data
The data. Be aware that a bad client can send arbitrary data in this field.
-
button_text
Text of the web_app keyboard button from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field.
-
pub type WebAppInfo {
WebAppInfo(url: String)
}
Constructors
-
WebAppInfo(url: String)
Describes a Web App.
Official reference: WebAppInfo
Arguments
-
url
An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps
-
pub type WebhookInfo {
WebhookInfo(
url: String,
has_custom_certificate: Bool,
pending_update_count: Int,
ip_address: Option(String),
last_error_date: Option(Int),
last_error_message: Option(String),
last_synchronization_error_date: Option(Int),
max_connections: Option(Int),
allowed_updates: Option(List(String)),
)
}
Constructors
-
WebhookInfo( url: String, has_custom_certificate: Bool, pending_update_count: Int, ip_address: Option(String), last_error_date: Option(Int), last_error_message: Option(String), last_synchronization_error_date: Option(Int), max_connections: Option(Int), allowed_updates: Option(List(String)), )
Describes the current status of a webhook.
Official reference: WebhookInfo
Arguments
-
url
Webhook URL, may be empty if webhook is not set up
-
has_custom_certificate
True, if a custom certificate was provided for webhook certificate checks
-
pending_update_count
Number of updates awaiting delivery
-
ip_address
Currently used webhook IP address
-
last_error_date
Unix time for the most recent error that happened when trying to deliver an update via webhook
-
last_error_message
Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook
-
last_synchronization_error_date
Maximum allowed payload size for incoming update
-
max_connections
Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
-
allowed_updates
A list of update types the bot is subscribed to. Defaults to all update types
-
Functions
pub fn bot_command_scope_to_json(scope: BotCommandScope) -> Json
pub fn bot_commands_from(
commands: List(#(String, String)),
) -> List(BotCommand)
pub fn decode_bot_command(
json: Dynamic,
) -> Result(List(BotCommand), List(DecodeError))
pub fn decode_callback_query(
json: Dynamic,
) -> Result(CallbackQuery, List(DecodeError))
pub fn decode_edit_message_text_result(
json: Dynamic,
) -> Result(EditMessageTextResult, List(DecodeError))
pub fn decode_inaccessible_message(
json: Dynamic,
) -> Result(InaccessibleMessage, List(DecodeError))
pub fn decode_inline_button(
json: Dynamic,
) -> Result(InlineKeyboardButton, List(DecodeError))
pub fn decode_inline_markup(
json: Dynamic,
) -> Result(InlineKeyboardMarkup, List(DecodeError))
pub fn decode_keyboard_button_request_users(
json: Dynamic,
) -> Result(KeyboardButtonRequestUsers, List(DecodeError))
pub fn decode_login_url(
json: Dynamic,
) -> Result(LoginUrl, List(DecodeError))
pub fn decode_maybe_inaccessible_message(
json: Dynamic,
) -> Result(MaybeInaccessibleMessage, List(DecodeError))
pub fn decode_message(
json: Dynamic,
) -> Result(Message, List(DecodeError))
pub fn decode_message_entity(
json: Dynamic,
) -> Result(MessageEntity, List(DecodeError))
pub fn decode_switch_inline_query_chosen_chat(
json: Dynamic,
) -> Result(SwitchInlineQueryChosenChat, List(DecodeError))
pub fn decode_update(
json: Dynamic,
) -> Result(Update, List(DecodeError))
Decode a message from the Telegram API.
pub fn decode_user(
json: Dynamic,
) -> Result(User, List(DecodeError))
pub fn decode_web_app_data(
json: Dynamic,
) -> Result(WebAppData, List(DecodeError))
pub fn decode_web_app_info(
json: Dynamic,
) -> Result(WebAppInfo, List(DecodeError))
pub fn decode_webhook_info(
json: Dynamic,
) -> Result(WebhookInfo, List(DecodeError))
pub fn default_botcommand_parameters() -> BotCommandParameters
pub fn default_edit_message_text_parameters() -> EditMessageTextParameters
pub fn encode_answer_callback_query_parameters(
params: AnswerCallbackQueryParameters,
) -> Json
pub fn encode_botcommand_parameters(
params: BotCommandParameters,
) -> List(#(String, Json))
pub fn encode_chat_administrator_rights(
chat_administrator_rights: ChatAdministratorRights,
) -> Json
pub fn encode_edit_message_text_parameters(
params: EditMessageTextParameters,
) -> Json
pub fn encode_inline_keyboard_button(
inline_keyboard_button: InlineKeyboardButton,
) -> Json
pub fn encode_inline_keyboard_markup(
inline_keyboard_markup: InlineKeyboardMarkup,
) -> Json
pub fn encode_keyboard_button(
keyboard_button: KeyboardButton,
) -> Json
pub fn encode_keyboard_button_poll_type(
keyboard_button_poll_type: KeyboardButtonPollType,
) -> Json
pub fn encode_keyboard_button_request_chat(
keyboard_button_request_chat: KeyboardButtonRequestChat,
) -> Json
pub fn encode_keyboard_button_request_users(
keyboard_button_request_users: KeyboardButtonRequestUsers,
) -> Json
pub fn encode_link_preview_options(
link_preview_options: LinkPreviewOptions,
) -> Json
pub fn encode_login_url(login_url: LoginUrl) -> Json
pub fn encode_message_entity(
message_entity: MessageEntity,
) -> Json
pub fn encode_reply_markup(reply_markup: ReplyMarkup) -> Json
pub fn encode_reply_parameters(
reply_parameters: ReplyParameters,
) -> Json
pub fn encode_send_dice_parameters(
params: SendDiceParameters,
) -> Json
pub fn encode_send_message_parameters(
send_message_parameters: SendMessageParameters,
) -> Json
pub fn encode_switch_inline_query_chosen_chat(
switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat,
) -> Json
pub fn encode_user(user: User) -> Json
pub fn encode_web_app_info(info: WebAppInfo) -> Json
pub fn new_answer_callback_query_parameters(
callback_query_id: String,
) -> AnswerCallbackQueryParameters
pub fn new_send_dice_parameters(
chat_id chat_id: IntOrString,
) -> SendDiceParameters
pub fn new_send_message_parameters(
chat_id chat_id: IntOrString,
text text: String,
) -> SendMessageParameters
pub fn set_send_message_parameters_reply_markup(
params: SendMessageParameters,
reply_markup: ReplyMarkup,
) -> SendMessageParameters