Types of API¶
- class telebot.types.Animation(file_id, file_unique_id, width=None, height=None, duration=None, thumbnail=None, file_name=None, mime_type=None, file_size=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
Telegram Documentation: https://core.telegram.org/bots/api#animation
- Parameters:
file_id (
str
) – Identifier for this file, which can be used to download or reuse the filefile_unique_id (
str
) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.width (
int
) – Video width as defined by senderheight (
int
) – Video height as defined by senderduration (
int
) – Duration of the video in seconds as defined by senderthumbnail (
telebot.types.PhotoSize
) – Optional. Animation thumbnail as defined by senderfile_name (
str
) – Optional. Original animation filename as defined by sendermime_type (
str
) – Optional. MIME type of the file as defined by senderfile_size (
int
) – Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
- Returns:
Instance of the class
- Return type:
- class telebot.types.Audio(file_id, file_unique_id, duration, performer=None, title=None, file_name=None, mime_type=None, file_size=None, thumbnail=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents an audio file to be treated as music by the Telegram clients.
Telegram Documentation: https://core.telegram.org/bots/api#audio
- Parameters:
file_id (
str
) – Identifier for this file, which can be used to download or reuse the filefile_unique_id (
str
) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.duration (
int
) – Duration of the audio in seconds as defined by senderperformer (
str
) – Optional. Performer of the audio as defined by sender or by audio tagstitle (
str
) – Optional. Title of the audio as defined by sender or by audio tagsfile_name (
str
) – Optional. Original filename as defined by sendermime_type (
str
) – Optional. MIME type of the file as defined by senderfile_size (
int
) – Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.thumbnail (
telebot.types.PhotoSize
) – Optional. Thumbnail of the album cover to which the music file belongs
- Returns:
Instance of the class
- Return type:
- class telebot.types.BackgroundFill¶
Bases:
ABC
,JsonDeserializable
- This object describes the way a background is filled based on the selected colors. Currently, it can be one of
BackgroundFillSolid BackgroundFillGradient BackgroundFillFreeformGradient
Telegram documentation: https://core.telegram.org/bots/api#backgroundfill
- Returns:
Instance of the class
- Return type:
BackgroundFillSolid
orBackgroundFillGradient
orBackgroundFillFreeformGradient
- class telebot.types.BackgroundFillFreeformGradient(type, colors, **kwargs)¶
Bases:
BackgroundFill
The background is a freeform gradient that rotates after every message in the chat.
Telegram documentation: https://core.telegram.org/bots/api#backgroundfillfreeformgradient
- Parameters:
type (
str
) – Type of the background fill, always “freeform_gradient”colors (
list
ofint
) – A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format
- Returns:
Instance of the class
- Return type:
- class telebot.types.BackgroundFillGradient(type, top_color, bottom_color, rotation_angle, **kwargs)¶
Bases:
BackgroundFill
The background is a gradient fill.
Telegram documentation: https://core.telegram.org/bots/api#backgroundfillgradient
- Parameters:
type (
str
) – Type of the background fill, always “gradient”top_color (
int
) – Top color of the gradient in the RGB24 formatbottom_color (
int
) – Bottom color of the gradient in the RGB24 formatrotation_angle (
int
) – Clockwise rotation angle of the background fill in degrees; 0-359
- Returns:
Instance of the class
- Return type:
- class telebot.types.BackgroundFillSolid(type, color, **kwargs)¶
Bases:
BackgroundFill
The background is filled using the selected color.
Telegram documentation: https://core.telegram.org/bots/api#backgroundfillsolid
- Parameters:
type (
str
) – Type of the background fill, always “solid”color (
int
) – The color of the background fill in the RGB24 format
- Returns:
Instance of the class
- Return type:
- class telebot.types.BackgroundType¶
Bases:
ABC
,JsonDeserializable
- This object describes the type of a background. Currently, it can be one of
BackgroundTypeFill BackgroundTypeWallpaper BackgroundTypePattern BackgroundTypeChatTheme
Telegram documentation: https://core.telegram.org/bots/api#backgroundtype
- Returns:
Instance of the class
- Return type:
BackgroundTypeFill
orBackgroundTypeWallpaper
orBackgroundTypePattern
orBackgroundTypeChatTheme
- class telebot.types.BackgroundTypeChatTheme(type, theme_name, **kwargs)¶
Bases:
BackgroundFill
The background is taken directly from a built-in chat theme.
Telegram documentation: https://core.telegram.org/bots/api#backgroundtypechattheme
- Parameters:
type (
str
) – Type of the background, always “chat_theme”theme_name (
str
) – Intensity of the pattern when it is shown above the filled background; 0-100
- Returns:
Instance of the class
- Return type:
- class telebot.types.BackgroundTypeFill(type, fill, dark_theme_dimming, **kwargs)¶
Bases:
BackgroundFill
The background is automatically filled based on the selected colors.
Telegram documentation: https://core.telegram.org/bots/api#backgroundtypefill
- Parameters:
type (
str
) – Type of the background, always “fill”fill (
BackgroundFill
) – The background filldark_theme_dimming (
int
) – Dimming of the background in dark themes, as a percentage; 0-100
- Returns:
Instance of the class
- Return type:
- class telebot.types.BackgroundTypePattern(type, document, fill, intensity, is_inverted=None, is_moving=None, **kwargs)¶
Bases:
BackgroundFill
The background is a wallpaper in the JPEG format.
Telegram documentation: https://core.telegram.org/bots/api#backgroundtypepattern
- Parameters:
type (
str
) – Type of the background, always “pattern”document (
Document
) – Document with the patternfill (
BackgroundFill
) – The background fill that is combined with the patternintensity (
int
) – Intensity of the pattern when it is shown above the filled background; 0-100is_inverted (
bool
) – Optional. True, if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes onlyis_moving (
bool
) – Optional. True, if the background moves slightly when the device is tilted
- Returns:
Instance of the class
- Return type:
- class telebot.types.BackgroundTypeWallpaper(type, document, dark_theme_dimming, is_blurred=None, is_moving=None, **kwargs)¶
Bases:
BackgroundFill
The background is a wallpaper in the JPEG format.
Telegram documentation: https://core.telegram.org/bots/api#backgroundtypewallpaper
- Parameters:
type (
str
) – Type of the background, always “wallpaper”document (
Document
) – Document with the wallpaperdark_theme_dimming (
int
) – Dimming of the background in dark themes, as a percentage; 0-100is_blurred (
bool
) – Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12is_moving (
bool
) – Optional. True, if the background moves slightly when the device is tilted
- Returns:
Instance of the class
- Return type:
- class telebot.types.Birthdate(day, month, year=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a user’s birthdate.
Telegram documentation: https://core.telegram.org/bots/api#birthdate
- Parameters:
day (
int
) – Day of the user’s birth; 1-31month (
int
) – Month of the user’s birth; 1-12year (
int
) – Optional. Year of the user’s birth
- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommand(command, description, **kwargs)¶
Bases:
JsonSerializable
,JsonDeserializable
,Dictionaryable
This object represents a bot command.
Telegram Documentation: https://core.telegram.org/bots/api#botcommand
- Parameters:
command (
str
) – Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.description (
str
) – Description of the command; 1-256 characters.
- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommandScope(type='default', chat_id=None, user_id=None)¶
Bases:
ABC
,JsonSerializable
This object represents the scope to which bot commands are applied. Currently, the following 7 scopes are supported:
Determining list of commands The following algorithm is used to determine the list of commands for a particular user viewing the bot menu. The first list of commands which is set is returned:
Commands in the chat with the bot:
BotCommandScopeChat
+ language_codeBotCommandScopeAllPrivateChats
+ language_codeBotCommandScopeDefault
+ language_code
Commands in group and supergroup chats:
BotCommandScopeChatMember
+ language_codeBotCommandScopeChatAdministrators
+ language_code (administrators only)BotCommandScopeChatAdministrators
(administrators only)BotCommandScopeChat
+ language_codeBotCommandScopeAllChatAdministrators
+ language_code (administrators only)BotCommandScopeAllChatAdministrators
(administrators only)BotCommandScopeAllGroupChats
+ language_codeBotCommandScopeDefault
+ language_code
- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommandScopeAllChatAdministrators¶
Bases:
BotCommandScope
Represents the scope of bot commands, covering all group and supergroup chat administrators.
Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallchatadministrators
- Parameters:
type (
str
) – Scope type, must be all_chat_administrators- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommandScopeAllGroupChats¶
Bases:
BotCommandScope
Represents the scope of bot commands, covering all group and supergroup chats.
Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallgroupchats
- Parameters:
type (
str
) – Scope type, must be all_group_chats- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommandScopeAllPrivateChats¶
Bases:
BotCommandScope
Represents the scope of bot commands, covering all private chats.
Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopeallprivatechats
- Parameters:
type (
str
) – Scope type, must be all_private_chats- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommandScopeChat(chat_id: int | str | None = None)¶
Bases:
BotCommandScope
Represents the scope of bot commands, covering a specific chat.
Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopechat
- Parameters:
type (
str
) – Scope type, must be chatchat_id (
int
orstr
) – Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommandScopeChatAdministrators(chat_id: int | str | None = None)¶
Bases:
BotCommandScope
Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopechatadministrators
- Parameters:
type (
str
) – Scope type, must be chat_administratorschat_id (
int
orstr
) – Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommandScopeChatMember(chat_id: int | str | None = None, user_id: int | str | None = None)¶
Bases:
BotCommandScope
Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopechatmember
- Parameters:
type (
str
) – Scope type, must be chat_memberchat_id (
int
orstr
) – Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)user_id (
int
) – Unique identifier of the target user
- Returns:
Instance of the class
- Return type:
- class telebot.types.BotCommandScopeDefault¶
Bases:
BotCommandScope
Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user.
Telegram Documentation: https://core.telegram.org/bots/api#botcommandscopedefault
- Parameters:
type (
str
) – Scope type, must be default- Returns:
Instance of the class
- Return type:
- class telebot.types.BotDescription(description: str, **kwargs)¶
Bases:
JsonDeserializable
This object represents a bot description.
Telegram documentation: https://core.telegram.org/bots/api#botdescription
- Parameters:
description (
str
) – Bot description- Returns:
Instance of the class
- Return type:
- class telebot.types.BotName(name: str, **kwargs)¶
Bases:
JsonDeserializable
This object represents a bot name.
Telegram Documentation: https://core.telegram.org/bots/api#botname
- Parameters:
name (
str
) – The bot name- Returns:
Instance of the class
- Return type:
- class telebot.types.BotShortDescription(short_description: str, **kwargs)¶
Bases:
JsonDeserializable
This object represents a bot short description.
Telegram documentation: https://core.telegram.org/bots/api#botshortdescription
- Parameters:
short_description (
str
) – Bot short description- Returns:
Instance of the class
- Return type:
- class telebot.types.BusinessConnection(id, user, user_chat_id, date, can_reply, is_enabled, **kwargs)¶
Bases:
JsonDeserializable
This object describes the connection of the bot with a business account.
Telegram documentation: https://core.telegram.org/bots/api#businessconnection
- Parameters:
id (
str
) – Unique identifier of the business connectionuser (
User
) – Business account user that created the business connectionuser_chat_id (
int
) – Identifier of a private chat with the user who created the business connectiondate (
int
) – Date the connection was established in Unix timecan_reply (
bool
) – True, if the bot can act on behalf of the business account in chats that were active in the last 24 hoursis_enabled (
bool
) – True, if the connection is active
- Returns:
Instance of the class
- Return type:
- class telebot.types.BusinessIntro(title=None, message=None, sticker=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a business intro.
Telegram documentation: https://core.telegram.org/bots/api#businessintro
- Parameters:
title (
str
) – Optional. Title text of the business intromessage (
str
) – Optional. Message text of the business introsticker (
Sticker
) – Optional. Sticker of the business intro
- Returns:
Instance of the class
- Return type:
- class telebot.types.BusinessLocation(address, location=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a business location.
Telegram documentation: https://core.telegram.org/bots/api#businesslocation
- Parameters:
address (
str
) – Address of the businesslocation (
Location
) – Optional. Location of the business
- Returns:
Instance of the class
- Return type:
- class telebot.types.BusinessMessagesDeleted(business_connection_id, chat, message_ids, **kwargs)¶
Bases:
JsonDeserializable
This object is received when messages are deleted from a connected business account.
Telegram documentation: https://core.telegram.org/bots/api#businessmessagesdeleted
- Parameters:
business_connection_id (
str
) – Unique identifier of the business connectionchat (
Chat
) – Information about a chat in the business account. The bot may not have access to the chat or the corresponding user.message_ids (
list
ofint
) – A JSON-serialized list of identifiers of deleted messages in the chat of the business account
- Returns:
Instance of the class
- Return type:
- class telebot.types.BusinessOpeningHours(time_zone_name, opening_hours, **kwargs)¶
Bases:
JsonDeserializable
This object represents business opening hours.
Telegram documentation: https://core.telegram.org/bots/api#businessopeninghours
- Parameters:
time_zone_name (
str
) – Unique name of the time zone for which the opening hours are definedopening_hours (
list
ofBusinessOpeningHoursInterval
) – List of time intervals describing business opening hours
- Returns:
Instance of the class
- Return type:
- class telebot.types.BusinessOpeningHoursInterval(opening_minute, closing_minute, **kwargs)¶
Bases:
JsonDeserializable
This object represents a business opening hours interval.
Telegram documentation: https://core.telegram.org/bots/api#businessopeninghoursinterval
- Parameters:
opening_minute (
int
) – The minute’s sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 24 60closing_minute (
int
) – The minute’s sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 24 60
- Returns:
Instance of the class
- Return type:
- class telebot.types.CallbackQuery(id, from_user, data, chat_instance, json_string, message=None, inline_message_id=None, game_short_name=None, **kwargs)¶
Bases:
JsonDeserializable
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.
Telegram Documentation: https://core.telegram.org/bots/api#callbackquery
- Parameters:
id (
str
) – Unique identifier for this queryfrom_user (
telebot.types.User
) – Sendermessage (
telebot.types.Message
ortelebot.types.InaccessibleMessage
) – Optional. Message sent by the bot with the callback button that originated the queryinline_message_id (
str
) – Optional. Identifier of the message sent via the bot in inline mode, that originated the query.chat_instance (
str
) – Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.data (
str
) – Optional. 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 (
str
) – Optional. Short name of a Game to be returned, serves as the unique identifier for the game
- Returns:
Instance of the class
- Return type:
- class telebot.types.Chat(id, type, title=None, username=None, first_name=None, last_name=None, photo=None, bio=None, has_private_forwards=None, description=None, invite_link=None, pinned_message=None, permissions=None, slow_mode_delay=None, message_auto_delete_time=None, has_protected_content=None, sticker_set_name=None, can_set_sticker_set=None, linked_chat_id=None, location=None, join_to_send_messages=None, join_by_request=None, has_restricted_voice_and_video_messages=None, is_forum=None, max_reaction_count=None, active_usernames=None, emoji_status_custom_emoji_id=None, has_hidden_members=None, has_aggressive_anti_spam_enabled=None, emoji_status_expiration_date=None, available_reactions=None, accent_color_id=None, background_custom_emoji_id=None, profile_accent_color_id=None, profile_background_custom_emoji_id=None, has_visible_history=None, unrestrict_boost_count=None, custom_emoji_sticker_set_name=None, business_intro=None, business_location=None, business_opening_hours=None, personal_chat=None, birthdate=None, can_send_paid_media=None, **kwargs)¶
Bases:
ChatFullInfo
In BotAPI 7.3 Chat was reduced and full info moved to ChatFullInfo: “Split out the class ChatFullInfo from the class Chat and changed the return type of the method getChat to ChatFullInfo.”
https://core.telegram.org/bots/api#chatfullinfo
Currently Chat is left as full copy of ChatFullInfo for compatibility.
- class telebot.types.ChatAdministratorRights(is_anonymous: bool, can_manage_chat: bool, can_delete_messages: bool, can_manage_video_chats: bool, can_restrict_members: bool, can_promote_members: bool, can_change_info: bool, can_invite_users: bool, can_post_messages: bool | None = None, can_edit_messages: bool | None = None, can_pin_messages: bool | None = None, can_manage_topics: bool | None = None, can_post_stories: bool | None = None, can_edit_stories: bool | None = None, can_delete_stories: bool | None = None, **kwargs)¶
Bases:
JsonDeserializable
,JsonSerializable
,Dictionaryable
Represents the rights of an administrator in a chat.
Telegram Documentation: https://core.telegram.org/bots/api#chatadministratorrights
- Parameters:
is_anonymous (
bool
) – True, if the user’s presence in the chat is hiddencan_manage_chat (
bool
) – True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilegecan_delete_messages (
bool
) – True, if the administrator can delete messages of other userscan_manage_video_chats (
bool
) – True, if the administrator can manage video chatscan_restrict_members (
bool
) – True, if the administrator can restrict, ban or unban chat memberscan_promote_members (
bool
) – True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)can_change_info (
bool
) – True, if the user is allowed to change the chat title, photo and other settingscan_invite_users (
bool
) – True, if the user is allowed to invite new users to the chatcan_post_messages (
bool
) – Optional. True, if the administrator can post in the channel; channels onlycan_edit_messages (
bool
) – Optional. True, if the administrator can edit messages of other users and can pin messages; channels onlycan_pin_messages (
bool
) – Optional. True, if the user is allowed to pin messages; groups and supergroups onlycan_manage_topics (
bool
) – Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups onlycan_post_stories (
bool
) – Optional. True, if the administrator can post channel storiescan_edit_stories (
bool
) – Optional. True, if the administrator can edit storiescan_delete_stories (
bool
) – Optional. True, if the administrator can delete stories of other users
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatBackground(type, **kwargs)¶
Bases:
JsonDeserializable
This object represents a chat background.
Telegram documentation: https://core.telegram.org/bots/api#chatbackground
- Parameters:
type (
BackgroundType
) – Type of the background- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatBoost(boost_id, add_date, expiration_date, source, **kwargs)¶
Bases:
JsonDeserializable
This object contains information about a chat boost.
Telegram documentation: https://core.telegram.org/bots/api#chatboost
- Parameters:
boost_id (
str
) – Unique identifier of the boostadd_date (
int
) – Point in time (Unix timestamp) when the chat was boostedexpiration_date (
int
) – Point in time (Unix timestamp) when the boost will automatically expire, unless the booster’s Telegram Premium subscription is prolongedsource (
ChatBoostSource
) – Optional. Source of the added boost (made Optional for now due to API error)
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatBoostAdded(boost_count, **kwargs)¶
Bases:
JsonDeserializable
This object represents a service message about a user boosting a chat.
Telegram documentation: https://core.telegram.org/bots/api#chatboostadded
- Parameters:
boost_count (
int
) – Number of boosts added by the user- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatBoostRemoved(chat, boost_id, remove_date, source, **kwargs)¶
Bases:
JsonDeserializable
This object represents a boost removed from a chat.
Telegram documentation: https://core.telegram.org/bots/api#chatboostremoved
- Parameters:
chat (
Chat
) – Chat which was boostedboost_id (
str
) – Unique identifier of the boostremove_date (
int
) – Point in time (Unix timestamp) when the boost was removedsource (
ChatBoostSource
) – Source of the removed boost
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatBoostSource¶
Bases:
ABC
,JsonDeserializable
- This object describes the source of a chat boost. It can be one of
ChatBoostSourcePremium ChatBoostSourceGiftCode ChatBoostSourceGiveaway
Telegram documentation: https://core.telegram.org/bots/api#chatboostsource
- Returns:
Instance of the class
- Return type:
ChatBoostSourcePremium
orChatBoostSourceGiftCode
orChatBoostSourceGiveaway
- class telebot.types.ChatBoostSourceGiftCode(source, user, **kwargs)¶
Bases:
ChatBoostSource
The boost was obtained by the creation of Telegram Premium gift codes to boost a chat.
Telegram documentation: https://core.telegram.org/bots/api#chatboostsourcegiftcode
- Parameters:
source (
str
) – Source of the boost, always “gift_code”user (
User
) – User for which the gift code was created
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatBoostSourceGiveaway(source, giveaway_message_id, user=None, is_unclaimed=None, prize_star_count=None, **kwargs)¶
Bases:
ChatBoostSource
The boost was obtained by the creation of a Telegram Premium giveaway.
Telegram documentation: https://core.telegram.org/bots/api#chatboostsourcegiveaway
- Parameters:
source (
str
) – Source of the boost, always “giveaway”giveaway_message_id (
int
) – Identifier of a message in the chat with the giveaway; the message could have been deleted already. May be 0 if the message isn’t sent yet.user (
User
) – User that won the prize in the giveaway if anyis_unclaimed (
bool
) – True, if the giveaway was completed, but there was no user to win the prizeprize_star_count (
int
) – Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatBoostSourcePremium(source, user, **kwargs)¶
Bases:
ChatBoostSource
The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscription to another user.
Telegram documentation: https://core.telegram.org/bots/api#chatboostsourcepremium
- Parameters:
source (
str
) – Source of the boost, always “premium”user (
User
) – User that boosted the chat
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatBoostUpdated(chat, boost, **kwargs)¶
Bases:
JsonDeserializable
This object represents a boost added to a chat or changed.
Telegram documentation: https://core.telegram.org/bots/api#chatboostupdated
- Parameters:
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatFullInfo(id, type, title=None, username=None, first_name=None, last_name=None, photo=None, bio=None, has_private_forwards=None, description=None, invite_link=None, pinned_message=None, permissions=None, slow_mode_delay=None, message_auto_delete_time=None, has_protected_content=None, sticker_set_name=None, can_set_sticker_set=None, linked_chat_id=None, location=None, join_to_send_messages=None, join_by_request=None, has_restricted_voice_and_video_messages=None, is_forum=None, max_reaction_count=None, active_usernames=None, emoji_status_custom_emoji_id=None, has_hidden_members=None, has_aggressive_anti_spam_enabled=None, emoji_status_expiration_date=None, available_reactions=None, accent_color_id=None, background_custom_emoji_id=None, profile_accent_color_id=None, profile_background_custom_emoji_id=None, has_visible_history=None, unrestrict_boost_count=None, custom_emoji_sticker_set_name=None, business_intro=None, business_location=None, business_opening_hours=None, personal_chat=None, birthdate=None, can_send_paid_media=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a chat.
Telegram Documentation: https://core.telegram.org/bots/api#chat
- Parameters:
id (
int
) – Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.type (
str
) – Type of chat, can be either “private”, “group”, “supergroup” or “channel”title (
str
) – Optional. Title, for supergroups, channels and group chatsusername (
str
) – Optional. Username, for private chats, supergroups and channels if availablefirst_name (
str
) – Optional. First name of the other party in a private chatlast_name (
str
) – Optional. Last name of the other party in a private chatis_forum (
bool
) – Optional. True, if the supergroup chat is a forum (has topics enabled)max_reaction_count (
int
) – Optional. The maximum number of reactions that can be set on a message in the chatphoto (
telebot.types.ChatPhoto
) – Optional. Chat photo. Returned only in getChat.active_usernames (
list
ofstr
) – Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat.birthdate (
str
) – Optional. Birthdate of the other party in a private chat. Returned only in getChat.business_intro (
telebot.types.BusinessIntro
) – Optional. Business intro for the chat. Returned only in getChat.business_location (
telebot.types.BusinessLocation
) – Optional. Business location for the chat. Returned only in getChat.
:param business_opening_hours : Optional. Business opening hours for the chat. Returned only in getChat. :type business_opening_hours:
telebot.types.BusinessHours
- Parameters:
personal_chat (
telebot.types.Chat
) – Optional. For private chats, the personal channel of the user. Returned only in getChat.available_reactions (
list
oftelebot.types.ReactionType
) – Optional. List of available chat reactions; for private chats, supergroups and channels. Returned only in getChat.accent_color_id (
int
) – Optional. Optional. Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. Returned only in getChat. Always returned in getChat.background_custom_emoji_id (
str
) – Optional. Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. Returned only in getChat.profile_accent_color_id (
int
) – Optional. Identifier of the accent color for the chat’s profile background. See profile accent colors for more details. Returned only in getChat.profile_background_custom_emoji_id (
str
) – Optional. Custom emoji identifier of the emoji chosen by the chat for its profile background. Returned only in getChat.emoji_status_custom_emoji_id (
str
) – Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat.emoji_status_expiration_date (
int
) – Optional. Expiration date of the emoji status of the other party in a private chat, if any. Returned only in getChat.bio (
str
) – Optional. Bio of the other party in a private chat. Returned only in getChat.has_private_forwards (
bool
) – Optional.bool
, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user. Returned only in getChat.has_restricted_voice_and_video_messages – Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in getChat.
:type
bool
- Parameters:
join_to_send_messages (
bool
) – Optional.bool
, if users need to join the supergroup before they can send messages. Returned only in getChat.join_by_request (
bool
) – Optional.bool
, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat.description (
str
) – Optional. Description, for groups, supergroups and channel chats. Returned only in getChat.invite_link (
str
) – Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.pinned_message (
telebot.types.Message
) – Optional. The most recent pinned message (by sending date). Returned only in getChat.permissions (
telebot.types.ChatPermissions
) – Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.slow_mode_delay (
int
) – Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. Returned only in getChat.unrestrict_boost_count (
int
) – Optional. For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions. Returned only in getChat.message_auto_delete_time (
int
) – Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.has_aggressive_anti_spam_enabled (
bool
) – Optional.bool
, if the chat has enabled aggressive anti-spam protection. Returned only in getChat.has_hidden_members (
bool
) – Optional.bool
, if the chat has enabled hidden members. Returned only in getChat.has_protected_content (
bool
) – Optional.bool
, if messages from the chat can’t be forwarded to other chats. Returned only in getChat.has_visible_history (
bool
) – Optional. True, if new chat members will have access to old messages; available only to chat administrators. Returned only in getChat.sticker_set_name (
str
) – Optional. For supergroups, name of group sticker set. Returned only in getChat.can_set_sticker_set (
bool
) – Optional.bool
, if the bot can change the group sticker set. Returned only in getChat.custom_emoji_sticker_set_name – Optional. For supergroups, the name of the group’s custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. Returned only in getChat.
custom_emoji_sticker_set_name –
str
linked_chat_id (
int
) – Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat.location (
telebot.types.ChatLocation
) – Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.can_send_paid_media (
bool
) – Optional. True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats.
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatInviteLink(invite_link: str, creator: User, creates_join_request: bool, is_primary: bool, is_revoked: bool, name: str | None = None, expire_date: int | None = None, member_limit: int | None = None, pending_join_request_count: int | None = None, **kwargs)¶
Bases:
JsonSerializable
,JsonDeserializable
,Dictionaryable
Represents an invite link for a chat.
Telegram Documentation: https://core.telegram.org/bots/api#chatinvitelink
- Parameters:
invite_link (
str
) – The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”.creator (
telebot.types.User
) – Creator of the linkcreates_join_request (
bool
) – True, if users joining the chat via the link need to be approved by chat administratorsis_primary (
bool
) – True, if the link is primaryis_revoked (
bool
) – True, if the link is revokedname (
str
) – Optional. Invite link nameexpire_date (
int
) – Optional. Point in time (Unix timestamp) when the link will expire or has been expiredmember_limit (
int
) – Optional. The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999pending_join_request_count (
int
) – Optional. Number of pending join requests created using this link
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatJoinRequest(chat, from_user, user_chat_id, date, bio=None, invite_link=None, **kwargs)¶
Bases:
JsonDeserializable
Represents a join request sent to a chat.
Telegram Documentation: https://core.telegram.org/bots/api#chatjoinrequest
- Parameters:
chat (
telebot.types.Chat
) – Chat to which the request was sentfrom_user (
telebot.types.User
) – User that sent the join requestuser_chat_id (
int
) – Optional. Identifier of a private chat with the user who sent the join request. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot can use this identifier for 24 hours to send messages until the join request is processed, assuming no other administrator contacted the user.date (
int
) – Date the request was sent in Unix timebio (
str
) – Optional. Bio of the user.invite_link (
telebot.types.ChatInviteLink
) – Optional. Chat invite link that was used by the user to send the join request
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatLocation(location: Location, address: str, **kwargs)¶
Bases:
JsonSerializable
,JsonDeserializable
,Dictionaryable
Represents a location to which a chat is connected.
Telegram Documentation: https://core.telegram.org/bots/api#chatlocation
- Parameters:
location (
telebot.types.Location
) – The location to which the supergroup is connected. Can’t be a live location.address (
str
) – Location address; 1-64 characters, as defined by the chat owner
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatMember(user, status, custom_title=None, is_anonymous=None, can_be_edited=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_restrict_members=None, can_promote_members=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, is_member=None, can_send_messages=None, can_send_audios=None, can_send_documents=None, can_send_photos=None, can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_manage_chat=None, can_manage_video_chats=None, until_date=None, can_manage_topics=None, can_post_stories=None, can_edit_stories=None, can_delete_stories=None, **kwargs)¶
Bases:
JsonDeserializable
This object contains information about one member of a chat. Currently, the following 6 types of chat members are supported:
Telegram Documentation: https://core.telegram.org/bots/api#chatmember
- property can_manage_voice_chats¶
- class telebot.types.ChatMemberAdministrator(user, status, custom_title=None, is_anonymous=None, can_be_edited=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_restrict_members=None, can_promote_members=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, is_member=None, can_send_messages=None, can_send_audios=None, can_send_documents=None, can_send_photos=None, can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_manage_chat=None, can_manage_video_chats=None, until_date=None, can_manage_topics=None, can_post_stories=None, can_edit_stories=None, can_delete_stories=None, **kwargs)¶
Bases:
ChatMember
Represents a chat member that has some additional privileges.
Telegram Documentation: https://core.telegram.org/bots/api#chatmemberadministrator
- Parameters:
status (
str
) – The member’s status in the chat, always “administrator”user (
telebot.types.User
) – Information about the usercan_be_edited (
bool
) – True, if the bot is allowed to edit administrator privileges of that useris_anonymous (
bool
) – True, if the user’s presence in the chat is hiddencan_manage_chat (
bool
) – True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilegecan_delete_messages (
bool
) – True, if the administrator can delete messages of other userscan_manage_video_chats (
bool
) – True, if the administrator can manage video chatscan_restrict_members (
bool
) – True, if the administrator can restrict, ban or unban chat memberscan_promote_members (
bool
) – True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)can_change_info (
bool
) – True, if the user is allowed to change the chat title, photo and other settingscan_invite_users (
bool
) – True, if the user is allowed to invite new users to the chatcan_post_messages (
bool
) – Optional. True, if the administrator can post in the channel; channels onlycan_edit_messages (
bool
) – Optional. True, if the administrator can edit messages of other users and can pin messages; channels onlycan_pin_messages (
bool
) – Optional. True, if the user is allowed to pin messages; groups and supergroups onlycan_manage_topics (
bool
) – Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups onlycustom_title (
str
) – Optional. Custom title for this usercan_post_stories (
bool
) – Optional. True, if the administrator can post channel storiescan_edit_stories (
bool
) – Optional. True, if the administrator can edit storiescan_delete_stories (
bool
) – Optional. True, if the administrator can delete stories of other users
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatMemberBanned(user, status, custom_title=None, is_anonymous=None, can_be_edited=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_restrict_members=None, can_promote_members=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, is_member=None, can_send_messages=None, can_send_audios=None, can_send_documents=None, can_send_photos=None, can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_manage_chat=None, can_manage_video_chats=None, until_date=None, can_manage_topics=None, can_post_stories=None, can_edit_stories=None, can_delete_stories=None, **kwargs)¶
Bases:
ChatMember
Represents a chat member that was banned in the chat and can’t return to the chat or view chat messages.
Telegram Documentation: https://core.telegram.org/bots/api#chatmemberbanned
- Parameters:
status (
str
) – The member’s status in the chat, always “kicked”user (
telebot.types.User
) – Information about the useruntil_date (
int
) – Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned forever
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatMemberLeft(user, status, custom_title=None, is_anonymous=None, can_be_edited=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_restrict_members=None, can_promote_members=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, is_member=None, can_send_messages=None, can_send_audios=None, can_send_documents=None, can_send_photos=None, can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_manage_chat=None, can_manage_video_chats=None, until_date=None, can_manage_topics=None, can_post_stories=None, can_edit_stories=None, can_delete_stories=None, **kwargs)¶
Bases:
ChatMember
Represents a chat member that isn’t currently a member of the chat, but may join it themselves.
Telegram Documentation: https://core.telegram.org/bots/api#chatmemberleft
- Parameters:
status (
str
) – The member’s status in the chat, always “left”user (
telebot.types.User
) – Information about the user
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatMemberMember(user, status, custom_title=None, is_anonymous=None, can_be_edited=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_restrict_members=None, can_promote_members=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, is_member=None, can_send_messages=None, can_send_audios=None, can_send_documents=None, can_send_photos=None, can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_manage_chat=None, can_manage_video_chats=None, until_date=None, can_manage_topics=None, can_post_stories=None, can_edit_stories=None, can_delete_stories=None, **kwargs)¶
Bases:
ChatMember
Represents a chat member that has no additional privileges or restrictions.
Telegram Documentation: https://core.telegram.org/bots/api#chatmembermember
- Parameters:
status (
str
) – The member’s status in the chat, always “member”user (
telebot.types.User
) – Information about the user
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatMemberOwner(user, status, custom_title=None, is_anonymous=None, can_be_edited=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_restrict_members=None, can_promote_members=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, is_member=None, can_send_messages=None, can_send_audios=None, can_send_documents=None, can_send_photos=None, can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_manage_chat=None, can_manage_video_chats=None, until_date=None, can_manage_topics=None, can_post_stories=None, can_edit_stories=None, can_delete_stories=None, **kwargs)¶
Bases:
ChatMember
Represents a chat member that owns the chat and has all administrator privileges.
Telegram Documentation: https://core.telegram.org/bots/api#chatmemberowner
- Parameters:
status (
str
) – The member’s status in the chat, always “creator”user (
telebot.types.User
) – Information about the useris_anonymous (
bool
) – True, if the user’s presence in the chat is hiddencustom_title (
str
) – Optional. Custom title for this user
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatMemberRestricted(user, status, custom_title=None, is_anonymous=None, can_be_edited=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_restrict_members=None, can_promote_members=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, is_member=None, can_send_messages=None, can_send_audios=None, can_send_documents=None, can_send_photos=None, can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_manage_chat=None, can_manage_video_chats=None, until_date=None, can_manage_topics=None, can_post_stories=None, can_edit_stories=None, can_delete_stories=None, **kwargs)¶
Bases:
ChatMember
Represents a chat member that is under certain restrictions in the chat. Supergroups only.
Telegram Documentation: https://core.telegram.org/bots/api#chatmemberrestricted
- Parameters:
status (
str
) – The member’s status in the chat, always “restricted”user (
telebot.types.User
) – Information about the useris_member (
bool
) – True, if the user is a member of the chat at the moment of the requestcan_change_info (
bool
) – True, if the user is allowed to change the chat title, photo and other settingscan_invite_users (
bool
) – True, if the user is allowed to invite new users to the chatcan_pin_messages (
bool
) – True, if the user is allowed to pin messagescan_manage_topics (
bool
) – True, if the user is allowed to create forum topicscan_send_messages (
bool
) – True, if the user is allowed to send text messages, contacts, locations and venuescan_send_audios (
bool
) – True, if the user is allowed to send audioscan_send_documents (
bool
) – True, if the user is allowed to send documentscan_send_photos (
bool
) – True, if the user is allowed to send photoscan_send_videos (
bool
) – True, if the user is allowed to send videoscan_send_video_notes (
bool
) – True, if the user is allowed to send video notescan_send_voice_notes (
bool
) – True, if the user is allowed to send voice notescan_send_polls (
bool
) – True, if the user is allowed to send pollscan_send_other_messages (
bool
) – True, if the user is allowed to send animations, games, stickers and use inline botscan_add_web_page_previews (
bool
) – True, if the user is allowed to add web page previews to their messagesuntil_date (
int
) – Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatMemberUpdated(chat, from_user, date, old_chat_member, new_chat_member, invite_link=None, via_join_request=None, via_chat_folder_invite_link=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents changes in the status of a chat member.
Telegram Documentation: https://core.telegram.org/bots/api#chatmemberupdated
- Parameters:
chat (
telebot.types.Chat
) – Chat the user belongs tofrom_user (
telebot.types.User
) – Performer of the action, which resulted in the changedate (
int
) – Date the change was done in Unix timeold_chat_member (
telebot.types.ChatMember
) – Previous information about the chat membernew_chat_member (
telebot.types.ChatMember
) – New information about the chat memberinvite_link (
telebot.types.ChatInviteLink
) – Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.via_join_request (
bool
) – Optional. True, if the user joined the chat after sending a direct join request without using an invite link and being approved by an administratorvia_chat_folder_invite_link (
bool
) – Optional. True, if the user joined the chat via a chat folder invite link
- Returns:
Instance of the class
- Return type:
- property difference: Dict[str, List]¶
Get the difference between old_chat_member and new_chat_member as a dict in the following format {‘parameter’: [old_value, new_value]} E.g {‘status’: [‘member’, ‘kicked’], ‘until_date’: [None, 1625055092]}
- Returns:
Dict of differences
- Return type:
Dict[str, List]
- class telebot.types.ChatPermissions(can_send_messages=None, can_send_media_messages=None, can_send_audios=None, can_send_documents=None, can_send_photos=None, can_send_videos=None, can_send_video_notes=None, can_send_voice_notes=None, can_send_polls=None, can_send_other_messages=None, can_add_web_page_previews=None, can_change_info=None, can_invite_users=None, can_pin_messages=None, can_manage_topics=None, **kwargs)¶
Bases:
JsonDeserializable
,JsonSerializable
,Dictionaryable
Describes actions that a non-administrator user is allowed to take in a chat.
Telegram Documentation: https://core.telegram.org/bots/api#chatpermissions
- Parameters:
can_send_messages (
bool
) – Optional. True, if the user is allowed to send text messages, contacts, locations and venuescan_send_audios (
bool
) – Optional. True, if the user is allowed to send audioscan_send_documents (
bool
) – Optional. True, if the user is allowed to send documentscan_send_photos (
bool
) – Optional. True, if the user is allowed to send photoscan_send_videos (
bool
) – Optional. True, if the user is allowed to send videoscan_send_video_notes (
bool
) – Optional. True, if the user is allowed to send video notescan_send_voice_notes (
bool
) – Optional. True, if the user is allowed to send voice notescan_send_polls (
bool
) – Optional. True, if the user is allowed to send polls, implies can_send_messagescan_send_other_messages (
bool
) – Optional. True, if the user is allowed to send animations, games, stickers and use inline botscan_add_web_page_previews (
bool
) – Optional. True, if the user is allowed to add web page previews to their messagescan_change_info (
bool
) – Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroupscan_invite_users (
bool
) – Optional. True, if the user is allowed to invite new users to the chatcan_pin_messages (
bool
) – Optional. True, if the user is allowed to pin messages. Ignored in public supergroupscan_manage_topics (
bool
) – Optional. True, if the user is allowed to create forum topics. If omitted defaults to the value of can_pin_messagescan_send_media_messages (
bool
) – deprecated.
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChatPhoto(small_file_id, small_file_unique_id, big_file_id, big_file_unique_id, **kwargs)¶
Bases:
JsonDeserializable
This object represents a chat photo.
Telegram Documentation: https://core.telegram.org/bots/api#chatphoto
- Parameters:
small_file_id (
str
) – File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed.small_file_unique_id (
str
) – Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.big_file_id (
str
) – File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed.big_file_unique_id (
str
) – Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.
- Returns:
Instance of the class
- Return type:
Bases:
JsonDeserializable
This object contains information about the chat whose identifier was shared with the bot using a telebot.types.KeyboardButtonRequestChat button.
Telegram documentation: https://core.telegram.org/bots/api#Chatshared
- Parameters:
request_id (
int
) – identifier of the requestchat_id (
int
) – Identifier of the shared chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.title (
str
) – Optional. Title of the shared chatphoto (
list
oftelebot.types.PhotoSize
) – Optional. Array of Photosizeusername (
str
) – Optional. Username of the shared chat
- Returns:
Instance of the class
- Return type:
- class telebot.types.ChosenInlineResult(result_id, from_user, query, location=None, inline_message_id=None, **kwargs)¶
Bases:
JsonDeserializable
Represents a result of an inline query that was chosen by the user and sent to their chat partner.
Telegram Documentation: https://core.telegram.org/bots/api#choseninlineresult
- Parameters:
result_id (
str
) – The unique identifier for the result that was chosenfrom (
telebot.types.User
) – The user that chose the resultlocation (
telebot.types.Location
) – Optional. Sender location, only for bots that require user locationinline_message_id (
str
) – Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message.query (
str
) – The query that was used to obtain the result
- Returns:
Instance of the class
- Return type:
- class telebot.types.Contact(phone_number, first_name, last_name=None, user_id=None, vcard=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a phone contact.
Telegram Documentation: https://core.telegram.org/bots/api#contact
- Parameters:
phone_number (
str
) – Contact’s phone numberfirst_name (
str
) – Contact’s first namelast_name (
str
) – Optional. Contact’s last nameuser_id (
int
) – Optional. Contact’s user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.vcard (
str
) – Optional. Additional data about the contact in the form of a vCard
- Returns:
Instance of the class
- Return type:
- class telebot.types.CopyTextButton(text: str, **kwargs)¶
Bases:
JsonSerializable
,JsonDeserializable
This object represents an inline keyboard button that copies specified text to the clipboard.
Telegram documentation: https://core.telegram.org/bots/api#copytextbutton
- Parameters:
text (
str
) – The text to be copied to the clipboard; 1-256 characters- Returns:
Instance of the class
- Return type:
- to_dict()¶
- class telebot.types.Dice(value, emoji, **kwargs)¶
Bases:
JsonSerializable
,Dictionaryable
,JsonDeserializable
This object represents an animated emoji that displays a random value.
Telegram Documentation: https://core.telegram.org/bots/api#dice
- Parameters:
emoji (
str
) – Emoji on which the dice throw animation is basedvalue (
int
) – Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for “🎰” base emoji
- Returns:
Instance of the class
- Return type:
- class telebot.types.Dictionaryable¶
Bases:
object
Subclasses of this class are guaranteed to be able to be converted to dictionary. All subclasses of this class must override to_dict.
- class telebot.types.Document(file_id, file_unique_id, thumbnail=None, file_name=None, mime_type=None, file_size=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a general file (as opposed to photos, voice messages and audio files).
Telegram Documentation: https://core.telegram.org/bots/api#document
- Parameters:
file_id (
str
) – Identifier for this file, which can be used to download or reuse the filefile_unique_id (
str
) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.thumbnail (
telebot.types.PhotoSize
) – Optional. Document thumbnail as defined by senderfile_name (
str
) – Optional. Original filename as defined by sendermime_type (
str
) – Optional. MIME type of the file as defined by senderfile_size (
int
) – Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
- Returns:
Instance of the class
- Return type:
- class telebot.types.ExternalReplyInfo(origin: MessageOrigin, chat: Chat | None = None, message_id: int | None = None, link_preview_options: LinkPreviewOptions | None = None, animation: Animation | None = None, audio: Audio | None = None, document: Document | None = None, photo: List[PhotoSize] | None = None, sticker: Sticker | None = None, story: Story | None = None, video: Video | None = None, video_note: VideoNote | None = None, voice: Voice | None = None, has_media_spoiler: bool | None = None, contact: Contact | None = None, dice: Dice | None = None, game: Game | None = None, giveaway: Giveaway | None = None, giveaway_winners: GiveawayWinners | None = None, invoice: Invoice | None = None, location: Location | None = None, poll: Poll | None = None, venue: Venue | None = None, paid_media: PaidMediaInfo | None = None, **kwargs)¶
Bases:
JsonDeserializable
This object contains information about a message that is being replied to, which may come from another chat or forum topic.
Telegram documentation: https://core.telegram.org/bots/api#externalreplyinfo
- Parameters:
origin (
MessageOrigin
) – Origin of the message replied to by the given messagechat (
Chat
) – Optional. Chat the original message belongs to. Available only if the chat is a supergroup or a channel.message_id (
int
) – Optional. Unique message identifier inside the original chat. Available only if the original chat is a supergroup or a channel.link_preview_options (
LinkPreviewOptions
) – Optional. Options used for link preview generation for the original message, if it is a text messageanimation (
Animation
) – Optional. Message is an animation, information about the animationaudio (
Audio
) – Optional. Message is an audio file, information about the filedocument (
Document
) – Optional. Message is a general file, information about the filepaid_media (
PaidMedia
) – Optional. Message is a paid media contentphoto (
list
ofPhotoSize
) – Optional. Message is a photo, available sizes of the photosticker (
Sticker
) – Optional. Message is a sticker, information about the stickerstory (
Story
) – Optional. Message is a forwarded storyvideo (
Video
) – Optional. Message is a video, information about the videovideo_note (
VideoNote
) – Optional. Message is a video note, information about the video messagevoice (
Voice
) – Optional. Message is a voice message, information about the filehas_media_spoiler (
bool
) – Optional. True, if the message media is covered by a spoiler animationcontact (
Contact
) – Optional. Message is a shared contact, information about the contactdice (
Dice
) – Optional. Message is a dice with random valuegame (
Game
) – Optional. Message is a game, information about the game. More about games »giveaway (
Giveaway
) – Optional. Message is a scheduled giveaway, information about the giveawaygiveaway_winners (
GiveawayWinners
) – Optional. A giveaway with public winners was completedinvoice (
Invoice
) – Optional. Message is an invoice for a payment, information about the invoice. More about payments »location (
Location
) – Optional. Message is a shared location, information about the locationpoll (
Poll
) – Optional. Message is a native poll, information about the pollvenue (
Venue
) – Optional. Message is a venue, information about the venue
- Returns:
Instance of the class
- Return type:
- class telebot.types.File(file_id, file_unique_id, file_size=None, file_path=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile.
Telegram Documentation: https://core.telegram.org/bots/api#file
- Parameters:
file_id (
str
) – Identifier for this file, which can be used to download or reuse the filefile_unique_id (
str
) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.file_size (
int
) – Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.file_path (
str
) – Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
- Returns:
Instance of the class
- Return type:
- class telebot.types.ForceReply(selective: bool | None = None, input_field_placeholder: str | None = None)¶
Bases:
JsonSerializable
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.
Telegram Documentation: https://core.telegram.org/bots/api#forcereply
- Parameters:
force_reply (
bool
) – Shows reply interface to the user, as if they manually selected the bot’s message and tapped ‘Reply’input_field_placeholder (
str
) – Optional. The placeholder to be shown in the input field when the reply is active; 1-64 charactersselective (
bool
) – Optional. 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.
- Returns:
Instance of the class
- Return type:
- class telebot.types.ForumTopic(message_thread_id: int, name: str, icon_color: int, icon_custom_emoji_id: str | None = None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a forum topic.
Telegram documentation: https://core.telegram.org/bots/api#forumtopic
- Parameters:
message_thread_id (
int
) – Unique identifier of the forum topicname (
str
) – Name of the topicicon_color (
int
) – Color of the topic icon in RGB formaticon_custom_emoji_id (
str
) – Optional. Unique identifier of the custom emoji shown as the topic icon
- Returns:
Instance of the class
- Return type:
- class telebot.types.ForumTopicClosed¶
Bases:
JsonDeserializable
This object represents a service message about a forum topic closed in the chat. Currently holds no information.
Telegram documentation: https://core.telegram.org/bots/api#forumtopicclosed
- class telebot.types.ForumTopicCreated(name: str, icon_color: int, icon_custom_emoji_id: str | None = None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a service message about a new forum topic created in the chat.
Telegram documentation: https://core.telegram.org/bots/api#forumtopiccreated
- Parameters:
name (
str
) – Name of the topicicon_color (
int
) – Color of the topic icon in RGB formaticon_custom_emoji_id (
str
) – Optional. Unique identifier of the custom emoji shown as the topic icon
- Returns:
Instance of the class
- Return type:
- class telebot.types.ForumTopicEdited(name: str | None = None, icon_custom_emoji_id: str | None = None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a service message about an edited forum topic.
Telegram documentation: https://core.telegram.org/bots/api#forumtopicedited
- Parameters:
name (
str
) – Optional, Name of the topic(if updated)icon_custom_emoji_id (
str
) – Optional. New identifier of the custom emoji shown as the topic icon, if it was edited; an empty string if the icon was removed
- class telebot.types.ForumTopicReopened¶
Bases:
JsonDeserializable
This object represents a service message about a forum topic reopened in the chat. Currently holds no information.
Telegram documentation: https://core.telegram.org/bots/api#forumtopicreopened
- class telebot.types.Game(title, description, photo, text=None, text_entities=None, animation=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.
Telegram Documentation: https://core.telegram.org/bots/api#game
- Parameters:
title (
str
) – Title of the gamedescription (
str
) – Description of the gamephoto (
list
oftelebot.types.PhotoSize
) – Photo that will be displayed in the game message in chats.text (
str
) – Optional. Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.text_entities (
list
oftelebot.types.MessageEntity
) – Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc.animation (
telebot.types.Animation
) – Optional. Animation that will be displayed in the game message in chats. Upload via BotFather
- Returns:
Instance of the class
- Return type:
- classmethod parse_entities(message_entity_array) List[MessageEntity] ¶
Parse the message entity array into a list of MessageEntity objects
- class telebot.types.GameHighScore(position: int, user: User, score: int, **kwargs)¶
Bases:
JsonDeserializable
This object represents one row of the high scores table for a game.
Telegram Documentation: https://core.telegram.org/bots/api#gamehighscore
- Parameters:
position (
int
) – Position in high score table for the gameuser (
telebot.types.User
) – Userscore (
int
) – Score
- Returns:
Instance of the class
- Return type:
- class telebot.types.GeneralForumTopicHidden¶
Bases:
JsonDeserializable
This object represents a service message about General forum topic hidden in the chat. Currently holds no information.
Telegram documentation: https://core.telegram.org/bots/api#generalforumtopichidden
Bases:
JsonDeserializable
This object represents a service message about General forum topic unhidden in the chat. Currently holds no information.
Telegram documentation: https://core.telegram.org/bots/api#generalforumtopicunhidden
- class telebot.types.Giveaway(chats: List[Chat], winners_selection_date: int, winner_count: int, only_new_members: bool | None = None, has_public_winners: bool | None = None, prize_description: str | None = None, country_codes: List[str] | None = None, premium_subscription_month_count: int | None = None, prize_star_count: int | None = None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a message about a scheduled giveaway.
Telegram documentation: https://core.telegram.org/bots/api#giveaway
- Parameters:
chats (
list
ofChat
) – The list of chats which the user must join to participate in the giveawaywinners_selection_date (
int
) – Point in time (Unix timestamp) when winners of the giveaway will be selectedwinner_count (
int
) – The number of users which are supposed to be selected as winners of the giveawayonly_new_members (
bool
) – Optional. True, if only users who join the chats after the giveaway started should be eligible to winhas_public_winners (
bool
) – Optional. True, if the list of giveaway winners will be visible to everyoneprize_description (
str
) – Optional. Description of additional giveaway prizecountry_codes (
list
ofstr
) – Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway.prize_star_count (
int
) – Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways onlypremium_subscription_month_count (
int
) – Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for
- Returns:
Instance of the class
- Return type:
- class telebot.types.GiveawayCompleted(winner_count: int, unclaimed_prize_count: int | None = None, giveaway_message: Message | None = None, is_star_giveaway: bool | None = None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a service message about the completion of a giveaway without public winners.
Telegram documentation: https://core.telegram.org/bots/api#giveawaycompleted
- Parameters:
winner_count (
int
) – Number of winners in the giveawayunclaimed_prize_count (
int
) – Optional. Number of undistributed prizesgiveaway_message (
Message
) – Optional. Message with the giveaway that was completed, if it wasn’t deletedis_star_giveaway (
bool
) – Optional. True, if the giveaway was a Telegram Star giveaway
- Returns:
Instance of the class
- Return type:
- class telebot.types.GiveawayCreated(prize_star_count=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a service message about the creation of a scheduled giveaway.
- Prize_star_count:
Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
- Returns:
Instance of the class
- class telebot.types.GiveawayWinners(chat: Chat, giveaway_message_id: int, winners_selection_date: int, winner_count: int, winners: List[User], additional_chat_count: int | None = None, premium_subscription_month_count: int | None = None, unclaimed_prize_count: int | None = None, only_new_members: bool | None = None, was_refunded: bool | None = None, prize_description: str | None = None, prize_star_count: int | None = None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a message about the completion of a giveaway with public winners.
Telegram documentation: https://core.telegram.org/bots/api#giveawaywinners
- Parameters:
chat (
Chat
) – The chat that created the giveawaygiveaway_message_id (
int
) – Identifier of the messsage with the giveaway in the chatwinners_selection_date (
int
) – Point in time (Unix timestamp) when winners of the giveaway were selectedwinner_count (
int
) – Total number of winners in the giveawaywinners (
list
ofUser
) – List of up to 100 winners of the giveawayadditional_chat_count (
int
) – Optional. The number of other chats the user had to join in order to be eligible for the giveawaypremium_subscription_month_count (
int
) – Optional. The number of months the Telegram Premium subscription won from the giveaway will be active forunclaimed_prize_count (
int
) – Optional. Number of undistributed prizesonly_new_members (
bool
) – Optional. True, if only users who had joined the chats after the giveaway started were eligible to winwas_refunded (
bool
) – Optional. True, if the giveaway was canceled because the payment for it was refundedprize_description (
str
) – Optional. Description of additional giveaway prizeprize_star_count (
int
) – Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
- Returns:
Instance of the class
- Return type:
- class telebot.types.InaccessibleMessage(chat, message_id, date, **kwargs)¶
Bases:
JsonDeserializable
This object describes a message that was deleted or is otherwise inaccessible to the bot.
Telegram documentation: https://core.telegram.org/bots/api#inaccessiblemessage
- Parameters:
chat (
Chat
) – Chat the message belonged tomessage_id (
int
) – Unique message identifier inside the chatdate (
int
) – Always 0. The field can be used to differentiate regular and inaccessible messages.
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineKeyboardButton(text: str, url: str | None = None, callback_data: str | None = None, web_app: WebAppInfo | None = None, switch_inline_query: str | None = None, switch_inline_query_current_chat: str | None = None, switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat | None = None, callback_game=None, pay: bool | None = None, login_url: LoginUrl | None = None, copy_text: CopyTextButton | None = None, **kwargs)¶
Bases:
Dictionaryable
,JsonSerializable
,JsonDeserializable
This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
Telegram Documentation: https://core.telegram.org/bots/api#inlinekeyboardbutton
- Parameters:
text (
str
) – Label text on the buttonurl (
str
) – Optional. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings.callback_data (
str
) – Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytesweb_app (
telebot.types.WebAppInfo
) – Optional. 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 (
telebot.types.LoginUrl
) – Optional. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.switch_inline_query (
str
) – Optional. 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.Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions - in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.switch_inline_query_current_chat (
str
) – Optional. If 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 (
telebot.types.SwitchInlineQueryChosenChat
) – Optional. 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 fieldcallback_game (
telebot.types.CallbackGame
) – Optional. Description of the game that will be launched when the user presses the button. NOTE: This type of button must always be the first button in the first row.pay (
bool
) – Optional. 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.copy_text (
telebot.types.CopyTextButton
) – Optional. Description of the button that copies the specified text to the clipboard.
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineKeyboardMarkup(keyboard=None, row_width=3)¶
Bases:
Dictionaryable
,JsonSerializable
,JsonDeserializable
This object represents an inline keyboard that appears right next to the message it belongs to.
Note
It is recommended to use
telebot.util.quick_markup()
instead.from telebot.util import quick_markup markup = quick_markup({ 'Twitter': {'url': 'https://twitter.com'}, 'Facebook': {'url': 'https://facebook.com'}, 'Back': {'callback_data': 'whatever'} }, row_width=2) # returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook # and a back button below
Telegram Documentation: https://core.telegram.org/bots/api#inlinekeyboardmarkup
- Parameters:
keyboard (
list
oflist
oftelebot.types.InlineKeyboardButton
) –list
of button rows, each represented by anlist
oftelebot.types.InlineKeyboardButton
objectsrow_width (
int
) – number oftelebot.types.InlineKeyboardButton
objects on each row
- Returns:
Instance of the class
- Return type:
- add(*args, row_width=None) InlineKeyboardMarkup ¶
This method adds buttons to the keyboard without exceeding row_width.
E.g. InlineKeyboardMarkup.add(“A”, “B”, “C”) yields the json result: {keyboard: [[“A”], [“B”], [“C”]]} when row_width is set to 1. When row_width is set to 2, the result: {keyboard: [[“A”, “B”], [“C”]]} See https://core.telegram.org/bots/api#inlinekeyboardmarkup
- Parameters:
args (
list
oftelebot.types.InlineKeyboardButton
) – Array of InlineKeyboardButton to append to the keyboardrow_width (
int
) – width of row
- Returns:
self, to allow function chaining.
- Return type:
- max_row_keys = 8¶
- row(*args) InlineKeyboardMarkup ¶
Adds a list of InlineKeyboardButton to the keyboard. This method does not consider row_width.
InlineKeyboardMarkup.row(“A”).row(“B”, “C”).to_json() outputs: ‘{keyboard: [[“A”], [“B”, “C”]]}’ See https://core.telegram.org/bots/api#inlinekeyboardmarkup
- Parameters:
args (
list
oftelebot.types.InlineKeyboardButton
) – Array of InlineKeyboardButton to append to the keyboard- Returns:
self, to allow function chaining.
- Return type:
- class telebot.types.InlineQuery(id, from_user, query, offset, chat_type=None, location=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequery
- Parameters:
id (
str
) – Unique identifier for this queryfrom_user (
telebot.types.User
) – Senderquery (
str
) – Text of the query (up to 256 characters)offset (
str
) – Offset of the results to be returned, can be controlled by the botchat_type (
str
) – Optional. Type of the chat from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chatlocation (
telebot.types.Location
) – Optional. Sender location, only for bots that request user location
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultArticle(id: str, title: str, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent, reply_markup: InlineKeyboardMarkup | None = None, url: str | None = None, hide_url: bool | None = None, description: str | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)¶
Bases:
InlineQueryResultBase
Represents a link to an article or web page.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultarticle
- Parameters:
type (
str
) – Type of the result, must be articleid (
str
) – Unique identifier for this result, 1-64 Bytestitle (
str
) – Title of the resultinput_message_content (
telebot.types.InputMessageContent
) – Content of the message to be sentreply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageurl (
str
) – Optional. URL of the resulthide_url (
bool
) – Optional. Pass True, if you don’t want the URL to be shown in the messagedescription (
str
) – Optional. Short description of the resultthumbnail_url (
str
) – Optional. Url of the thumbnail for the resultthumbnail_width (
int
) – Optional. Thumbnail widththumbnail_height (
int
) – Optional. Thumbnail height
- Returns:
Instance of the class
- Return type:
- property thumb_height: int¶
- property thumb_url: str¶
- property thumb_width: int¶
- class telebot.types.InlineQueryResultAudio(id: str, audio_url: str, title: str, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, performer: str | None = None, audio_duration: int | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None)¶
Bases:
InlineQueryResultBase
Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultaudio
- Parameters:
type (
str
) – Type of the result, must be audioid (
str
) – Unique identifier for this result, 1-64 bytesaudio_url (
str
) – A valid URL for the audio filetitle (
str
) – Titlecaption (
str
) – Optional. Caption, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the audio caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modeperformer (
str
) – Optional. Performeraudio_duration (
int
) – Optional. Audio duration in secondsreply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the audio
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultBase(type: str, id: str, title: str | None = None, caption: str | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, reply_markup: InlineKeyboardMarkup | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None)¶
Bases:
ABC
,Dictionaryable
,JsonSerializable
This object represents one result of an inline query. Telegram clients currently support results of the following 20 types:
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresult
- class telebot.types.InlineQueryResultCachedAudio(id: str, audio_file_id: str, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None)¶
Bases:
InlineQueryResultCachedBase
Represents a link to an MP3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedaudio
- Parameters:
type (
str
) – Type of the result, must be audioid (
str
) – Unique identifier for this result, 1-64 bytesaudio_file_id (
str
) – A valid file identifier for the audio filecaption (
str
) – Optional. Caption, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the audio caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the audio
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultCachedBase¶
Bases:
ABC
,JsonSerializable
Base class of all InlineQueryResultCached* classes.
- class telebot.types.InlineQueryResultCachedDocument(id: str, document_file_id: str, title: str, description: str | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None)¶
Bases:
InlineQueryResultCachedBase
Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcacheddocument
- Parameters:
type (
str
) – Type of the result, must be documentid (
str
) – Unique identifier for this result, 1-64 bytestitle (
str
) – Title for the resultdocument_file_id (
str
) – A valid file identifier for the filedescription (
str
) – Optional. Short description of the resultcaption (
str
) – Optional. Caption of the document to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the document caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the file
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultCachedGif(id: str, gif_file_id: str, title: str | None = None, description: str | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InlineQueryResultCachedBase
Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedgif
- Parameters:
type (
str
) – Type of the result, must be gifid (
str
) – Unique identifier for this result, 1-64 bytesgif_file_id (
str
) – A valid file identifier for the GIF filetitle (
str
) – Optional. Title for the resultcaption (
str
) – Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the GIF animationshow_caption_above_media (
bool
) – Optional. Pass True, if a caption is not required for the media
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultCachedMpeg4Gif(id: str, mpeg4_file_id: str, title: str | None = None, description: str | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InlineQueryResultCachedBase
Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif
- Parameters:
type (
str
) – Type of the result, must be mpeg4_gifid (
str
) – Unique identifier for this result, 1-64 bytesmpeg4_file_id (
str
) – A valid file identifier for the MPEG4 filetitle (
str
) – Optional. Title for the resultcaption (
str
) – Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the video animationshow_caption_above_media (
bool
) – Optional. Pass True, if caption should be shown above the media
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultCachedPhoto(id: str, photo_file_id: str, title: str | None = None, description: str | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InlineQueryResultCachedBase
Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedphoto
- Parameters:
type (
str
) – Type of the result, must be photoid (
str
) – Unique identifier for this result, 1-64 bytesphoto_file_id (
str
) – A valid file identifier of the phototitle (
str
) – Optional. Title for the resultdescription (
str
) – Optional. Short description of the resultcaption (
str
) – Optional. Caption of the photo to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the photo caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the photoshow_caption_above_media (
bool
) – Optional. Pass True, if a caption is not required for the media
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultCachedSticker(id: str, sticker_file_id: str, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None)¶
Bases:
InlineQueryResultCachedBase
Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedsticker
- Parameters:
type (
str
) – Type of the result, must be stickerid (
str
) – Unique identifier for this result, 1-64 bytessticker_file_id (
str
) – A valid file identifier of the stickerreply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the sticker
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultCachedVideo(id: str, video_file_id: str, title: str, description: str | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InlineQueryResultCachedBase
Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedvideo
- Parameters:
type (
str
) – Type of the result, must be videoid (
str
) – Unique identifier for this result, 1-64 bytesvideo_file_id (
str
) – A valid file identifier for the video filetitle (
str
) – Title for the resultdescription (
str
) – Optional. Short description of the resultcaption (
str
) – Optional. Caption of the video to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the video caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the videoshow_caption_above_media (
bool
) – Optional. Pass True, if a caption is not required for the media
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultCachedVoice(id: str, voice_file_id: str, title: str, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None)¶
Bases:
InlineQueryResultCachedBase
Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcachedvoice
- Parameters:
type (
str
) – Type of the result, must be voiceid (
str
) – Unique identifier for this result, 1-64 bytesvoice_file_id (
str
) – A valid file identifier for the voice messagetitle (
str
) – Voice message titlecaption (
str
) – Optional. Caption, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the voice message caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the voice message
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultContact(id: str, phone_number: str, first_name: str, last_name: str | None = None, vcard: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)¶
Bases:
InlineQueryResultBase
Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultcontact
- Parameters:
type (
str
) – Type of the result, must be contactid (
str
) – Unique identifier for this result, 1-64 Bytesphone_number (
str
) – Contact’s phone numberfirst_name (
str
) – Contact’s first namelast_name (
str
) – Optional. Contact’s last namevcard (
str
) – Optional. Additional data about the contact in the form of a vCard, 0-2048 bytesreply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the contactthumbnail_url (
str
) – Optional. Url of the thumbnail for the resultthumbnail_width (
int
) – Optional. Thumbnail widththumbnail_height (
int
) – Optional. Thumbnail height
- Returns:
Instance of the class
- Return type:
- property thumb_height: int¶
- property thumb_url: str¶
- property thumb_width: int¶
- class telebot.types.InlineQueryResultDocument(id: str, title: str, document_url: str, mime_type: str, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, description: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)¶
Bases:
InlineQueryResultBase
Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultdocument
- Parameters:
type (
str
) – Type of the result, must be documentid (
str
) – Unique identifier for this result, 1-64 bytestitle (
str
) – Title for the resultcaption (
str
) – Optional. Caption of the document to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the document caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modedocument_url (
str
) – A valid URL for the filemime_type (
str
) – MIME type of the content of the file, either “application/pdf” or “application/zip”description (
str
) – Optional. Short description of the resultreply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the filethumbnail_url (
str
) – Optional. URL of the thumbnail (JPEG only) for the filethumbnail_width (
int
) – Optional. Thumbnail widththumbnail_height (
int
) – Optional. Thumbnail height
- Returns:
Instance of the class
- Return type:
- property thumb_height: int¶
- property thumb_url: str¶
- property thumb_width: int¶
- class telebot.types.InlineQueryResultGame(id: str, game_short_name: str, reply_markup: InlineKeyboardMarkup | None = None)¶
Bases:
InlineQueryResultBase
Represents a Game.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultgame
- Parameters:
type (
str
) – Type of the result, must be gameid (
str
) – Unique identifier for this result, 1-64 bytesgame_short_name (
str
) – Short name of the gamereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the message
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultGif(id: str, gif_url: str, thumbnail_url: str, gif_width: int | None = None, gif_height: int | None = None, title: str | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, gif_duration: int | None = None, parse_mode: str | None = None, thumbnail_mime_type: str | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InlineQueryResultBase
Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultgif
- Parameters:
type (
str
) – Type of the result, must be gifid (
str
) – Unique identifier for this result, 1-64 bytesgif_url (
str
) – A valid URL for the GIF file. File size must not exceed 1MBgif_width (
int
) – Optional. Width of the GIFgif_height (
int
) – Optional. Height of the GIFgif_duration (
int
) – Optional. Duration of the GIF in secondsthumbnail_url (
str
) – URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the resultthumbnail_mime_type (
str
) – Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”title (
str
) – Optional. Title for the resultcaption (
str
) – Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the GIF animationshow_caption_above_media (
bool
) – Optional. If true, a caption is shown over the photo or video
- Returns:
Instance of the class
- Return type:
- property thumb_mime_type: str¶
- property thumb_url: str¶
- class telebot.types.InlineQueryResultLocation(id: str, title: str, latitude: float, longitude: float, horizontal_accuracy: float, live_period: int | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None, heading: int | None = None, proximity_alert_radius: int | None = None)¶
Bases:
InlineQueryResultBase
Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultlocation
- Parameters:
type (
str
) – Type of the result, must be locationid (
str
) – Unique identifier for this result, 1-64 Byteslatitude (
float
number) – Location latitude in degreeslongitude (
float
number) – Location longitude in degreestitle (
str
) – Location titlehorizontal_accuracy (
float
number) – Optional. The radius of uncertainty for the location, measured in meters; 0-1500live_period (
int
) – Optional. Period in seconds during which the location can be updated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely.heading (
int
) – Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.proximity_alert_radius (
int
) – Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.reply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the locationthumbnail_url (
str
) – Optional. Url of the thumbnail for the resultthumbnail_width (
int
) – Optional. Thumbnail widththumbnail_height (
int
) – Optional. Thumbnail height
- Returns:
Instance of the class
- Return type:
- property thumb_height: int¶
- property thumb_url: str¶
- property thumb_width: int¶
- class telebot.types.InlineQueryResultMpeg4Gif(id: str, mpeg4_url: str, thumbnail_url: str, mpeg4_width: int | None = None, mpeg4_height: int | None = None, title: str | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, mpeg4_duration: int | None = None, thumbnail_mime_type: str | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InlineQueryResultBase
Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
- Parameters:
type (
str
) – Type of the result, must be mpeg4_gifid (
str
) – Unique identifier for this result, 1-64 bytesmpeg4_url (
str
) – A valid URL for the MPEG4 file. File size must not exceed 1MBmpeg4_width (
int
) – Optional. Video widthmpeg4_height (
int
) – Optional. Video heightmpeg4_duration (
int
) – Optional. Video duration in secondsthumbnail_url (
str
) – URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the resultthumbnail_mime_type (
str
) – Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg”title (
str
) – Optional. Title for the resultcaption (
str
) – Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the video animationshow_caption_above_media (
bool
) – Optional. If true, a caption is shown over the photo or video
- Returns:
Instance of the class
- Return type:
- property thumb_mime_type: str¶
- property thumb_url: str¶
- class telebot.types.InlineQueryResultPhoto(id: str, photo_url: str, thumbnail_url: str, photo_width: int | None = None, photo_height: int | None = None, title: str | None = None, description: str | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InlineQueryResultBase
Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultphoto
- Parameters:
type (
str
) – Type of the result, must be photoid (
str
) – Unique identifier for this result, 1-64 bytesphoto_url (
str
) – A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MBthumbnail_url (
str
) – URL of the thumbnail for the photophoto_width (
int
) – Optional. Width of the photophoto_height (
int
) – Optional. Height of the phototitle (
str
) – Optional. Title for the resultdescription (
str
) – Optional. Short description of the resultcaption (
str
) – Optional. Caption of the photo to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the photo caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modereply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the photoshow_caption_above_media (
bool
) – Optional. If true, a caption is shown over the photo or video
- Returns:
Instance of the class
- Return type:
- property thumb_url: str¶
- class telebot.types.InlineQueryResultVenue(id: str, title: str, latitude: float, longitude: float, address: str, foursquare_id: str | None = None, foursquare_type: str | None = None, google_place_id: str | None = None, google_place_type: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)¶
Bases:
InlineQueryResultBase
Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultvenue
- Parameters:
type (
str
) – Type of the result, must be venueid (
str
) – Unique identifier for this result, 1-64 Byteslatitude (
float
) – Latitude of the venue location in degreeslongitude (
float
) – Longitude of the venue location in degreestitle (
str
) – Title of the venueaddress (
str
) – Address of the venuefoursquare_id (
str
) – Optional. Foursquare identifier of the venue if knownfoursquare_type (
str
) – Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)google_place_id (
str
) – Optional. Google Places identifier of the venuegoogle_place_type (
str
) – Optional. Google Places type of the venue. (See supported types.)reply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the venuethumbnail_url (
str
) – Optional. Url of the thumbnail for the resultthumbnail_width (
int
) – Optional. Thumbnail widththumbnail_height (
int
) – Optional. Thumbnail height
- Returns:
Instance of the class
- Return type:
- property thumb_height: int¶
- property thumb_url: str¶
- property thumb_width: int¶
- class telebot.types.InlineQueryResultVideo(id: str, video_url: str, mime_type: str, thumbnail_url: str, title: str, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, video_width: int | None = None, video_height: int | None = None, video_duration: int | None = None, description: str | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InlineQueryResultBase
Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultvideo
- Parameters:
type (
str
) – Type of the result, must be videoid (
str
) – Unique identifier for this result, 1-64 bytesvideo_url (
str
) – A valid URL for the embedded video player or video filemime_type (
str
) – MIME type of the content of the video URL, “text/html” or “video/mp4”thumbnail_url (
str
) – URL of the thumbnail (JPEG only) for the videotitle (
str
) – Title for the resultcaption (
str
) – Optional. Caption of the video to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the video caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modevideo_width (
int
) – Optional. Video widthvideo_height (
int
) – Optional. Video heightvideo_duration (
int
) – Optional. Video duration in secondsdescription (
str
) – Optional. Short description of the resultreply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).show_caption_above_media (
bool
) – Optional. If true, a caption is shown over the video
- Returns:
Instance of the class
- Return type:
- property thumb_url: str¶
- class telebot.types.InlineQueryResultVoice(id: str, voice_url: str, title: str, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, parse_mode: str | None = None, voice_duration: int | None = None, reply_markup: InlineKeyboardMarkup | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | None = None)¶
Bases:
InlineQueryResultBase
Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message.
Telegram Documentation: https://core.telegram.org/bots/api#inlinequeryresultvoice
- Parameters:
type (
str
) – Type of the result, must be voiceid (
str
) – Unique identifier for this result, 1-64 bytesvoice_url (
str
) – A valid URL for the voice recordingtitle (
str
) – Recording titlecaption (
str
) – Optional. Caption, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the voice message caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modevoice_duration (
int
) – Optional. Recording duration in secondsreply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the messageinput_message_content (
telebot.types.InputMessageContent
) – Optional. Content of the message to be sent instead of the voice recording
- Returns:
Instance of the class
- Return type:
- class telebot.types.InlineQueryResultsButton(text: str, web_app: WebAppInfo | None = None, start_parameter: str | None = None)¶
Bases:
JsonSerializable
,Dictionaryable
This object represents a button to be shown above inline query results. You must use exactly one of the optional fields.
Telegram documentation: https://core.telegram.org/bots/api#inlinequeryresultsbutton
- Parameters:
text (
str
) – Label text on the buttonweb_app (
telebot.types.WebAppInfo
) – Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method web_app_switch_inline_query inside the Web App.start_parameter (
str
) – Optional. Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a ‘Connect your YouTube account’ button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot’s inline capabilities.
- Returns:
Instance of the class
- Return type:
- class telebot.types.InputContactMessageContent(phone_number, first_name, last_name=None, vcard=None)¶
Bases:
Dictionaryable
Represents the content of a contact message to be sent as the result of an inline query.
Telegram Documentation: https://core.telegram.org/bots/api#inputcontactmessagecontent
- Parameters:
phone_number (
str
) – Contact’s phone numberfirst_name (
str
) – Contact’s first namelast_name (
str
) – Optional. Contact’s last namevcard (
str
) – Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
- Returns:
Instance of the class
- Return type:
- class telebot.types.InputFile(file: str | IOBase | Path, file_name: str | None = None)¶
Bases:
object
A class to send files through Telegram Bot API.
You need to pass a file, which should be an instance of
io.IOBase
orpathlib.Path
, orstr
.If you pass an
str
as a file, it will be opened and closed by the class.- Parameters:
file (
io.IOBase
orpathlib.Path
orstr
) – A file to send.
from telebot.types import InputFile # Sending a file from disk bot.send_document( chat_id, InputFile('/path/to/file/file.txt') ) # Sending a file from an io.IOBase object with open('/path/to/file/file.txt', 'rb') as f: bot.send_document( chat_id, InputFile(f) ) # Sending a file using pathlib.Path: bot.send_document( chat_id, InputFile(pathlib.Path('/path/to/file/file.txt')) )
- property file: IOBase | str¶
File object.
- property file_name: str¶
File name.
- class telebot.types.InputInvoiceMessageContent(title: str, description: str, payload: str, provider_token: str | None, currency: str, prices: List[LabeledPrice], max_tip_amount: int | None = None, suggested_tip_amounts: List[int] | None = None, provider_data: str | None = None, photo_url: str | None = None, photo_size: int | None = None, photo_width: int | None = None, photo_height: int | None = None, need_name: bool | None = None, need_phone_number: bool | None = None, need_email: bool | None = None, need_shipping_address: bool | None = None, send_phone_number_to_provider: bool | None = None, send_email_to_provider: bool | None = None, is_flexible: bool | None = None)¶
Bases:
Dictionaryable
Represents the content of an invoice message to be sent as the result of an inline query.
Telegram Documentation: https://core.telegram.org/bots/api#inputinvoicemessagecontent
- Parameters:
title (
str
) – Product name, 1-32 charactersdescription (
str
) – Product description, 1-255 characterspayload (
str
) – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.provider_token (
str
orNone
) – Payment provider token, obtained via @BotFather; To create invoice in stars, provide an empty token.currency (
str
) – Three-letter ISO 4217 currency code, see more on currenciesprices (
list
oftelebot.types.LabeledPrice
) – Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)max_tip_amount (
int
) – Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0suggested_tip_amounts (
list
ofint
) – Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.provider_data (
str
) – Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider. A detailed description of the required fields should be provided by the payment provider.photo_url (
str
) – Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.photo_size (
int
) – Optional. Photo size in bytesphoto_width (
int
) – Optional. Photo widthphoto_height (
int
) – Optional. Photo heightneed_name (
bool
) – Optional. Pass True, if you require the user’s full name to complete the orderneed_phone_number (
bool
) – Optional. Pass True, if you require the user’s phone number to complete the orderneed_email (
bool
) – Optional. Pass True, if you require the user’s email address to complete the orderneed_shipping_address (
bool
) – Optional. Pass True, if you require the user’s shipping address to complete the ordersend_phone_number_to_provider (
bool
) – Optional. Pass True, if the user’s phone number should be sent to providersend_email_to_provider (
bool
) – Optional. Pass True, if the user’s email address should be sent to provideris_flexible (
bool
) – Optional. Pass True, if the final price depends on the shipping method
- Returns:
Instance of the class
- Return type:
- class telebot.types.InputLocationMessageContent(latitude, longitude, horizontal_accuracy=None, live_period=None, heading=None, proximity_alert_radius=None)¶
Bases:
Dictionaryable
Represents the content of a location message to be sent as the result of an inline query.
Telegram Documentation: https://core.telegram.org/bots/api#inputlocationmessagecontent
- Parameters:
latitude (
float
) – Latitude of the location in degreeslongitude (
float
) – Longitude of the location in degreeshorizontal_accuracy (
float
number) – Optional. The radius of uncertainty for the location, measured in meters; 0-1500live_period (
int
) – Optional. Period in seconds during which the location can be updated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely.heading (
int
) – Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.proximity_alert_radius (
int
) – Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
- Returns:
Instance of the class
- Return type:
- class telebot.types.InputMedia(type, media, caption=None, parse_mode=None, caption_entities=None)¶
Bases:
Dictionaryable
,JsonSerializable
This object represents the content of a media message to be sent. It should be one of
- class telebot.types.InputMediaAnimation(media: str | InputFile, thumbnail: str | InputFile | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, width: int | None = None, height: int | None = None, duration: int | None = None, has_spoiler: bool | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InputMedia
Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.
Telegram Documentation: https://core.telegram.org/bots/api#inputmediaanimation
- Parameters:
media (
str
) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »thumbnail (InputFile or
str
) – Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »caption (
str
) – Optional. Caption of the animation to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the animation caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modewidth (
int
) – Optional. Animation widthheight (
int
) – Optional. Animation heightduration (
int
) – Optional. Animation duration in secondshas_spoiler (
bool
) – Optional. True, if the uploaded animation is a spoilershow_caption_above_media (
bool
) – Optional. True, if the caption should be shown above the animation
- Returns:
Instance of the class
- Return type:
- property thumb: str | Any | None¶
- class telebot.types.InputMediaAudio(media: str | InputFile, thumbnail: str | InputFile | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, duration: int | None = None, performer: str | None = None, title: str | None = None)¶
Bases:
InputMedia
Represents an audio file to be treated as music to be sent.
Telegram Documentation: https://core.telegram.org/bots/api#inputmediaaudio
- Parameters:
media (
str
) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »thumbnail (InputFile or
str
) – Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »caption (
str
) – Optional. Caption of the audio to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the audio caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modeduration (
int
) – Optional. Duration of the audio in secondsperformer (
str
) – Optional. Performer of the audiotitle (
str
) – Optional. Title of the audio
- Returns:
Instance of the class
- Return type:
- property thumb: str | Any | None¶
- class telebot.types.InputMediaDocument(media: str | InputFile, thumbnail: str | InputFile | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, disable_content_type_detection: bool | None = None)¶
Bases:
InputMedia
Represents a general file to be sent.
Telegram Documentation: https://core.telegram.org/bots/api#inputmediadocument
- Parameters:
media (
str
) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »thumbnail (InputFile or
str
) – Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »caption (
str
) – Optional. Caption of the document to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the document caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modedisable_content_type_detection (
bool
) – Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always True, if the document is sent as part of an album.
- Returns:
Instance of the class
- Return type:
- property thumb: str | Any | None¶
- class telebot.types.InputMediaPhoto(media: str | InputFile, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, has_spoiler: bool | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InputMedia
Represents a photo to be sent.
Telegram Documentation: https://core.telegram.org/bots/api#inputmediaphoto
- Parameters:
media (
str
) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »caption (
str
) – Optional. Caption of the photo to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the photo caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modehas_spoiler (
bool
) – Optional. True, if the uploaded photo is a spoilershow_caption_above_media (
bool
) – Optional. True, if the caption should be shown above the photo
- Returns:
Instance of the class
- Return type:
- class telebot.types.InputMediaVideo(media: str | InputFile, thumbnail: str | InputFile | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, width: int | None = None, height: int | None = None, duration: int | None = None, supports_streaming: bool | None = None, has_spoiler: bool | None = None, show_caption_above_media: bool | None = None)¶
Bases:
InputMedia
Represents a video to be sent.
Telegram Documentation: https://core.telegram.org/bots/api#inputmediavideo
- Parameters:
media (
str
) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »thumbnail (InputFile or
str
) – Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »caption (
str
) – Optional. Caption of the video to be sent, 0-1024 characters after entities parsingparse_mode (
str
) – Optional. Mode for parsing entities in the video caption. See formatting options for more details.caption_entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in the caption, which can be specified instead of parse_modewidth (
int
) – Optional. Video widthheight (
int
) – Optional. Video heightduration (
int
) – Optional. Video duration in secondssupports_streaming (
bool
) – Optional. Pass True, if the uploaded video is suitable for streaminghas_spoiler (
bool
) – Optional. True, if the uploaded video is a spoilershow_caption_above_media (
bool
) – Optional. True, if the caption should be shown above the video
- Returns:
Instance of the class
- Return type:
- property thumb: str | Any | None¶
- class telebot.types.InputPaidMedia(type: str, media: str | InputFile, **kwargs)¶
Bases:
JsonSerializable
- This object describes the paid media to be sent. Currently, it can be one of
InputPaidMediaPhoto InputPaidMediaVideo
Telegram documentation: https://core.telegram.org/bots/api#inputpaidmedia
- Returns:
Instance of the class
- Return type:
- to_dict()¶
- class telebot.types.InputPaidMediaPhoto(media: str | InputFile, **kwargs)¶
Bases:
InputPaidMedia
The paid media to send is a photo.
Telegram documentation: https://core.telegram.org/bots/api#inputpaidmediaphoto
- Parameters:
type (
str
) – Type of the media, must be photomedia (
str
) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »
- Returns:
Instance of the class
- Return type:
- class telebot.types.InputPaidMediaVideo(media: str | InputFile, thumbnail: InputFile | None = None, width: int | None = None, height: int | None = None, duration: int | None = None, supports_streaming: bool | None = None, **kwargs)¶
Bases:
InputPaidMedia
The paid media to send is a video.
Telegram documentation: https://core.telegram.org/bots/api#inputpaidmediavideo
- Parameters:
type (
str
) – Type of the media, must be videomedia (
str
) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files »thumbnail (
InputFile
) – Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files »width (
int
) – Optional. Video widthheight (
int
) – Optional. Video heightduration (
int
) – Optional. Video duration in secondssupports_streaming (
bool
) – Optional. Pass True if the uploaded video is suitable for streaming
- Returns:
Instance of the class
- Return type:
- to_dict()¶
- class telebot.types.InputPollOption(text: str, text_parse_mode: str | None = None, text_entities: List[MessageEntity] | None = None, **kwargs)¶
Bases:
JsonSerializable
This object contains information about one answer option in a poll to send.
Telegram Documentation: https://core.telegram.org/bots/api#inputpolloption
- Parameters:
text (
str
) – Option text, 1-100 characterstext_parse_mode (
str
) – Optional. Mode for parsing entities in the text. See formatting options for more details. Currently, only custom emoji entities are allowedtext_entities (
list
oftelebot.types.MessageEntity
) – Optional. A JSON-serialized list of special entities that appear in the poll option text. It can be specified instead of text_parse_mode
- Returns:
Instance of the class
- Return type:
- to_dict()¶
- class telebot.types.InputSticker(sticker: str | InputFile, emoji_list: List[str], format: str | None = None, mask_position: MaskPosition | None = None, keywords: List[str] | None = None)¶
Bases:
Dictionaryable
,JsonSerializable
This object describes a sticker to be added to a sticker set.
- Parameters:
sticker (
str
ortelebot.types.InputFile
) – The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video stickers can’t be uploaded via HTTP URL.emoji_list (
list
ofstr
) – One or more(up to 20) emoji(s) corresponding to the stickermask_position (
telebot.types.MaskPosition
) – Optional. Position where the mask should be placed on faces. For “mask” stickers only.keywords (
list
ofstr
) – Optional. List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only.format (
str
) – Format of the added sticker, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video
- Returns:
Instance of the class
- Return type:
- convert_input_sticker() Tuple[str, dict | None] ¶
- class telebot.types.InputTextMessageContent(message_text: str, parse_mode: str | None = None, entities: List[MessageEntity] | None = None, disable_web_page_preview: bool | None = None, link_preview_options: LinkPreviewOptions | None = None)¶
Bases:
Dictionaryable
Represents the content of a text message to be sent as the result of an inline query.
Telegram Documentation: https://core.telegram.org/bots/api#inputtextmessagecontent
- Parameters:
message_text (
str
) – Text of the message to be sent, 1-4096 charactersparse_mode (
str
) – Optional. Mode for parsing entities in the message text. See formatting options for more details.entities (
list
oftelebot.types.MessageEntity
) – Optional. List of special entities that appear in message text, which can be specified instead of parse_modedisable_web_page_preview (
bool
) – deprecatedlink_preview_options (
telebot.types.LinkPreviewOptions
) – Optional. Link preview generation options for the message
- Returns:
Instance of the class
- Return type:
- class telebot.types.InputVenueMessageContent(latitude, longitude, title, address, foursquare_id=None, foursquare_type=None, google_place_id=None, google_place_type=None)¶
Bases:
Dictionaryable
Represents the content of a venue message to be sent as the result of an inline query.
Telegram Documentation: https://core.telegram.org/bots/api#inputvenuemessagecontent
- Parameters:
latitude (
float
) – Latitude of the venue in degreeslongitude (
float
) – Longitude of the venue in degreestitle (
str
) – Name of the venueaddress (
str
) – Address of the venuefoursquare_id (
str
) – Optional. Foursquare identifier of the venue, if knownfoursquare_type (
str
) – Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)google_place_id (
str
) – Optional. Google Places identifier of the venuegoogle_place_type (
str
) – Optional. Google Places type of the venue. (See supported types.)
- Returns:
Instance of the class
- Return type:
- class telebot.types.Invoice(title, description, start_parameter, currency, total_amount, **kwargs)¶
Bases:
JsonDeserializable
This object contains basic information about an invoice.
Telegram Documentation: https://core.telegram.org/bots/api#invoice
- Parameters:
title (
str
) – Product namedescription (
str
) – Product descriptionstart_parameter (
str
) – Unique bot deep-linking parameter that can be used to generate this invoicecurrency (
str
) – Three-letter ISO 4217 currency codetotal_amount (
int
) – Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
- Returns:
Instance of the class
- Return type:
- class telebot.types.JsonDeserializable¶
Bases:
object
Subclasses of this class are guaranteed to be able to be created from a json-style dict or json formatted string. All subclasses of this class must override de_json.
- class telebot.types.JsonSerializable¶
Bases:
object
Subclasses of this class are guaranteed to be able to be converted to JSON format. All subclasses of this class must override to_json.
- class telebot.types.KeyboardButton(text: str, request_contact: bool | None = None, request_location: bool | None = None, request_poll: KeyboardButtonPollType | None = None, web_app: WebAppInfo | None = None, request_user: KeyboardButtonRequestUser | None = None, request_chat: KeyboardButtonRequestChat | None = None, request_users: KeyboardButtonRequestUsers | None = None)¶
Bases:
Dictionaryable
,JsonSerializable
This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields web_app, request_contact, request_location, and request_poll are mutually exclusive.
Telegram Documentation: https://core.telegram.org/bots/api#keyboardbutton
- Parameters:
text (
str
) – Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressedrequest_contact (
bool
) – Optional. 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 (
bool
) – Optional. If True, the user’s current location will be sent when the button is pressed. Available in private chats only.request_poll (
telebot.types.KeyboardButtonPollType
) – Optional. 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 (
telebot.types.WebAppInfo
) – Optional. 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.request_user (
telebot.types.KeyboardButtonRequestUser
) – deprecatedrequest_users (
telebot.types.KeyboardButtonRequestUsers
) – Optional. 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 (
telebot.types.KeyboardButtonRequestChat
) – Optional. 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.
- Returns:
Instance of the class
- Return type:
- class telebot.types.KeyboardButtonPollType(type=None)¶
Bases:
Dictionaryable
This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed.
Telegram Documentation: https://core.telegram.org/bots/api#keyboardbuttonpolltype
- Parameters:
type (
str
) – Optional. 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.- Returns:
Instance of the class
- Return type:
- class telebot.types.KeyboardButtonRequestChat(request_id: int, chat_is_channel: bool, chat_is_forum: bool | None = None, chat_has_username: bool | None = None, chat_is_created: bool | None = None, user_administrator_rights: ChatAdministratorRights | None = None, bot_administrator_rights: ChatAdministratorRights | None = None, bot_is_member: bool | None = None, request_title: bool | None = None, request_photo: bool | None = None, request_username: bool | None = None)¶
Bases:
Dictionaryable
This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed.
Telegram documentation: https://core.telegram.org/bots/api#keyboardbuttonrequestchat
- Parameters:
request_id (
int
) – Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the messagechat_is_channel (
bool
) – Pass True to request a channel chat, pass False to request a group or a supergroup chat.chat_is_forum (
bool
) – Optional. 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 (
bool
) – Optional. 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 (
bool
) – Optional. Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied.user_administrator_rights (
telebot.types.ChatAdministratorRights
) – Optional. 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 (
telebot.types.ChatAdministratorRights
) – Optional. 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 (
bool
) – Optional. Pass True to request a chat where the bot is a member. Otherwise, no additional restrictions are applied.request_title (
bool
) – Optional. Request titlerequest_photo (
bool
) – Optional. Request photorequest_username (
bool
) – Optional. Request username
- Returns:
Instance of the class
- Return type:
- class telebot.types.KeyboardButtonRequestUser(request_id: int, user_is_bot: bool | None = None, user_is_premium: bool | None = None, max_quantity: int | None = None)¶
Bases:
KeyboardButtonRequestUsers
Deprecated. Use KeyboardButtonRequestUsers instead.
- class telebot.types.KeyboardButtonRequestUsers(request_id: int, user_is_bot: bool | None = None, user_is_premium: bool | None = None, max_quantity: int | None = None, request_name: bool | None = None, request_username: bool | None = None, request_photo: bool | None = None)¶
Bases:
Dictionaryable
This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed.
Telegram documentation: https://core.telegram.org/bots/api#keyboardbuttonrequestusers
- Parameters:
request_id (
int
) – Signed 32-bit identifier of the request, which will be received back in the UsersShared object. Must be unique within the messageuser_is_bot (
bool
) – Optional. Pass True to request a bot, pass False to request a regular user. If not specified, no additional restrictions are applied.user_is_premium (
bool
) – Optional. Pass True to request a premium user, pass False to request a non-premium user. If not specified, no additional restrictions are applied.max_quantity (
int
) – Optional. The maximum number of users to be selected; 1-10. Defaults to 1.request_name (
bool
) – Optional. Request namerequest_username (
bool
) – Optional. Request usernamerequest_photo (
bool
) – Optional. Request photo
- Returns:
Instance of the class
- Return type:
- class telebot.types.LabeledPrice(label, amount)¶
Bases:
JsonSerializable
,Dictionaryable
This object represents a portion of the price for goods or services.
Telegram Documentation: https://core.telegram.org/bots/api#labeledprice
- Parameters:
label (
str
) – Portion labelamount (
int
) – Price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
- Returns:
Instance of the class
- Return type:
- class telebot.types.LinkPreviewOptions(is_disabled: bool | None = None, url: str | None = None, prefer_small_media: bool | None = None, prefer_large_media: bool | None = None, show_above_text: bool | None = None, **kwargs)¶
Bases:
JsonDeserializable
,Dictionaryable
,JsonSerializable
Describes the options used for link preview generation.
Telegram documentation: https://core.telegram.org/bots/api#linkpreviewoptions
- Parameters:
is_disabled (
bool
) – Optional. True, if the link preview is disabledurl (
str
) – Optional. URL to use for the link preview. If empty, then the first URL found in the message text will be usedprefer_small_media (
bool
) – Optional. 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 previewprefer_large_media (
bool
) – Optional. 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 previewshow_above_text (
bool
) – Optional. True, if the link preview must be shown above the message text; otherwise, the link preview will be shown below the message text
- Returns:
Instance of the class
- Return type:
- class telebot.types.Location(longitude, latitude, horizontal_accuracy=None, live_period=None, heading=None, proximity_alert_radius=None, **kwargs)¶
Bases:
JsonDeserializable
,JsonSerializable
,Dictionaryable
This object represents a point on the map.
Telegram Documentation: https://core.telegram.org/bots/api#location
- Parameters:
longitude (
float
) – Longitude as defined by senderlatitude (
float
) – Latitude as defined by senderhorizontal_accuracy (
float
number) – Optional. The radius of uncertainty for the location, measured in meters; 0-1500live_period (
int
) – Optional. Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only.heading (
int
) – Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only.proximity_alert_radius (
int
) – Optional. The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only.
- Returns:
Instance of the class
- Return type:
- class telebot.types.LoginUrl(url: str, forward_text: str | None = None, bot_username: str | None = None, request_write_access: bool | None = None, **kwargs)¶
Bases:
Dictionaryable
,JsonSerializable
,JsonDeserializable
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:
Telegram Documentation: https://core.telegram.org/bots/api#loginurl
- Parameters:
url (
str
) – 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 (
str
) – Optional. New text of the button in forwarded messages.bot_username (
str
) – Optional. 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 (
bool
) – Optional. Pass True to request the permission for your bot to send messages to the user.
- Returns:
Instance of the class
- Return type:
- class telebot.types.MaskPosition(point, x_shift, y_shift, scale, **kwargs)¶
Bases:
Dictionaryable
,JsonDeserializable
,JsonSerializable
This object describes the position on faces where a mask should be placed by default.
Telegram Documentation: https://core.telegram.org/bots/api#maskposition
- Parameters:
point (
str
) – The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”.x_shift (
float
number) – Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position.y_shift (
float
number) – Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position.scale (
float
number) – Mask scaling coefficient. For example, 2.0 means double size.
- Returns:
Instance of the class
- Return type:
- class telebot.types.MenuButton¶
Bases:
JsonDeserializable
,JsonSerializable
,Dictionaryable
This object describes the bot’s menu button in a private chat. It should be one of
If a menu button other than MenuButtonDefault is set for a private chat, then it is applied in the chat. Otherwise the default menu button is applied. By default, the menu button opens the list of bot commands.
- class telebot.types.MenuButtonCommands(type: str = None, **kwargs)¶
Bases:
MenuButton
Represents a menu button, which opens the bot’s list of commands.
Telegram Documentation: https://core.telegram.org/bots/api#menubuttoncommands
- Parameters:
type (
str
) – Type of the button, must be commands- Returns:
Instance of the class
- Return type:
- class telebot.types.MenuButtonDefault(type: str = None, **kwargs)¶
Bases:
MenuButton
Describes that no specific value for the menu button was set.
Telegram Documentation: https://core.telegram.org/bots/api#menubuttondefault
- Parameters:
type (
str
) – Type of the button, must be default- Returns:
Instance of the class
- Return type:
- class telebot.types.MenuButtonWebApp(type: str, text: str, web_app: WebAppInfo, **kwargs)¶
Bases:
MenuButton
Represents a menu button, which launches a Web App.
Telegram Documentation: https://core.telegram.org/bots/api#menubuttonwebapp
- Parameters:
type (
str
) – Type of the button, must be web_apptext (
str
) – Text on the buttonweb_app (
telebot.types.WebAppInfo
) – 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. Alternatively, a t.me link to a Web App of the bot can be specified in the object instead of the Web App’s URL, in which case the Web App will be opened as if the user pressed the link.
- Returns:
Instance of the class
- Return type:
- class telebot.types.Message(message_id, from_user, date, chat, content_type, options, json_string)¶
Bases:
JsonDeserializable
This object represents a message.
Telegram Documentation: https://core.telegram.org/bots/api#message
- Parameters:
message_id (
int
) – Unique message identifier inside this chatmessage_thread_id (
int
) – Optional. Unique identifier of a message thread to which the message belongs; for supergroups onlyfrom_user (
telebot.types.User
) – Optional. 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 (
telebot.types.Chat
) – Optional. 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 (
int
) – Optional. If the sender of the message boosted the chat, the number of boosts added by the userinfo (sender_business_bot) – Optional. Information about the business bot that sent the message
date (
int
) – Date the message was sent in Unix timebusiness_connection_id (
str
) – Optional. Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.chat (
telebot.types.Chat
) – Conversation the message belongs tois_topic_message (
bool
) – Optional. True, if the message is sent to a forum topicis_automatic_forward (
bool
) – Optional.bool
, if the message is a channel post that was automatically forwarded to the connected discussion groupreply_to_message (
telebot.types.Message
) – Optional. For replies, 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.external_reply (
telebot.types.ExternalReplyInfo
) – Optional. Information about the message that is being replied to, which may come from another chat or forum topicquote (
telebot.types.TextQuote
) – Optional. For replies that quote part of the original message, the quoted part of the messagereply_to_story (
telebot.types.Story
) – Optional. For replies to a story, the original storyvia_bot (
telebot.types.User
) – Optional. Bot through which the message was sentedit_date (
int
) – Optional. Date the message was last edited in Unix timehas_protected_content (
bool
) – Optional.bool
, if the message can’t be forwardedis_from_offline (
bool
) – Optional. True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled messagemedia_group_id (
str
) – Optional. The unique identifier of a media message group this message belongs toauthor_signature (
str
) – Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administratortext (
str
) – Optional. For text messages, the actual UTF-8 text of the messageentities (
list
oftelebot.types.MessageEntity
) – Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the textlink_preview_options (
telebot.types.LinkPreviewOptions
) – Optional. Options used for link preview generation for the message, if it is a text message and link preview options were changedeffect_id (
str
) – Optional. Unique identifier of the message effect added to the messageanimation (
telebot.types.Animation
) – Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be setaudio (
telebot.types.Audio
) – Optional. Message is an audio file, information about the filedocument (
telebot.types.Document
) – Optional. Message is a general file, information about the filepaid_media (
telebot.types.PaidMediaInfo
) – Optional. Message contains paid media; information about the paid mediaphoto (
list
oftelebot.types.PhotoSize
) – Optional. Message is a photo, available sizes of the photosticker (
telebot.types.Sticker
) – Optional. Message is a sticker, information about the stickerstory (
telebot.types.Story
) – Optional. Message is a forwarded storyvideo (
telebot.types.Video
) – Optional. Message is a video, information about the videovideo_note (
telebot.types.VideoNote
) – Optional. Message is a video note, information about the video messagevoice (
telebot.types.Voice
) – Optional. Message is a voice message, information about the filecaption (
str
) – Optional. Caption for the animation, audio, document, photo, video or voicecaption_entities (
list
oftelebot.types.MessageEntity
) – Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the captionshow_caption_above_media (
bool
) – Optional. True, if the caption must be shown above the message mediahas_media_spoiler (
bool
) – Optional. True, if the message media is covered by a spoiler animationcontact (
telebot.types.Contact
) – Optional. Message is a shared contact, information about the contactdice (
telebot.types.Dice
) – Optional. Message is a dice with random valuegame (
telebot.types.Game
) – Optional. Message is a game, information about the game. More about games »poll (
telebot.types.Poll
) – Optional. Message is a native poll, information about the pollvenue (
telebot.types.Venue
) – Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be setlocation (
telebot.types.Location
) – Optional. Message is a shared location, information about the locationnew_chat_members (
list
oftelebot.types.User
) – Optional. 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 (
telebot.types.User
) – Optional. A member was removed from the group, information about them (this member may be the bot itself)new_chat_title (
str
) – Optional. A chat title was changed to this valuenew_chat_photo (
list
oftelebot.types.PhotoSize
) – Optional. A chat photo was change to this valuedelete_chat_photo (
bool
) – Optional. Service message: the chat photo was deletedgroup_chat_created (
bool
) – Optional. Service message: the group has been createdsupergroup_chat_created (
bool
) – Optional. 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 (
bool
) – Optional. 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.message_auto_delete_timer_changed (
telebot.types.MessageAutoDeleteTimerChanged
) – Optional. Service message: auto-delete timer settings changed in the chatmigrate_to_chat_id (
int
) – Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.migrate_from_chat_id (
int
) – Optional. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.pinned_message (
telebot.types.Message
ortelebot.types.InaccessibleMessage
) – Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.invoice (
telebot.types.Invoice
) – Optional. Message is an invoice for a payment, information about the invoice. More about payments »successful_payment (
telebot.types.SuccessfulPayment
) – Optional. Message is a service message about a successful payment, information about the payment. More about payments »refunded_payment (
telebot.types.RefundedPayment
) – Optional. Message is a service message about a refunded payment, information about the payment. More about payments »users_shared (
telebot.types.UsersShared
) – Optional. Service message: a user was shared with the botchat_shared (
telebot.types.ChatShared
) – Optional. Service message: a chat was shared with the botconnected_website (
str
) – Optional. The domain name of the website on which the user has logged in. More about Telegram Login »write_access_allowed (
telebot.types.WriteAccessAllowed
) – Optional. Service message: the user allowed the bot added to the attachment menu to write messagespassport_data (
telebot.types.PassportData
) – Optional. Telegram Passport dataproximity_alert_triggered (
telebot.types.ProximityAlertTriggered
) – Optional. Service message. A user in the chat triggered another user’s proximity alert while sharing Live Location.boost_added (
telebot.types.ChatBoostAdded
) – Optional. Service message: user boosted the chatchat_background_set (
telebot.types.ChatBackground
) – Optional. Service message: chat background setforum_topic_created (
telebot.types.ForumTopicCreated
) – Optional. Service message: forum topic createdforum_topic_edited (
telebot.types.ForumTopicEdited
) – Optional. Service message: forum topic editedforum_topic_closed (
telebot.types.ForumTopicClosed
) – Optional. Service message: forum topic closedforum_topic_reopened (
telebot.types.ForumTopicReopened
) – Optional. Service message: forum topic reopenedgeneral_forum_topic_hidden (
telebot.types.GeneralForumTopicHidden
) – Optional. Service message: the ‘General’ forum topic hiddengeneral_forum_topic_unhidden (
telebot.types.GeneralForumTopicUnhidden
) – Optional. Service message: the ‘General’ forum topic unhiddengiveaway_created (
telebot.types.GiveawayCreated
) – Optional. Service message: a giveaway has been createdgiveaway (
telebot.types.Giveaway
) – Optional. The message is a scheduled giveaway messagegiveaway_winners (
telebot.types.GiveawayWinners
) – Optional. Service message: giveaway winners(public winners)giveaway_completed (
telebot.types.GiveawayCompleted
) – Optional. Service message: giveaway completed, without public winnersvideo_chat_scheduled (
telebot.types.VideoChatScheduled
) – Optional. Service message: video chat scheduledvideo_chat_started (
telebot.types.VideoChatStarted
) – Optional. Service message: video chat startedvideo_chat_ended (
telebot.types.VideoChatEnded
) – Optional. Service message: video chat endedvideo_chat_participants_invited (
telebot.types.VideoChatParticipantsInvited
) – Optional. Service message: new participants invited to a video chatweb_app_data (
telebot.types.WebAppData
) – Optional. Service message: data sent by a Web Appreply_markup (
telebot.types.InlineKeyboardMarkup
) – Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.
- Forward_origin:
Optional. For forwarded messages, information about the original message;
- Returns:
Instance of the class
- Return type:
- property any_entities: List[MessageEntity] | None¶
- property any_text: str | None¶
- property forward_date¶
- property forward_from¶
- property forward_from_chat¶
- property forward_from_message_id¶
- property forward_sender_name¶
- property forward_signature¶
Returns html-rendered caption.
- property html_text: str | None¶
Returns html-rendered text.
- property new_chat_member¶
- classmethod parse_entities(message_entity_array) List[MessageEntity] ¶
Parses message entity array.
- property voice_chat_ended¶
- property voice_chat_participants_invited¶
- property voice_chat_scheduled¶
- property voice_chat_started¶
- class telebot.types.MessageAutoDeleteTimerChanged(message_auto_delete_time, **kwargs)¶
Bases:
JsonDeserializable
This object represents a service message about a change in auto-delete timer settings.
Telegram Documentation: https://core.telegram.org/bots/api#messageautodeletetimerchanged
- Parameters:
message_auto_delete_time (
int
) – New auto-delete time for messages in the chat; in seconds- Returns:
Instance of the class
- Return type:
- class telebot.types.MessageEntity(type, offset, length, url=None, user=None, language=None, custom_emoji_id=None, **kwargs)¶
Bases:
Dictionaryable
,JsonSerializable
,JsonDeserializable
This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
Telegram Documentation: https://core.telegram.org/bots/api#messageentity
- Parameters:
type (
str
) – Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag or #hashtag@chatusername), “cashtag” ($USD or $USD@chatusername), “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), “expandable_blockquote” (collapsed-by-default 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 (
int
) – Offset in UTF-16 code units to the start of the entitylength (
int
) – Length of the entity in UTF-16 code unitsurl (
str
) – Optional. For “text_link” only, URL that will be opened after user taps on the textuser (
telebot.types.User
) – Optional. For “text_mention” only, the mentioned userlanguage (
str
) – Optional. For “pre” only, the programming language of the entity textcustom_emoji_id (
str
) – Optional. For “custom_emoji” only, unique identifier of the custom emoji. Use get_custom_emoji_stickers to get full information about the sticker.
- Returns:
Instance of the class
- Return type:
- static to_list_of_dicts(entity_list) List[Dict] | None ¶
Converts a list of MessageEntity objects to a list of dictionaries.
- class telebot.types.MessageID(message_id, **kwargs)¶
Bases:
JsonDeserializable
This object represents a unique message identifier.
Telegram Documentation: https://core.telegram.org/bots/api#messageid
- Parameters:
message_id (
int
) – Unique message identifier- Returns:
Instance of the class
- Return type:
telebot.types.MessageId
- class telebot.types.MessageOrigin(type: str, date: int)¶
Bases:
JsonDeserializable
This object describes the origin of a message.
Telegram documentation: https://core.telegram.org/bots/api#messageorigin
- Parameters:
type (
str
) – Type of the message origindate (
int
) – Date the message was sent originally in Unix timesender_user (
User
) – User that sent the message originally (for MessageOriginUser)sender_user_name (
str
) – Name of the user that sent the message originally (for MessageOriginHiddenUser)sender_chat (
Chat
) – Chat that sent the message originally (for MessageOriginChat)author_signature (
str
) – Optional. Author signature for certain cases
- Returns:
Instance of the class
- Return type:
- class telebot.types.MessageOriginChannel(date: int, chat: Chat, message_id: int, author_signature: str | None = None)¶
Bases:
MessageOrigin
The message was originally sent to a channel chat.
- Parameters:
chat (
Chat
) – Channel chat to which the message was originally sentmessage_id (
int
) – Unique message identifier inside the chatauthor_signature (
str
) – Optional. Signature of the original post author
- class telebot.types.MessageOriginChat(date: int, sender_chat: Chat, author_signature: str | None = None)¶
Bases:
MessageOrigin
The message was originally sent on behalf of a chat to a group chat.
- Parameters:
sender_chat (
Chat
) – Chat that sent the message originallyauthor_signature (
str
) – Optional. For messages originally sent by an anonymous chat administrator, original message author signature
- class telebot.types.MessageOriginHiddenUser(date: int, sender_user_name: str)¶
Bases:
MessageOrigin
The message was originally sent by an unknown user.
- Parameters:
sender_user_name (
str
) – Name of the user that sent the message originally
- class telebot.types.MessageOriginUser(date: int, sender_user: User)¶
Bases:
MessageOrigin
The message was originally sent by a known user.
- Parameters:
sender_user (
User
) – User that sent the message originally
- class telebot.types.MessageReactionCountUpdated(chat: Chat, message_id: int, date: int, reactions: List[ReactionCount], **kwargs)¶
Bases:
JsonDeserializable
This object represents a service message about a change in the list of the current user’s reactions to a message.
Telegram documentation: https://core.telegram.org/bots/api#messagereactioncountupdated
- Parameters:
chat (
telebot.types.Chat
) – The chat containing the messagemessage_id (
int
) – Unique message identifier inside the chatdate (
int
) – Date of the change in Unix timereactions (
list
ofReactionCount
) – List of reactions that are present on the message
- Returns:
Instance of the class
- Return type:
- class telebot.types.MessageReactionUpdated(chat: Chat, message_id: int, date: int, old_reaction: List[ReactionType], new_reaction: List[ReactionType], user: User | None = None, actor_chat: Chat | None = None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a service message about a change in the list of the current user’s reactions to a message.
Telegram documentation: https://core.telegram.org/bots/api#messagereactionupdated
- Parameters:
chat (
telebot.types.Chat
) – The chat containing the message the user reacted tomessage_id (
int
) – Unique identifier of the message inside the chatuser (
telebot.types.User
) – Optional. The user that changed the reaction, if the user isn’t anonymousactor_chat (
telebot.types.Chat
) – Optional. The chat on behalf of which the reaction was changed, if the user is anonymousdate (
int
) – Date of the change in Unix timeold_reaction (
list
ofReactionType
) – Previous list of reaction types that were set by the usernew_reaction (
list
ofReactionType
) – New list of reaction types that have been set by the user
- Returns:
Instance of the class
- Return type:
- class telebot.types.OrderInfo(name=None, phone_number=None, email=None, shipping_address=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents information about an order.
Telegram Documentation: https://core.telegram.org/bots/api#orderinfo
- Parameters:
name (
str
) – Optional. User namephone_number (
str
) – Optional. User’s phone numberemail (
str
) – Optional. User emailshipping_address (
telebot.types.ShippingAddress
) – Optional. User shipping address
- Returns:
Instance of the class
- Return type:
- class telebot.types.PaidMedia¶
Bases:
JsonDeserializable
This object describes paid media. Currently, it can be one of
PaidMediaPreview PaidMediaPhoto PaidMediaVideo
Telegram documentation: https://core.telegram.org/bots/api#paidmedia
- Returns:
Instance of the class
- Return type:
- class telebot.types.PaidMediaInfo(star_count, paid_media, **kwargs)¶
Bases:
JsonDeserializable
Describes the paid media added to a message.
Telegram documentation: https://core.telegram.org/bots/api#paidmediainfo
- Parameters:
star_count (
int
) – The number of Telegram Stars that must be paid to buy access to the mediapaid_media (
list
ofPaidMedia
) – Information about the paid media
- Returns:
Instance of the class
- Return type:
- class telebot.types.PaidMediaPhoto(type, photo, **kwargs)¶
Bases:
PaidMedia
The paid media is a photo.
Telegram documentation: https://core.telegram.org/bots/api#paidmediaphoto
- Parameters:
type (
str
) – Type of the paid media, always “photo”photo (
list
ofPhotoSize
) – The photo
- Returns:
Instance of the class
- Return type:
- class telebot.types.PaidMediaPreview(type, width=None, height=None, duration=None, **kwargs)¶
Bases:
PaidMedia
The paid media isn’t available before the payment.
Telegram documentation: https://core.telegram.org/bots/api#paidmediapreview
- Parameters:
type (
str
) – Type of the paid media, always “preview”width (
int
) – Optional. Media width as defined by the senderheight (
int
) – Optional. Media height as defined by the senderduration (
int
) – Optional. Duration of the media in seconds as defined by the sender
- Returns:
Instance of the class
- Return type:
- class telebot.types.PaidMediaPurchased(from_user, paid_media_payload, **kwargs)¶
Bases:
JsonDeserializable
This object contains information about a paid media purchase.
Telegram documentation: https://core.telegram.org/bots/api#paidmediapurchased
- Parameters:
from_user (
User
) – User who purchased the mediapaid_media_payload (
str
) – Bot-specified paid media payload
- Returns:
Instance of the class
- Return type:
- class telebot.types.PaidMediaVideo(type, video, **kwargs)¶
Bases:
PaidMedia
The paid media is a video.
Telegram documentation: https://core.telegram.org/bots/api#paidmediavideo
- Parameters:
type (
str
) – Type of the paid media, always “video”video (
Video
) – The video
- Returns:
Instance of the class
- Return type:
- class telebot.types.PhotoSize(file_id, file_unique_id, width, height, file_size=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents one size of a photo or a file / sticker thumbnail.
Telegram Documentation: https://core.telegram.org/bots/api#photosize
- Parameters:
file_id (
str
) – Identifier for this file, which can be used to download or reuse the filefile_unique_id (
str
) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.width (
int
) – Photo widthheight (
int
) – Photo heightfile_size (
int
) – Optional. File size in bytes
- Returns:
Instance of the class
- Return type:
- class telebot.types.Poll(question: str, options: List[PollOption], poll_id: str = None, total_voter_count: int = None, is_closed: bool = None, is_anonymous: bool = None, type: str = None, allows_multiple_answers: bool = None, correct_option_id: int = None, explanation: str = None, explanation_entities: List[MessageEntity] = None, open_period: int = None, close_date: int = None, poll_type: str = None, question_entities: List[MessageEntity] = None, **kwargs)¶
Bases:
JsonDeserializable
This object contains information about a poll.
Telegram Documentation: https://core.telegram.org/bots/api#poll
- Parameters:
id (
str
) – Unique poll identifierquestion (
str
) – Poll question, 1-300 charactersoptions (
list
oftelebot.types.PollOption
) – List of poll optionstotal_voter_count (
int
) – Total number of users that voted in the pollis_closed (
bool
) – True, if the poll is closedis_anonymous (
bool
) – True, if the poll is anonymoustype (
str
) – Poll type, currently can be “regular” or “quiz”allows_multiple_answers (
bool
) – True, if the poll allows multiple answerscorrect_option_id (
int
) – Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.explanation (
str
) – Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 charactersexplanation_entities (
list
oftelebot.types.MessageEntity
) – Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanationopen_period (
int
) – Optional. Amount of time in seconds the poll will be active after creationclose_date (
int
) – Optional. Point in time (Unix timestamp) when the poll will be automatically closedquestion_entities (
list
oftelebot.types.MessageEntity
) – Optional. Special entities that appear in the question. Currently, only custom emoji entities are allowed in poll questions
- Returns:
Instance of the class
- Return type:
- add(option)¶
Add an option to the poll.
- Parameters:
option (
telebot.types.PollOption
orstr
) – Option to add
- class telebot.types.PollAnswer(poll_id: str, option_ids: List[int], user: User | None = None, voter_chat: Chat | None = None, **kwargs)¶
Bases:
JsonSerializable
,JsonDeserializable
,Dictionaryable
This object represents an answer of a user in a non-anonymous poll.
Telegram Documentation: https://core.telegram.org/bots/api#pollanswer
- Parameters:
poll_id (
str
) – Unique poll identifiervoter_chat (
telebot.types.Chat
) – Optional. The chat that changed the answer to the poll, if the voter is anonymoususer (
telebot.types.User
) – Optional. The user, who changed the answer to the polloption_ids (
list
ofint
) – 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote.
- Returns:
Instance of the class
- Return type:
- class telebot.types.PollOption(text, voter_count=0, text_entities=None, **kwargs)¶
Bases:
JsonDeserializable
This object contains information about one answer option in a poll.
Telegram Documentation: https://core.telegram.org/bots/api#polloption
- Parameters:
text (
str
) – Option text, 1-100 charactersvoter_count (
int
) – Number of users that voted for this optiontext_entities (
list
oftelebot.types.MessageEntity
) – Optional. Special entities that appear in the option text. Currently, only custom emoji entities are allowed in poll option texts
- Returns:
Instance of the class
- Return type:
- class telebot.types.PreCheckoutQuery(id, from_user, currency, total_amount, invoice_payload, shipping_option_id=None, order_info=None, **kwargs)¶
Bases:
JsonDeserializable
This object contains information about an incoming pre-checkout query.
Telegram Documentation: https://core.telegram.org/bots/api#precheckoutquery
- Parameters:
id (
str
) – Unique query identifierfrom (
telebot.types.User
) – User who sent the querycurrency (
str
) – Three-letter ISO 4217 currency codetotal_amount (
int
) – Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).invoice_payload (
str
) – Bot specified invoice payloadshipping_option_id (
str
) – Optional. Identifier of the shipping option chosen by the userorder_info (
telebot.types.OrderInfo
) – Optional. Order information provided by the user
- Returns:
Instance of the class
- Return type:
- class telebot.types.ProximityAlertTriggered(traveler, watcher, distance, **kwargs)¶
Bases:
JsonDeserializable
This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user.
Telegram Documentation: https://core.telegram.org/bots/api#proximityalerttriggered
- Parameters:
traveler (
telebot.types.User
) – User that triggered the alertwatcher (
telebot.types.User
) – User that set the alertdistance (
int
) – The distance between the users
- Returns:
Instance of the class
- Return type:
- class telebot.types.ReactionCount(type: ReactionType, total_count: int, **kwargs)¶
Bases:
JsonDeserializable
This object represents a reaction added to a message along with the number of times it was added.
Telegram documentation: https://core.telegram.org/bots/api#reactioncount
- Parameters:
type (
ReactionType
) – Type of the reactiontotal_count (
int
) – Number of times the reaction was added
- Returns:
Instance of the class
- Return type:
- class telebot.types.ReactionType(type: str)¶
Bases:
JsonDeserializable
,Dictionaryable
,JsonSerializable
This object represents a reaction type.
Telegram documentation: https://core.telegram.org/bots/api#reactiontype
- Parameters:
type (
str
) – Type of the reaction- Returns:
Instance of the class
- Return type:
- class telebot.types.ReactionTypeCustomEmoji(custom_emoji_id: str, **kwargs)¶
Bases:
ReactionType
This object represents a custom emoji reaction type.
Telegram documentation: https://core.telegram.org/bots/api#reactiontypecustomemoji
- Parameters:
type (
str
) – Type of the reaction, must be custom_emojicustom_emoji_id (
str
) – Identifier of the custom emoji
- Returns:
Instance of the class
- Return type:
- class telebot.types.ReactionTypeEmoji(emoji: str, **kwargs)¶
Bases:
ReactionType
This object represents an emoji reaction type.
Telegram documentation: https://core.telegram.org/bots/api#reactiontypeemoji
- Parameters:
type (
str
) – Type of the reaction, must be emojiemoji (
str
) – Reaction emoji. List is available on the API doc.
- Returns:
Instance of the class
- Return type:
- class telebot.types.ReactionTypePaid(**kwargs)¶
Bases:
ReactionType
This object represents a paid reaction type.
Telegram documentation: https://core.telegram.org/bots/api#reactiontypepaid
- Parameters:
type (
str
) – Type of the reaction, must be paid- Returns:
Instance of the class
- Return type:
- class telebot.types.RefundedPayment(currency, total_amount, invoice_payload, telegram_payment_charge_id, provider_payment_charge_id=None, **kwargs)¶
Bases:
JsonDeserializable
This object contains basic information about a refunded payment.
Telegram documentation: https://core.telegram.org/bots/api#refundedpayment
- Parameters:
currency (
str
) – Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars. Currently, always “XTR”total_amount (
int
) – Total refunded price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45, total_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).invoice_payload (
str
) – Bot-specified invoice payloadtelegram_payment_charge_id (
str
) – Telegram payment identifierprovider_payment_charge_id (
str
) – Optional. Provider payment identifier
- Returns:
Instance of the class
- Return type:
- class telebot.types.ReplyKeyboardMarkup(resize_keyboard: bool | None = None, one_time_keyboard: bool | None = None, selective: bool | None = None, row_width: int = 3, input_field_placeholder: str | None = None, is_persistent: bool | None = None)¶
Bases:
JsonSerializable
This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
from telebot.types import ReplyKeyboardMarkup, KeyboardButton markup = ReplyKeyboardMarkup(resize_keyboard=True) markup.add(KeyboardButton('Text')) # or: markup.add('Text') # display this markup: bot.send_message(chat_id, 'Text', reply_markup=markup)
Telegram Documentation: https://core.telegram.org/bots/api#replykeyboardmarkup
- Parameters:
keyboard (
list
oflist
oftelebot.types.KeyboardButton
) –list
of button rows, each represented by anlist
oftelebot.types.KeyboardButton
objectsresize_keyboard (
bool
) – Optional. 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 (
bool
) – Optional. 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 (
str
) – Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 charactersselective (
bool
) – Optional. 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.is_persistent –
Optional. 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 (has reply_to_message_id), 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.
- Returns:
Instance of the class
- Return type:
- add(*args, row_width=None) ReplyKeyboardMarkup ¶
This function adds strings to the keyboard, while not exceeding row_width. E.g. ReplyKeyboardMarkup#add(“A”, “B”, “C”) yields the json result {keyboard: [[“A”], [“B”], [“C”]]} when row_width is set to 1. When row_width is set to 2, the following is the result of this function: {keyboard: [[“A”, “B”], [“C”]]} See https://core.telegram.org/bots/api#replykeyboardmarkup
- Parameters:
args (
str
ortelebot.types.KeyboardButton
) – KeyboardButton to append to the keyboardrow_width (
int
) – width of row
- Returns:
self, to allow function chaining.
- Return type:
- max_row_keys = 12¶
- row(*args) ReplyKeyboardMarkup ¶
Adds a list of KeyboardButton to the keyboard. This function does not consider row_width. ReplyKeyboardMarkup#row(“A”)#row(“B”, “C”)#to_json() outputs ‘{keyboard: [[“A”], [“B”, “C”]]}’ See https://core.telegram.org/bots/api#replykeyboardmarkup
- Parameters:
args (
str
) – strings- Returns:
self, to allow function chaining.
- Return type:
- class telebot.types.ReplyKeyboardRemove(selective: bool | None = None)¶
Bases:
JsonSerializable
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).
Telegram Documentation: https://core.telegram.org/bots/api#replykeyboardremove
- Parameters:
remove_keyboard (
bool
) – 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) Note that this parameter is set to True by default by the library. You cannot modify it.selective (
bool
) – Optional. Use this parameter if you want to remove the keyboard for 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 (has reply_to_message_id), sender of the original message.Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven’t voted yet.
- Returns:
Instance of the class
- Return type:
- class telebot.types.ReplyParameters(message_id: int, chat_id: int | str | None = None, allow_sending_without_reply: bool | None = None, quote: str | None = None, quote_parse_mode: str | None = None, quote_entities: List[MessageEntity] | None = None, quote_position: int | None = None, **kwargs)¶
Bases:
JsonDeserializable
,Dictionaryable
,JsonSerializable
Describes reply parameters for the message that is being sent.
Telegram documentation: https://core.telegram.org/bots/api#replyparameters
- Parameters:
message_id (
int
) – Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specifiedchat_id (
int
orstr
) – Optional. 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 (
bool
) – Optional. 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 (
str
) – Optional. 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 (
str
) – Optional. Mode for parsing entities in the quote. See formatting options for more details.quote_entities (
list
ofMessageEntity
) – Optional. A JSON-serialized list of special entities that appear in the quote. It can be specified instead of quote_parse_mode.quote_position (
int
) – Optional. Position of the quote in the original message in UTF-16 code units
- Returns:
Instance of the class
- Return type:
- class telebot.types.RevenueWithdrawalState¶
Bases:
JsonDeserializable
- This object describes the state of a revenue withdrawal operation. Currently, it can be one of
RevenueWithdrawalStatePending RevenueWithdrawalStateSucceeded RevenueWithdrawalStateFailed
Telegram documentation: https://core.telegram.org/bots/api#revenuewithdrawalstate
- Parameters:
type (
str
) – Type of the state, always “pending” or “succeeded” or “failed”- Returns:
Instance of the class
- Return type:
RevenueWithdrawalStatePending
orRevenueWithdrawalStateSucceeded
orRevenueWithdrawalStateFailed
- class telebot.types.RevenueWithdrawalStateFailed(type, **kwargs)¶
Bases:
RevenueWithdrawalState
The withdrawal failed and the transaction was refunded.
Telegram documentation: https://core.telegram.org/bots/api#revenuewithdrawalstatefailed
- Parameters:
type (
str
) – Type of the state, always “failed”- Returns:
Instance of the class
- Return type:
- class telebot.types.RevenueWithdrawalStatePending(type, **kwargs)¶
Bases:
RevenueWithdrawalState
The withdrawal is in progress.
Telegram documentation: https://core.telegram.org/bots/api#revenuewithdrawalstatepending
- Parameters:
type (
str
) – Type of the state, always “pending”- Returns:
Instance of the class
- Return type:
- class telebot.types.RevenueWithdrawalStateSucceeded(type, date, url, **kwargs)¶
Bases:
RevenueWithdrawalState
The withdrawal succeeded.
Telegram documentation: https://core.telegram.org/bots/api#revenuewithdrawalstatesucceeded
- Parameters:
type (
str
) – Type of the state, always “succeeded”date (
int
) – Date the withdrawal was completed in Unix timeurl (
str
) – An HTTPS URL that can be used to see transaction details
- Returns:
Instance of the class
- Return type:
- class telebot.types.SentWebAppMessage(inline_message_id=None, **kwargs)¶
Bases:
JsonDeserializable
,Dictionaryable
Describes an inline message sent by a Web App on behalf of a user.
Telegram Documentation: https://core.telegram.org/bots/api#sentwebappmessage
- Parameters:
inline_message_id (
str
) – Optional. Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message.- Returns:
Instance of the class
- Return type:
Bases:
JsonDeserializable
This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUser button.
Telegram documentation: https://core.telegram.org/bots/api#shareduser
- Parameters:
user_id (
int
) – Identifier of the shared user. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.first_name (
str
) – Optional. First name of the user, if the name was requested by the botlast_name (
str
) – Optional. Last name of the user, if the name was requested by the botusername (
str
) – Optional. Username of the user, if the username was requested by the botphoto (
list
ofPhotoSize
) – Optional. Available sizes of the chat photo, if the photo was requested by the bot
- Returns:
Instance of the class
- Return type:
- class telebot.types.ShippingAddress(country_code, state, city, street_line1, street_line2, post_code, **kwargs)¶
Bases:
JsonDeserializable
This object represents a shipping address.
Telegram Documentation: https://core.telegram.org/bots/api#shippingaddress
- Parameters:
country_code (
str
) – Two-letter ISO 3166-1 alpha-2 country codestate (
str
) – State, if applicablecity (
str
) – Citystreet_line1 (
str
) – First line for the addressstreet_line2 (
str
) – Second line for the addresspost_code (
str
) – Address post code
- Returns:
Instance of the class
- Return type:
- class telebot.types.ShippingOption(id, title)¶
Bases:
JsonSerializable
This object represents one shipping option.
Telegram Documentation: https://core.telegram.org/bots/api#shippingoption
- Parameters:
id (
str
) – Shipping option identifiertitle (
str
) – Option titleprices (
list
oftelebot.types.LabeledPrice
) – List of price portions
- Returns:
Instance of the class
- Return type:
- add_price(*args) ShippingOption ¶
Add LabeledPrice to ShippingOption
- Parameters:
args (
LabeledPrice
) – LabeledPrices- Returns:
None
- class telebot.types.ShippingQuery(id, from_user, invoice_payload, shipping_address, **kwargs)¶
Bases:
JsonDeserializable
This object contains information about an incoming shipping query.
Telegram Documentation: https://core.telegram.org/bots/api#shippingquery
- Parameters:
id (
str
) – Unique query identifierfrom (
telebot.types.User
) – User who sent the queryinvoice_payload (
str
) – Bot specified invoice payloadshipping_address (
telebot.types.ShippingAddress
) – User specified shipping address
- Returns:
Instance of the class
- Return type:
- class telebot.types.StarTransaction(id, amount, date, source=None, receiver=None, **kwargs)¶
Bases:
JsonDeserializable
Describes a Telegram Star transaction.
Telegram documentation: https://core.telegram.org/bots/api#startransaction
- Parameters:
id (
str
) – Unique identifier of the transaction. Coincides with the identifer of the original transaction for refund transactions. Coincides with SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users.amount (
int
) – Number of Telegram Stars transferred by the transactiondate (
int
) – Date the transaction was created in Unix timesource (
TransactionPartner
) – Optional. Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactionsreceiver (
TransactionPartner
) – Optional. Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions
- Returns:
Instance of the class
- Return type:
- class telebot.types.StarTransactions(transactions, **kwargs)¶
Bases:
JsonDeserializable
Contains a list of Telegram Star transactions.
Telegram documentation: https://core.telegram.org/bots/api#startransactions
- Parameters:
transactions (
list
ofStarTransaction
) – The list of transactions- Returns:
Instance of the class
- Return type:
- class telebot.types.Sticker(file_id, file_unique_id, type, width, height, is_animated, is_video, thumbnail=None, emoji=None, set_name=None, mask_position=None, file_size=None, premium_animation=None, custom_emoji_id=None, needs_repainting=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a sticker.
Telegram Documentation: https://core.telegram.org/bots/api#sticker
- Parameters:
file_id (
str
) – Identifier for this file, which can be used to download or reuse the filefile_unique_id (
str
) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.type (
str
) – Type of the sticker, currently one of “regular”, “mask”, “custom_emoji”. The type of the sticker is independent from its format, which is determined by the fields is_animated and is_video.width (
int
) – Sticker widthheight (
int
) – Sticker heightis_animated (
bool
) – True, if the sticker is animatedis_video (
bool
) – True, if the sticker is a video stickerthumbnail (
telebot.types.PhotoSize
) – Optional. Sticker thumbnail in the .WEBP or .JPG formatemoji (
str
) – Optional. Emoji associated with the stickerset_name (
str
) – Optional. Name of the sticker set to which the sticker belongspremium_animation (
telebot.types.File
) – Optional. Premium animation for the sticker, if the sticker is premiummask_position (
telebot.types.MaskPosition
) – Optional. For mask stickers, the position where the mask should be placedcustom_emoji_id (
str
) – Optional. For custom emoji stickers, unique identifier of the custom emojineeds_repainting (
bool
) – Optional. True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, white color on chat photos, or another appropriate color in other placesfile_size (
int
) – Optional. File size in bytes
- Returns:
Instance of the class
- Return type:
- class telebot.types.StickerSet(name, title, sticker_type, stickers, thumbnail=None, **kwargs)¶
Bases:
JsonDeserializable
This object represents a sticker set.
Telegram Documentation: https://core.telegram.org/bots/api#stickerset
- Parameters:
name (
str
) – Sticker set nametitle (
str
) – Sticker set titlesticker_type (
str
) – Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”stickers (
list
oftelebot.types.Sticker
) – List of all set stickersthumbnail (
telebot.types.PhotoSize
) – Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format
- Returns:
Instance of the class
- Return type:
- property contains_masks: bool¶
Deprecated since Bot API 6.2, use sticker_type instead.
- property is_animated: bool¶
Deprecated since Bot API 7.2. Stickers can be mixed now.
- property is_video: bool¶
Deprecated since Bot API 7.2. Stickers can be mixed now.
- class telebot.types.Story(chat: Chat, id: int, **kwargs)¶
Bases:
JsonDeserializable
This object represents a story.
Telegram documentation: https://core.telegram.org/bots/api#story
- Parameters:
chat (
telebot.types.Chat
) – Chat that posted the storyid (
int
) – Unique identifier for the story in the chat
- Returns:
Instance of the class
- Return type:
- class telebot.types.SuccessfulPayment(currency, total_amount, invoice_payload, shipping_option_id=None, order_info=None, telegram_payment_charge_id=None, provider_payment_charge_id=None, **kwargs)¶
Bases:
JsonDeserializable
This object contains basic information about a successful payment.
Telegram Documentation: https://core.telegram.org/bots/api#successfulpayment
- Parameters:
currency (
str
) – Three-letter ISO 4217 currency codetotal_amount (
int
) – Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).invoice_payload (
str
) – Bot specified invoice payloadshipping_option_id (
str
) – Optional. Identifier of the shipping option chosen by the userorder_info (
telebot.types.OrderInfo
) – Optional. Order information provided by the usertelegram_payment_charge_id (
str
) – Telegram payment identifierprovider_payment_charge_id (
str
) – Provider payment identifier
- Returns:
Instance of the class
- Return type:
- class telebot.types.SwitchInlineQueryChosenChat(query: str | None = None, allow_user_chats: bool | None = None,