2016-07-14 21:36:15 +02:00
|
|
|
# python-telegram-bot - a Python interface to the Telegram Bot API
|
2021-01-03 06:10:24 +01:00
|
|
|
# Copyright (C) 2015-2021
|
2016-07-14 21:36:15 +02:00
|
|
|
# by the python-telegram-bot contributors <devs@python-telegram-bot.org>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser Public License
|
|
|
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
2017-09-01 08:43:08 +02:00
|
|
|
"""Constants in the Telegram network.
|
2016-07-14 21:36:15 +02:00
|
|
|
|
|
|
|
The following constants were extracted from the
|
2019-10-17 22:24:44 +02:00
|
|
|
`Telegram Bots FAQ <https://core.telegram.org/bots/faq>`_ and
|
|
|
|
`Telegram Bots API <https://core.telegram.org/bots/api>`_.
|
2016-07-14 21:36:15 +02:00
|
|
|
|
|
|
|
Attributes:
|
2021-03-14 16:41:35 +01:00
|
|
|
BOT_API_VERSION (:obj:`str`): `5.1`. Telegram Bot API version supported by this
|
|
|
|
version of `python-telegram-bot`. Also available as ``telegram.bot_api_version``.
|
|
|
|
|
|
|
|
.. versionadded:: 13.4
|
2017-07-23 22:33:08 +02:00
|
|
|
MAX_MESSAGE_LENGTH (:obj:`int`): 4096
|
2018-10-16 19:51:57 +02:00
|
|
|
MAX_CAPTION_LENGTH (:obj:`int`): 1024
|
2017-07-23 22:33:08 +02:00
|
|
|
SUPPORTED_WEBHOOK_PORTS (List[:obj:`int`]): [443, 80, 88, 8443]
|
|
|
|
MAX_FILESIZE_DOWNLOAD (:obj:`int`): In bytes (20MB)
|
|
|
|
MAX_FILESIZE_UPLOAD (:obj:`int`): In bytes (50MB)
|
2019-10-17 22:24:44 +02:00
|
|
|
MAX_PHOTOSIZE_UPLOAD (:obj:`int`): In bytes (10MB)
|
2017-07-23 22:33:08 +02:00
|
|
|
MAX_MESSAGES_PER_SECOND_PER_CHAT (:obj:`int`): `1`. Telegram may allow short bursts that go
|
|
|
|
over this limit, but eventually you'll begin receiving 429 errors.
|
|
|
|
MAX_MESSAGES_PER_SECOND (:obj:`int`): 30
|
|
|
|
MAX_MESSAGES_PER_MINUTE_PER_GROUP (:obj:`int`): 20
|
|
|
|
MAX_INLINE_QUERY_RESULTS (:obj:`int`): 50
|
2021-01-07 21:27:51 +01:00
|
|
|
MAX_ANSWER_CALLBACK_QUERY_TEXT_LENGTH (:obj:`int`): 200
|
|
|
|
|
|
|
|
.. versionadded:: 13.2
|
2016-09-07 08:49:09 +02:00
|
|
|
|
|
|
|
The following constant have been found by experimentation:
|
|
|
|
|
|
|
|
Attributes:
|
2017-07-23 22:33:08 +02:00
|
|
|
MAX_MESSAGE_ENTITIES (:obj:`int`): 100 (Beyond this cap telegram will simply ignore further
|
|
|
|
formatting styles)
|
2020-10-18 16:15:56 +02:00
|
|
|
ANONYMOUS_ADMIN_ID (:obj:`int`): ``1087968824`` (User id in groups for anonymous admin)
|
|
|
|
SERVICE_CHAT_ID (:obj:`int`): ``777000`` (Telegram service chat, that also acts as sender of
|
|
|
|
channel posts forwarded to discussion groups)
|
2017-09-01 08:43:08 +02:00
|
|
|
|
2020-10-13 17:58:36 +02:00
|
|
|
The following constants are related to specific classes and are also available
|
|
|
|
as attributes of those classes:
|
|
|
|
|
|
|
|
:class:`telegram.Chat`:
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
CHAT_PRIVATE (:obj:`str`): 'private'
|
|
|
|
CHAT_GROUP (:obj:`str`): 'group'
|
|
|
|
CHAT_SUPERGROUP (:obj:`str`): 'supergroup'
|
|
|
|
CHAT_CHANNEL (:obj:`str`): 'channel'
|
|
|
|
|
|
|
|
:class:`telegram.ChatAction`:
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
CHATACTION_FIND_LOCATION (:obj:`str`): 'find_location'
|
|
|
|
CHATACTION_RECORD_AUDIO (:obj:`str`): 'record_audio'
|
|
|
|
CHATACTION_RECORD_VIDEO (:obj:`str`): 'record_video'
|
|
|
|
CHATACTION_RECORD_VIDEO_NOTE (:obj:`str`): 'record_video_note'
|
|
|
|
CHATACTION_TYPING (:obj:`str`): 'typing'
|
|
|
|
CHATACTION_UPLOAD_AUDIO (:obj:`str`): 'upload_audio'
|
|
|
|
CHATACTION_UPLOAD_DOCUMENT (:obj:`str`): 'upload_document'
|
|
|
|
CHATACTION_UPLOAD_PHOTO (:obj:`str`): 'upload_photo'
|
|
|
|
CHATACTION_UPLOAD_VIDEO (:obj:`str`): 'upload_video'
|
|
|
|
CHATACTION_UPLOAD_VIDEO_NOTE (:obj:`str`): 'upload_video_note'
|
|
|
|
|
|
|
|
:class:`telegram.ChatMember`:
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
CHATMEMBER_ADMINISTRATOR (:obj:`str`): 'administrator'
|
|
|
|
CHATMEMBER_CREATOR (:obj:`str`): 'creator'
|
|
|
|
CHATMEMBER_KICKED (:obj:`str`): 'kicked'
|
|
|
|
CHATMEMBER_LEFT (:obj:`str`): 'left'
|
|
|
|
CHATMEMBER_MEMBER (:obj:`str`): 'member'
|
|
|
|
CHATMEMBER_RESTRICTED (:obj:`str`): 'restricted'
|
|
|
|
|
|
|
|
:class:`telegram.Dice`:
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
DICE_DICE (:obj:`str`): '🎲'
|
|
|
|
DICE_DARTS (:obj:`str`): '🎯'
|
|
|
|
DICE_BASKETBALL (:obj:`str`): '🏀'
|
2020-11-29 16:20:46 +01:00
|
|
|
DICE_FOOTBALL (:obj:`str`): '⚽'
|
|
|
|
DICE_SLOT_MACHINE (:obj:`str`): '🎰'
|
2021-03-14 16:41:35 +01:00
|
|
|
DICE_BOWLING (:obj:`str`): '🎳'
|
|
|
|
|
|
|
|
.. versionadded:: 13.4
|
2020-10-13 17:58:36 +02:00
|
|
|
DICE_ALL_EMOJI (List[:obj:`str`]): List of all supported base emoji.
|
|
|
|
|
2021-03-14 16:41:35 +01:00
|
|
|
.. versionchanged:: 13.4
|
|
|
|
Added :attr:`DICE_BOWLING`
|
|
|
|
|
2020-10-13 17:58:36 +02:00
|
|
|
:class:`telegram.MessageEntity`:
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
MESSAGEENTITY_MENTION (:obj:`str`): 'mention'
|
|
|
|
MESSAGEENTITY_HASHTAG (:obj:`str`): 'hashtag'
|
|
|
|
MESSAGEENTITY_CASHTAG (:obj:`str`): 'cashtag'
|
|
|
|
MESSAGEENTITY_PHONE_NUMBER (:obj:`str`): 'phone_number'
|
|
|
|
MESSAGEENTITY_BOT_COMMAND (:obj:`str`): 'bot_command'
|
|
|
|
MESSAGEENTITY_URL (:obj:`str`): 'url'
|
|
|
|
MESSAGEENTITY_EMAIL (:obj:`str`): 'email'
|
|
|
|
MESSAGEENTITY_BOLD (:obj:`str`): 'bold'
|
|
|
|
MESSAGEENTITY_ITALIC (:obj:`str`): 'italic'
|
|
|
|
MESSAGEENTITY_CODE (:obj:`str`): 'code'
|
|
|
|
MESSAGEENTITY_PRE (:obj:`str`): 'pre'
|
|
|
|
MESSAGEENTITY_TEXT_LINK (:obj:`str`): 'text_link'
|
|
|
|
MESSAGEENTITY_TEXT_MENTION (:obj:`str`): 'text_mention'
|
|
|
|
MESSAGEENTITY_UNDERLINE (:obj:`str`): 'underline'
|
|
|
|
MESSAGEENTITY_STRIKETHROUGH (:obj:`str`): 'strikethrough'
|
|
|
|
MESSAGEENTITY_ALL_TYPES (List[:obj:`str`]): List of all the types of message entity.
|
|
|
|
|
|
|
|
:class:`telegram.ParseMode`:
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
PARSEMODE_MARKDOWN (:obj:`str`): 'Markdown'
|
|
|
|
PARSEMODE_MARKDOWN_V2 (:obj:`str`): 'MarkdownV2'
|
|
|
|
PARSEMODE_HTML (:obj:`str`): 'HTML'
|
|
|
|
|
|
|
|
:class:`telegram.Poll`:
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
POLL_REGULAR (:obj:`str`): 'regular'
|
|
|
|
POLL_QUIZ (:obj:`str`): 'quiz'
|
2020-11-29 16:20:46 +01:00
|
|
|
MAX_POLL_QUESTION_LENGTH (:obj:`int`): 300
|
|
|
|
MAX_POLL_OPTION_LENGTH (:obj:`int`): 100
|
2020-10-13 17:58:36 +02:00
|
|
|
|
|
|
|
:class:`telegram.files.MaskPosition`:
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
STICKER_FOREHEAD (:obj:`str`): 'forehead'
|
|
|
|
STICKER_EYES (:obj:`str`): 'eyes'
|
|
|
|
STICKER_MOUTH (:obj:`str`): 'mouth'
|
|
|
|
STICKER_CHIN (:obj:`str`): 'chin'
|
|
|
|
|
2016-07-14 21:36:15 +02:00
|
|
|
"""
|
2020-10-06 19:28:40 +02:00
|
|
|
from typing import List
|
2016-07-14 21:36:15 +02:00
|
|
|
|
2021-03-14 16:41:35 +01:00
|
|
|
BOT_API_VERSION: str = '5.1'
|
2020-10-06 19:28:40 +02:00
|
|
|
MAX_MESSAGE_LENGTH: int = 4096
|
|
|
|
MAX_CAPTION_LENGTH: int = 1024
|
2020-10-18 16:15:56 +02:00
|
|
|
ANONYMOUS_ADMIN_ID: int = 1087968824
|
|
|
|
SERVICE_CHAT_ID: int = 777000
|
2016-07-14 21:36:15 +02:00
|
|
|
|
|
|
|
# constants above this line are tested
|
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
SUPPORTED_WEBHOOK_PORTS: List[int] = [443, 80, 88, 8443]
|
2020-10-09 17:22:07 +02:00
|
|
|
MAX_FILESIZE_DOWNLOAD: int = int(20e6) # (20MB)
|
|
|
|
MAX_FILESIZE_UPLOAD: int = int(50e6) # (50MB)
|
|
|
|
MAX_PHOTOSIZE_UPLOAD: int = int(10e6) # (10MB)
|
2020-10-06 19:28:40 +02:00
|
|
|
MAX_MESSAGES_PER_SECOND_PER_CHAT: int = 1
|
|
|
|
MAX_MESSAGES_PER_SECOND: int = 30
|
|
|
|
MAX_MESSAGES_PER_MINUTE_PER_GROUP: int = 20
|
|
|
|
MAX_MESSAGE_ENTITIES: int = 100
|
|
|
|
MAX_INLINE_QUERY_RESULTS: int = 50
|
2021-01-07 21:27:51 +01:00
|
|
|
MAX_ANSWER_CALLBACK_QUERY_TEXT_LENGTH: int = 200
|
2020-10-13 17:58:36 +02:00
|
|
|
|
|
|
|
CHAT_PRIVATE: str = 'private'
|
|
|
|
CHAT_GROUP: str = 'group'
|
|
|
|
CHAT_SUPERGROUP: str = 'supergroup'
|
|
|
|
CHAT_CHANNEL: str = 'channel'
|
|
|
|
|
|
|
|
CHATACTION_FIND_LOCATION: str = 'find_location'
|
|
|
|
CHATACTION_RECORD_AUDIO: str = 'record_audio'
|
|
|
|
CHATACTION_RECORD_VIDEO: str = 'record_video'
|
|
|
|
CHATACTION_RECORD_VIDEO_NOTE: str = 'record_video_note'
|
|
|
|
CHATACTION_TYPING: str = 'typing'
|
|
|
|
CHATACTION_UPLOAD_AUDIO: str = 'upload_audio'
|
|
|
|
CHATACTION_UPLOAD_DOCUMENT: str = 'upload_document'
|
|
|
|
CHATACTION_UPLOAD_PHOTO: str = 'upload_photo'
|
|
|
|
CHATACTION_UPLOAD_VIDEO: str = 'upload_video'
|
|
|
|
CHATACTION_UPLOAD_VIDEO_NOTE: str = 'upload_video_note'
|
|
|
|
|
|
|
|
CHATMEMBER_ADMINISTRATOR: str = 'administrator'
|
|
|
|
CHATMEMBER_CREATOR: str = 'creator'
|
|
|
|
CHATMEMBER_KICKED: str = 'kicked'
|
|
|
|
CHATMEMBER_LEFT: str = 'left'
|
|
|
|
CHATMEMBER_MEMBER: str = 'member'
|
|
|
|
CHATMEMBER_RESTRICTED: str = 'restricted'
|
|
|
|
|
|
|
|
DICE_DICE: str = '🎲'
|
|
|
|
DICE_DARTS: str = '🎯'
|
|
|
|
DICE_BASKETBALL: str = '🏀'
|
2020-11-29 16:20:46 +01:00
|
|
|
DICE_FOOTBALL: str = '⚽'
|
|
|
|
DICE_SLOT_MACHINE: str = '🎰'
|
2021-03-14 16:41:35 +01:00
|
|
|
DICE_BOWLING: str = '🎳'
|
2020-11-29 16:20:46 +01:00
|
|
|
DICE_ALL_EMOJI: List[str] = [
|
|
|
|
DICE_DICE,
|
|
|
|
DICE_DARTS,
|
|
|
|
DICE_BASKETBALL,
|
|
|
|
DICE_FOOTBALL,
|
|
|
|
DICE_SLOT_MACHINE,
|
2021-03-14 16:41:35 +01:00
|
|
|
DICE_BOWLING,
|
2020-11-29 16:20:46 +01:00
|
|
|
]
|
2020-10-13 17:58:36 +02:00
|
|
|
|
|
|
|
MESSAGEENTITY_MENTION: str = 'mention'
|
|
|
|
MESSAGEENTITY_HASHTAG: str = 'hashtag'
|
|
|
|
MESSAGEENTITY_CASHTAG: str = 'cashtag'
|
|
|
|
MESSAGEENTITY_PHONE_NUMBER: str = 'phone_number'
|
|
|
|
MESSAGEENTITY_BOT_COMMAND: str = 'bot_command'
|
|
|
|
MESSAGEENTITY_URL: str = 'url'
|
|
|
|
MESSAGEENTITY_EMAIL: str = 'email'
|
|
|
|
MESSAGEENTITY_BOLD: str = 'bold'
|
|
|
|
MESSAGEENTITY_ITALIC: str = 'italic'
|
|
|
|
MESSAGEENTITY_CODE: str = 'code'
|
|
|
|
MESSAGEENTITY_PRE: str = 'pre'
|
|
|
|
MESSAGEENTITY_TEXT_LINK: str = 'text_link'
|
|
|
|
MESSAGEENTITY_TEXT_MENTION: str = 'text_mention'
|
|
|
|
MESSAGEENTITY_UNDERLINE: str = 'underline'
|
|
|
|
MESSAGEENTITY_STRIKETHROUGH: str = 'strikethrough'
|
|
|
|
MESSAGEENTITY_ALL_TYPES: List[str] = [
|
|
|
|
MESSAGEENTITY_MENTION,
|
|
|
|
MESSAGEENTITY_HASHTAG,
|
|
|
|
MESSAGEENTITY_CASHTAG,
|
|
|
|
MESSAGEENTITY_PHONE_NUMBER,
|
|
|
|
MESSAGEENTITY_BOT_COMMAND,
|
|
|
|
MESSAGEENTITY_URL,
|
|
|
|
MESSAGEENTITY_EMAIL,
|
|
|
|
MESSAGEENTITY_BOLD,
|
|
|
|
MESSAGEENTITY_ITALIC,
|
|
|
|
MESSAGEENTITY_CODE,
|
|
|
|
MESSAGEENTITY_PRE,
|
|
|
|
MESSAGEENTITY_TEXT_LINK,
|
|
|
|
MESSAGEENTITY_TEXT_MENTION,
|
|
|
|
MESSAGEENTITY_UNDERLINE,
|
|
|
|
MESSAGEENTITY_STRIKETHROUGH,
|
|
|
|
]
|
|
|
|
|
|
|
|
PARSEMODE_MARKDOWN: str = 'Markdown'
|
|
|
|
PARSEMODE_MARKDOWN_V2: str = 'MarkdownV2'
|
|
|
|
PARSEMODE_HTML: str = 'HTML'
|
|
|
|
|
|
|
|
POLL_REGULAR: str = 'regular'
|
|
|
|
POLL_QUIZ: str = 'quiz'
|
2020-11-29 16:20:46 +01:00
|
|
|
MAX_POLL_QUESTION_LENGTH: int = 300
|
|
|
|
MAX_POLL_OPTION_LENGTH: int = 100
|
2020-10-13 17:58:36 +02:00
|
|
|
|
|
|
|
STICKER_FOREHEAD: str = 'forehead'
|
|
|
|
STICKER_EYES: str = 'eyes'
|
|
|
|
STICKER_MOUTH: str = 'mouth'
|
|
|
|
STICKER_CHIN: str = 'chin'
|