telegram.constants Module¶
This module contains several constants that are relevant for working with the Bot API.
Unless noted otherwise, all constants in this module were extracted from the Telegram Bots FAQ and Telegram Bots API.
Most of the following constants are related to specific classes or topics and are grouped into enums. If they are related to a specific class, then they are also available as attributes of those classes.
Changed in version 20.0:
Most of the constants in this module are grouped into enums.
- telegram.constants.BOT_API_VERSION = '6.2'[source]¶
Telegram Bot API version supported by this version of python-telegram-bot. Also available as
telegram.__bot_api_version__
.New in version 13.4.
- Type
- telegram.constants.BOT_API_VERSION_INFO = BotAPIVersion(major=6, minor=2)[source]¶
The components can also be accessed by name, so
BOT_API_VERSION_INFO[0]
is equivalent toBOT_API_VERSION_INFO.major
and so on. Also available astelegram.__bot_api_version_info__
.New in version 20.0.
- class telegram.constants.BotCommandScopeType(value)[source]¶
-
This enum contains the available types of
telegram.BotCommandScope
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- ALL_CHAT_ADMINISTRATORS = 'all_chat_administrators'[source]¶
The type of
telegram.BotCommandScopeAllChatAdministrators
.- Type
- ALL_GROUP_CHATS = 'all_group_chats'[source]¶
The type of
telegram.BotCommandScopeAllGroupChats
.- Type
- ALL_PRIVATE_CHATS = 'all_private_chats'[source]¶
The type of
telegram.BotCommandScopeAllPrivateChats
.- Type
- CHAT = 'chat'[source]¶
The type of
telegram.BotCommandScopeChat
.- Type
- CHAT_ADMINISTRATORS = 'chat_administrators'[source]¶
The type of
telegram.BotCommandScopeChatAdministrators
.- Type
- CHAT_MEMBER = 'chat_member'[source]¶
The type of
telegram.BotCommandScopeChatMember
.- Type
- DEFAULT = 'default'[source]¶
The type of
telegram.BotCommandScopeDefault
.- Type
- class telegram.constants.CallbackQueryLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.CallbackQuery
/telegram.Bot.answer_callback_query()
. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- ANSWER_CALLBACK_QUERY_TEXT_LENGTH = 200[source]¶
Maximum number of characters for the
text
parameter oftelegram.Bot.answer_callback_query()
.- Type
- class telegram.constants.ChatAction(value)[source]¶
-
This enum contains the available chat actions for
telegram.Bot.send_chat_action()
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- CHOOSE_STICKER = 'choose_sticker'[source]¶
Chat action indicating that the bot is selecting a sticker.
- Type
- FIND_LOCATION = 'find_location'[source]¶
Chat action indicating that the bot is selecting a location.
- Type
- RECORD_VIDEO = 'record_video'[source]¶
Chat action indicating that the bot is recording a video.
- Type
- RECORD_VIDEO_NOTE = 'record_video_note'[source]¶
Chat action indicating that the bot is recording a video note.
- Type
- RECORD_VOICE = 'record_voice'[source]¶
Chat action indicating that the bot is recording a voice message.
- Type
- UPLOAD_DOCUMENT = 'upload_document'[source]¶
Chat action indicating that the bot is uploading a document.
- Type
- UPLOAD_PHOTO = 'upload_photo'[source]¶
Chat action indicating that the bot is uploading a photo.
- Type
- UPLOAD_VIDEO = 'upload_video'[source]¶
Chat action indicating that the bot is uploading a video.
- Type
- class telegram.constants.ChatID(value)[source]¶
Bases:
enum.IntEnum
This enum contains some special chat IDs. The enum members of this enumeration are instances of
int
and can be treated as such.New in version 20.0.
- ANONYMOUS_ADMIN = 1087968824[source]¶
User ID in groups for messages sent by anonymous admins.
Note
telegram.Message.from_user
will contain this ID for backwards compatibility only. It’s recommended to usetelegram.Message.sender_chat
instead.- Type
- FAKE_CHANNEL = 136817688[source]¶
User ID in groups when message is sent on behalf of a channel.
Note
telegram.Message.from_user
will contain this ID for backwards compatibility only. It’s recommended to usetelegram.Message.sender_chat
instead.This value is undocumented and might be changed by Telegram.
- Type
- SERVICE_CHAT = 777000[source]¶
Telegram service chat, that also acts as sender of channel posts forwarded to discussion groups.
Note
telegram.Message.from_user
will contain this ID for backwards compatibility only. It’s recommended to usetelegram.Message.sender_chat
instead.- Type
- class telegram.constants.ChatInviteLinkLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.ChatInviteLink
/telegram.Bot.create_chat_invite_link()
/telegram.Bot.edit_chat_invite_link()
. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- MEMBER_LIMIT = 99999[source]¶
Maximum value allowed for the
member_limit
parameter oftelegram.Bot.create_chat_invite_link()
andtelegram.Bot.edit_chat_invite_link()
.- Type
- NAME_LENGTH = 32[source]¶
Maximum number of characters allowed for the
name
parameter oftelegram.Bot.create_chat_invite_link()
andtelegram.Bot.edit_chat_invite_link()
.- Type
- class telegram.constants.ChatMemberStatus(value)[source]¶
-
This enum contains the available states for
telegram.ChatMember
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- ADMINISTRATOR = 'administrator'[source]¶
A
telegram.ChatMember
who is administrator of the chat.- Type
- BANNED = 'kicked'[source]¶
A
telegram.ChatMember
who was banned in the chat.- Type
- LEFT = 'left'[source]¶
A
telegram.ChatMember
who has left the chat.- Type
- MEMBER = 'member'[source]¶
A
telegram.ChatMember
who is a member of the chat.- Type
- OWNER = 'creator'[source]¶
A
telegram.ChatMember
who is the owner of the chat.- Type
- RESTRICTED = 'restricted'[source]¶
A
telegram.ChatMember
who was restricted in this chat.- Type
- class telegram.constants.ChatType(value)[source]¶
-
This enum contains the available types of
telegram.Chat
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- CHANNEL = 'channel'[source]¶
A
telegram.Chat
that is a channel.- Type
- GROUP = 'group'[source]¶
A
telegram.Chat
that is a group.- Type
- PRIVATE = 'private'[source]¶
A
telegram.Chat
that is private.- Type
- SENDER = 'sender'[source]¶
A
telegram.Chat
that represents the chat of atelegram.User
sending antelegram.InlineQuery
.- Type
- SUPERGROUP = 'supergroup'[source]¶
A
telegram.Chat
that is a supergroup.- Type
- class telegram.constants.CustomEmojiStickerLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.Bot.get_custom_emoji_stickers()
. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- CUSTOM_EMOJI_IDENTIFIER_LIMIT = 200[source]¶
Maximum amount of custom emoji identifiers which can be specified for the
custom_emoji_ids
parameter oftelegram.Bot.get_custom_emoji_stickers()
.- Type
- class telegram.constants.DiceEmoji(value)[source]¶
-
This enum contains the available emoji for
telegram.Dice
/telegram.Bot.send_dice()
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- BASKETBALL = '🏀'[source]¶
A
telegram.Dice
with the emoji🏀
.- Type
- BOWLING = '🎳'[source]¶
A
telegram.Dice
with the emoji🎳
.- Type
- DARTS = '🎯'[source]¶
A
telegram.Dice
with the emoji🎯
.- Type
- DICE = '🎲'[source]¶
A
telegram.Dice
with the emoji🎲
.- Type
- FOOTBALL = '⚽'[source]¶
A
telegram.Dice
with the emoji⚽
.- Type
- SLOT_MACHINE = '🎰'[source]¶
A
telegram.Dice
with the emoji🎰
.- Type
- class telegram.constants.FileSizeLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations regarding the upload and download of files. The enum members of this enumeration are instances of
int
and can be treated as such.New in version 20.0.
- class telegram.constants.FloodLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations regarding flood limits. The enum members of this enumeration are instances of
int
and can be treated as such.New in version 20.0.
- MESSAGES_PER_MINUTE_PER_GROUP = 20[source]¶
The number of messages that can roughly be sent to a particular group within one minute.
- Type
- class telegram.constants.InlineKeyboardMarkupLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.InlineKeyboardMarkup
/telegram.Bot.send_message()
& friends. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- class telegram.constants.InlineQueryLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.InlineQuery
/telegram.Bot.answer_inline_query()
. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- RESULTS = 50[source]¶
Maximum number of results that can be passed to
telegram.Bot.answer_inline_query()
.- Type
- SWITCH_PM_TEXT_LENGTH = 64[source]¶
Maximum number of characters for the
switch_pm_text
parameter oftelegram.Bot.answer_inline_query()
.- Type
- class telegram.constants.InlineQueryResultType(value)[source]¶
-
This enum contains the available types of
telegram.InlineQueryResult
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- ARTICLE = 'article'[source]¶
Type of
telegram.InlineQueryResultArticle
.- Type
- AUDIO = 'audio'[source]¶
Type of
telegram.InlineQueryResultAudio
andtelegram.InlineQueryResultCachedAudio
.- Type
- CONTACT = 'contact'[source]¶
Type of
telegram.InlineQueryResultContact
.- Type
- DOCUMENT = 'document'[source]¶
Type of
telegram.InlineQueryResultDocument
andtelegram.InlineQueryResultCachedDocument
.- Type
- GAME = 'game'[source]¶
Type of
telegram.InlineQueryResultGame
.- Type
- GIF = 'gif'[source]¶
Type of
telegram.InlineQueryResultGif
andtelegram.InlineQueryResultCachedGif
.- Type
- LOCATION = 'location'[source]¶
Type of
telegram.InlineQueryResultLocation
.- Type
- MPEG4GIF = 'mpeg4_gif'[source]¶
Type of
telegram.InlineQueryResultMpeg4Gif
andtelegram.InlineQueryResultCachedMpeg4Gif
.- Type
- PHOTO = 'photo'[source]¶
Type of
telegram.InlineQueryResultPhoto
andtelegram.InlineQueryResultCachedPhoto
.- Type
- STICKER = 'sticker'[source]¶
Type of and
telegram.InlineQueryResultCachedSticker
.- Type
- VENUE = 'venue'[source]¶
Type of
telegram.InlineQueryResultVenue
.- Type
- VIDEO = 'video'[source]¶
Type of
telegram.InlineQueryResultVideo
andtelegram.InlineQueryResultCachedVideo
.- Type
- VOICE = 'voice'[source]¶
Type of
telegram.InlineQueryResultVoice
andtelegram.InlineQueryResultCachedVoice
.- Type
- class telegram.constants.InputMediaType(value)[source]¶
-
This enum contains the available types of
telegram.InputMedia
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- ANIMATION = 'animation'[source]¶
Type of
telegram.InputMediaAnimation
.- Type
- AUDIO = 'audio'[source]¶
Type of
telegram.InputMediaAudio
.- Type
- DOCUMENT = 'document'[source]¶
Type of
telegram.InputMediaDocument
.- Type
- PHOTO = 'photo'[source]¶
Type of
telegram.InputMediaPhoto
.- Type
- VIDEO = 'video'[source]¶
Type of
telegram.InputMediaVideo
.- Type
- class telegram.constants.InvoiceLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.Bot.create_invoice_link()
. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- class telegram.constants.LocationLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.Location
/telegram.Bot.send_location()
. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- HEADING = 360[source]¶
Maximum value allowed for the direction in which the user is moving, in degrees.
- Type
- class telegram.constants.MaskPosition(value)[source]¶
-
This enum contains the available positions for
telegram.MaskPosition
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- class telegram.constants.MenuButtonType(value)[source]¶
-
This enum contains the available types of
telegram.MenuButton
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- COMMANDS = 'commands'[source]¶
The type of
telegram.MenuButtonCommands
.- Type
- DEFAULT = 'default'[source]¶
The type of
telegram.MenuButtonDefault
.- Type
- WEB_APP = 'web_app'[source]¶
The type of
telegram.MenuButtonWebApp
.- Type
- class telegram.constants.MessageAttachmentType(value)[source]¶
-
This enum contains the available types of
telegram.Message
that can be seen as attachment. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- ANIMATION = 'animation'[source]¶
Messages with
telegram.Message.animation
.- Type
- AUDIO = 'audio'[source]¶
Messages with
telegram.Message.audio
.- Type
- CONTACT = 'contact'[source]¶
Messages with
telegram.Message.contact
.- Type
- DICE = 'dice'[source]¶
Messages with
telegram.Message.dice
.- Type
- DOCUMENT = 'document'[source]¶
Messages with
telegram.Message.document
.- Type
- GAME = 'game'[source]¶
Messages with
telegram.Message.game
.- Type
- INVOICE = 'invoice'[source]¶
Messages with
telegram.Message.invoice
.- Type
- LOCATION = 'location'[source]¶
Messages with
telegram.Message.location
.- Type
- PASSPORT_DATA = 'passport_data'[source]¶
Messages with
telegram.Message.passport_data
.- Type
- PHOTO = 'photo'[source]¶
Messages with
telegram.Message.photo
.- Type
- POLL = 'poll'[source]¶
Messages with
telegram.Message.poll
.- Type
- STICKER = 'sticker'[source]¶
Messages with
telegram.Message.sticker
.- Type
- SUCCESSFUL_PAYMENT = 'successful_payment'[source]¶
Messages with
telegram.Message.successful_payment
.- Type
- VENUE = 'venue'[source]¶
Messages with
telegram.Message.venue
.- Type
- VIDEO = 'video'[source]¶
Messages with
telegram.Message.video
.- Type
- VIDEO_NOTE = 'video_note'[source]¶
Messages with
telegram.Message.video_note
.- Type
- VOICE = 'voice'[source]¶
Messages with
telegram.Message.voice
.- Type
- class telegram.constants.MessageEntityType(value)[source]¶
-
This enum contains the available types of
telegram.MessageEntity
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- CUSTOM_EMOJI = 'custom_emoji'[source]¶
Message entities representing inline custom emoji stickers.
New in version 20.0.
- Type
- class telegram.constants.MessageLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.Message
/telegram.Bot.send_message()
& friends. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- class telegram.constants.MessageType(value)[source]¶
-
This enum contains the available types of
telegram.Message
that can be seen as attachment. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- ANIMATION = 'animation'[source]¶
Messages with
telegram.Message.animation
.- Type
- AUDIO = 'audio'[source]¶
Messages with
telegram.Message.audio
.- Type
- CHANNEL_CHAT_CREATED = 'channel_chat_created'[source]¶
Messages with
telegram.Message.channel_chat_created
.- Type
- CONTACT = 'contact'[source]¶
Messages with
telegram.Message.contact
.- Type
- DELETE_CHAT_PHOTO = 'delete_chat_photo'[source]¶
Messages with
telegram.Message.delete_chat_photo
.- Type
- DICE = 'dice'[source]¶
Messages with
telegram.Message.dice
.- Type
- DOCUMENT = 'document'[source]¶
Messages with
telegram.Message.document
.- Type
- GAME = 'game'[source]¶
Messages with
telegram.Message.game
.- Type
- GROUP_CHAT_CREATED = 'group_chat_created'[source]¶
Messages with
telegram.Message.group_chat_created
.- Type
- INVOICE = 'invoice'[source]¶
Messages with
telegram.Message.invoice
.- Type
- LEFT_CHAT_MEMBER = 'left_chat_member'[source]¶
Messages with
telegram.Message.left_chat_member
.- Type
- LOCATION = 'location'[source]¶
Messages with
telegram.Message.location
.- Type
- MESSAGE_AUTO_DELETE_TIMER_CHANGED = 'message_auto_delete_timer_changed'[source]¶
Messages with
telegram.Message.message_auto_delete_timer_changed
.- Type
- MIGRATE_FROM_CHAT_ID = 'migrate_from_chat_id'[source]¶
Messages with
telegram.Message.migrate_from_chat_id
.- Type
- MIGRATE_TO_CHAT_ID = 'migrate_to_chat_id'[source]¶
Messages with
telegram.Message.migrate_to_chat_id
.- Type
- NEW_CHAT_MEMBERS = 'new_chat_members'[source]¶
Messages with
telegram.Message.new_chat_members
.- Type
- NEW_CHAT_PHOTO = 'new_chat_photo'[source]¶
Messages with
telegram.Message.new_chat_photo
.- Type
- NEW_CHAT_TITLE = 'new_chat_title'[source]¶
Messages with
telegram.Message.new_chat_title
.- Type
- PASSPORT_DATA = 'passport_data'[source]¶
Messages with
telegram.Message.passport_data
.- Type
- PHOTO = 'photo'[source]¶
Messages with
telegram.Message.photo
.- Type
- PINNED_MESSAGE = 'pinned_message'[source]¶
Messages with
telegram.Message.pinned_message
.- Type
- POLL = 'poll'[source]¶
Messages with
telegram.Message.poll
.- Type
- PROXIMITY_ALERT_TRIGGERED = 'proximity_alert_triggered'[source]¶
Messages with
telegram.Message.proximity_alert_triggered
.- Type
- STICKER = 'sticker'[source]¶
Messages with
telegram.Message.sticker
.- Type
- SUCCESSFUL_PAYMENT = 'successful_payment'[source]¶
Messages with
telegram.Message.successful_payment
.- Type
- SUPERGROUP_CHAT_CREATED = 'supergroup_chat_created'[source]¶
Messages with
telegram.Message.supergroup_chat_created
.- Type
- TEXT = 'text'[source]¶
Messages with
telegram.Message.text
.- Type
- VENUE = 'venue'[source]¶
Messages with
telegram.Message.venue
.- Type
- VIDEO = 'video'[source]¶
Messages with
telegram.Message.video
.- Type
- VIDEO_CHAT_ENDED = 'video_chat_ended'[source]¶
Messages with
telegram.Message.video_chat_ended
.- Type
- VIDEO_CHAT_PARTICIPANTS_INVITED = 'video_chat_participants_invited'[source]¶
Messages with
telegram.Message.video_chat_participants_invited
.- Type
- VIDEO_CHAT_SCHEDULED = 'video_chat_scheduled'[source]¶
Messages with
telegram.Message.video_chat_scheduled
.- Type
- VIDEO_CHAT_STARTED = 'video_chat_started'[source]¶
Messages with
telegram.Message.video_chat_started
.- Type
- VIDEO_NOTE = 'video_note'[source]¶
Messages with
telegram.Message.video_note
.- Type
- VOICE = 'voice'[source]¶
Messages with
telegram.Message.voice
.- Type
- class telegram.constants.ParseMode(value)[source]¶
-
This enum contains the available parse modes. The enum members of this enumeration are instances of
str
and can be treated as such.New in version 20.0.
- MARKDOWN = 'Markdown'[source]¶
Markdown parse mode.
Note
MARKDOWN
is a legacy mode, retained by Telegram for backward compatibility. You should useMARKDOWN_V2
instead.- Type
- class telegram.constants.PollLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.Poll
/telegram.Bot.send_poll()
. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.
- class telegram.constants.PollType(value)[source]¶
-
This enum contains the available types for
telegram.Poll
/telegram.Bot.send_poll()
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- telegram.constants.SUPPORTED_WEBHOOK_PORTS = [443, 80, 88, 8443][source]¶
Ports supported by
telegram.Bot.set_webhook.url
.- Type
List[
int
]
- class telegram.constants.StickerType(value)[source]¶
-
This enum contains the available types of
telegram.Sticker
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- class telegram.constants.UpdateType(value)[source]¶
-
This enum contains the available types of
telegram.Update
. The enum members of this enumeration are instances ofstr
and can be treated as such.New in version 20.0.
- CALLBACK_QUERY = 'callback_query'[source]¶
Updates with
telegram.Update.callback_query
.- Type
- CHANNEL_POST = 'channel_post'[source]¶
Updates with
telegram.Update.channel_post
.- Type
- CHAT_JOIN_REQUEST = 'chat_join_request'[source]¶
Updates with
telegram.Update.chat_join_request
.- Type
- CHAT_MEMBER = 'chat_member'[source]¶
Updates with
telegram.Update.chat_member
.- Type
- CHOSEN_INLINE_RESULT = 'chosen_inline_result'[source]¶
Updates with
telegram.Update.chosen_inline_result
.- Type
- EDITED_CHANNEL_POST = 'edited_channel_post'[source]¶
Updates with
telegram.Update.edited_channel_post
.- Type
- EDITED_MESSAGE = 'edited_message'[source]¶
Updates with
telegram.Update.edited_message
.- Type
- INLINE_QUERY = 'inline_query'[source]¶
Updates with
telegram.Update.inline_query
.- Type
- MESSAGE = 'message'[source]¶
Updates with
telegram.Update.message
.- Type
- MY_CHAT_MEMBER = 'my_chat_member'[source]¶
Updates with
telegram.Update.my_chat_member
.- Type
- POLL = 'poll'[source]¶
Updates with
telegram.Update.poll
.- Type
- POLL_ANSWER = 'poll_answer'[source]¶
Updates with
telegram.Update.poll_answer
.- Type
- PRE_CHECKOUT_QUERY = 'pre_checkout_query'[source]¶
Updates with
telegram.Update.pre_checkout_query
.- Type
- SHIPPING_QUERY = 'shipping_query'[source]¶
Updates with
telegram.Update.shipping_query
.- Type
- class telegram.constants.WebhookLimit(value)[source]¶
Bases:
enum.IntEnum
This enum contains limitations for
telegram.Bot.set_webhook.secret_token
. The enum members of this enumeration are instances ofint
and can be treated as such.New in version 20.0.