mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 14:35:00 +01:00
Add Several New Enums To Constants (#3351)
This commit is contained in:
parent
caacafa090
commit
c3f8fcd7b7
42 changed files with 1262 additions and 230 deletions
|
@ -295,7 +295,7 @@ class TGConstXRefRole(PyXRefRole):
|
|||
|
||||
Example:
|
||||
|
||||
:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` renders as `4096` but links to the
|
||||
:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` renders as `4096` but links to the
|
||||
constant.
|
||||
"""
|
||||
|
||||
|
|
132
telegram/_bot.py
132
telegram/_bot.py
|
@ -681,8 +681,8 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
Args:
|
||||
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
||||
text (:obj:`str`): Text of the message to be sent. Max
|
||||
:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` characters after entities
|
||||
parsing.
|
||||
:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters after
|
||||
entities parsing.
|
||||
parse_mode (:obj:`str`): |parse_mode|
|
||||
entities (List[:class:`telegram.MessageEntity`], optional): List of special entities
|
||||
that appear in message text, which can be specified instead of
|
||||
|
@ -1723,7 +1723,10 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
|
||||
Note:
|
||||
To use this method, the file must have the type :mimetype:`audio/ogg` and be no more
|
||||
than ``1MB`` in size. ``1-20MB`` voice notes will be sent as files.
|
||||
than :tg-const:`telegram.constants.FileSizeLimit.VOICE_NOTE_FILE_SIZE` in size.
|
||||
:tg-const:`telegram.constants.FileSizeLimit.VOICE_NOTE_FILE_SIZE`-
|
||||
:tg-const:`telegram.constants.FileSizeLimit.FILESIZE_DOWNLOAD` voice notes will be
|
||||
sent as files.
|
||||
|
||||
.. seealso:: :attr:`telegram.Message.reply_voice`, :attr:`telegram.Chat.send_voice`,
|
||||
:attr:`telegram.User.send_voice`
|
||||
|
@ -1971,13 +1974,18 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
measured in meters;
|
||||
0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
|
||||
live_period (:obj:`int`, optional): Period in seconds for which the location will be
|
||||
updated, should be between 60 and 86400.
|
||||
updated, should be between
|
||||
:tg-const:`telegram.constants.LocationLimit.MIN_LIVE_PERIOD` and
|
||||
:tg-const:`telegram.constants.LocationLimit.MAX_LIVE_PERIOD`.
|
||||
heading (:obj:`int`, optional): For live locations, a direction in which the user is
|
||||
moving, in degrees. Must be between 1 and
|
||||
:tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
|
||||
moving, in degrees. Must be between
|
||||
:tg-const:`telegram.constants.LocationLimit.MIN_HEADING` and
|
||||
:tg-const:`telegram.constants.LocationLimit.MAX_HEADING` if specified.
|
||||
proximity_alert_radius (:obj:`int`, optional): For live locations, a maximum distance
|
||||
for proximity alerts about approaching another chat member, in meters. Must be
|
||||
between 1 and :tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
|
||||
between :tg-const:`telegram.constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS`
|
||||
and :tg-const:`telegram.constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS`
|
||||
if specified.
|
||||
disable_notification (:obj:`bool`, optional): |disable_notification|
|
||||
protect_content (:obj:`bool`, optional): |protect_content|
|
||||
|
||||
|
@ -2088,10 +2096,13 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
location, measured in meters;
|
||||
0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
|
||||
heading (:obj:`int`, optional): Direction in which the user is moving, in degrees. Must
|
||||
be between 1 and :tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
|
||||
be between :tg-const:`telegram.constants.LocationLimit.MIN_HEADING`
|
||||
and :tg-const:`telegram.constants.LocationLimit.MAX_HEADING` if specified.
|
||||
proximity_alert_radius (:obj:`int`, optional): Maximum distance for proximity alerts
|
||||
about approaching another chat member, in meters. Must be between 1 and
|
||||
:tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
|
||||
about approaching another chat member, in meters. Must be between
|
||||
:tg-const:`telegram.constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS`
|
||||
and :tg-const:`telegram.constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS`
|
||||
if specified.
|
||||
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for a new
|
||||
inline keyboard.
|
||||
|
||||
|
@ -2369,7 +2380,7 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
first_name (:obj:`str`, optional): Contact's first name.
|
||||
last_name (:obj:`str`, optional): Contact's last name.
|
||||
vcard (:obj:`str`, optional): Additional data about the contact in the form of a vCard,
|
||||
0-2048 bytes.
|
||||
0-:tg-const:`telegram.constants.ContactLimit.VCARD` bytes.
|
||||
disable_notification (:obj:`bool`, optional): |disable_notification|
|
||||
protect_content (:obj:`bool`, optional): |protect_content|
|
||||
|
||||
|
@ -2699,13 +2710,14 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
next_offset (:obj:`str`, optional): Pass the offset that a client should send in the
|
||||
next query with the same text to receive more results. Pass an empty string if
|
||||
there are no more results or if you don't support pagination. Offset length can't
|
||||
exceed 64 bytes.
|
||||
exceed :tg-const:`telegram.InlineQuery.MAX_OFFSET_LENGTH` bytes.
|
||||
switch_pm_text (:obj:`str`, optional): If passed, clients will display a button with
|
||||
specified text that switches the user to a private chat with the bot and sends the
|
||||
bot a start message with the parameter :paramref:`switch_pm_parameter`.
|
||||
switch_pm_parameter (:obj:`str`, optional): Deep-linking parameter for the
|
||||
:guilabel:`/start` message sent to the bot when user presses the switch button.
|
||||
1-:tg-const:`telegram.InlineQuery.MAX_SWITCH_PM_TEXT_LENGTH` characters,
|
||||
:tg-const:`telegram.InlineQuery.MIN_SWITCH_PM_TEXT_LENGTH`-
|
||||
:tg-const:`telegram.InlineQuery.MAX_SWITCH_PM_TEXT_LENGTH` characters,
|
||||
only ``A-Z``, ``a-z``, ``0-9``, ``_`` and ``-`` are allowed.
|
||||
|
||||
Keyword Args:
|
||||
|
@ -2775,7 +2787,9 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
offset (:obj:`int`, optional): Sequential number of the first photo to be returned.
|
||||
By default, all photos are returned.
|
||||
limit (:obj:`int`, optional): Limits the number of photos to be retrieved. Values
|
||||
between 1-100 are accepted. Defaults to ``100``.
|
||||
between :tg-const:`telegram.constants.UserProfilePhotosLimit.MIN_LIMIT`-
|
||||
:tg-const:`telegram.constants.UserProfilePhotosLimit.MAX_LIMIT` are accepted.
|
||||
Defaults to ``100``.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.UserProfilePhotos`
|
||||
|
@ -3193,8 +3207,9 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
inline_message_id (:obj:`str`, optional): Required if :paramref:`chat_id` and
|
||||
:paramref:`message_id` are not specified. Identifier of the inline message.
|
||||
text (:obj:`str`): New text of the message,
|
||||
1-:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` characters after entities
|
||||
parsing.
|
||||
:tg-const:`telegram.constants.MessageLimit.MIN_TEXT_LENGTH`-
|
||||
:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters after
|
||||
entities parsing.
|
||||
parse_mode (:obj:`str`, optional): |parse_mode|
|
||||
entities (List[:class:`telegram.MessageEntity`], optional): List of special entities
|
||||
that appear in message text, which can be specified instead of
|
||||
|
@ -3471,7 +3486,9 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
can be specified to retrieve updates starting from -offset update from the end of
|
||||
the updates queue. All previous updates will forgotten.
|
||||
limit (:obj:`int`, optional): Limits the number of updates to be retrieved. Values
|
||||
between 1-100 are accepted. Defaults to ``100``.
|
||||
between :tg-const:`telegram.constants.PollingLimit.MIN_LIMIT`-
|
||||
:tg-const:`telegram.constants.PollingLimit.MAX_LIMIT` are accepted.
|
||||
Defaults to ``100``.
|
||||
timeout (:obj:`int`, optional): Timeout in seconds for long polling. Defaults to ``0``,
|
||||
i.e. usual short polling. Should be positive, short polling should be used for
|
||||
testing purposes only.
|
||||
|
@ -3591,9 +3608,11 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
ip_address (:obj:`str`, optional): The fixed IP address which will be used to send
|
||||
webhook requests instead of the IP address resolved through DNS.
|
||||
max_connections (:obj:`int`, optional): Maximum allowed number of simultaneous HTTPS
|
||||
connections to the webhook for update delivery, 1-100. Defaults to ``40``. Use
|
||||
lower values to limit the load on your bot's server, and higher values to increase
|
||||
your bot's throughput.
|
||||
connections to the webhook for update delivery,
|
||||
:tg-const:`telegram.constants.WebhookLimit.MIN_CONNECTIONS_LIMIT`-
|
||||
:tg-const:`telegram.constants.WebhookLimit.MAX_CONNECTIONS_LIMIT`.
|
||||
Defaults to ``40``. Use lower values to limit the load on your bot's server,
|
||||
and higher values to increase your bot's throughput.
|
||||
allowed_updates (List[:obj:`str`], optional): A list the types of
|
||||
updates you want your bot to receive. For example, specify ["message",
|
||||
"edited_channel_post", "callback_query"] to only receive updates of these types.
|
||||
|
@ -4728,8 +4747,9 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
Args:
|
||||
chat_id (:obj:`int` | :obj:`str`): |chat_id_group|
|
||||
user_id (:obj:`int`): Unique identifier of the target administrator.
|
||||
custom_title (:obj:`str`): New custom title for the administrator; 0-16 characters,
|
||||
emoji are not allowed.
|
||||
custom_title (:obj:`str`): New custom title for the administrator;
|
||||
0-:tg-const:`telegram.constants.ChatLimit.CHAT_ADMINISTRATOR_CUSTOM_TITLE_LENGTH`
|
||||
characters, emoji are not allowed.
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
@ -4832,7 +4852,8 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
used.
|
||||
member_limit (:obj:`int`, optional): Maximum number of users that can be members of
|
||||
the chat simultaneously after joining the chat via this invite link;
|
||||
1-:tg-const:`telegram.constants.ChatInviteLinkLimit.MEMBER_LIMIT`.
|
||||
:tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
|
||||
:tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
|
||||
name (:obj:`str`, optional): Invite link name;
|
||||
0-:tg-const:`telegram.constants.ChatInviteLinkLimit.NAME_LENGTH` characters.
|
||||
|
||||
|
@ -4919,7 +4940,8 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
used.
|
||||
member_limit (:obj:`int`, optional): Maximum number of users that can be members of
|
||||
the chat simultaneously after joining the chat via this invite link;
|
||||
1-:tg-const:`telegram.constants.ChatInviteLinkLimit.MEMBER_LIMIT`.
|
||||
:tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
|
||||
:tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
|
||||
name (:obj:`str`, optional): Invite link name;
|
||||
0-:tg-const:`telegram.constants.ChatInviteLinkLimit.NAME_LENGTH` characters.
|
||||
|
||||
|
@ -5261,7 +5283,9 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
|
||||
Args:
|
||||
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
||||
description (:obj:`str`, optional): New chat description, 0-255 characters.
|
||||
description (:obj:`str`, optional): New chat description,
|
||||
0-:tg-const:`telegram.constants.ChatDescriptionLimit.DESCRIPTION_LENGTH`
|
||||
characters.
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
@ -5591,8 +5615,11 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
|||
(e.g., animals). Can contain only english letters, digits and underscores.
|
||||
Must begin with a letter, can't contain consecutive underscores and
|
||||
must end in "_by_<bot username>". <bot_username> is case insensitive.
|
||||
1-64 characters.
|
||||
title (:obj:`str`): Sticker set title, 1-64 characters.
|
||||
:tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`-
|
||||
:tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters.
|
||||
title (:obj:`str`): Sticker set title,
|
||||
:tg-const:`telegram.constants.StickerLimit.MIN_NAME_AND_TITLE`-
|
||||
:tg-const:`telegram.constants.StickerLimit.MAX_NAME_AND_TITLE` characters.
|
||||
png_sticker (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path`, \
|
||||
optional): **PNG** image with the sticker,
|
||||
must be up to 512 kilobytes in size, dimensions must not exceed 512px,
|
||||
|
@ -5980,11 +6007,13 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
|||
|
||||
Args:
|
||||
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
|
||||
question (:obj:`str`): Poll question, 1-:tg-const:`telegram.Poll.MAX_QUESTION_LENGTH`
|
||||
characters.
|
||||
question (:obj:`str`): Poll question, :tg-const:`telegram.Poll.MIN_QUESTION_LENGTH`-
|
||||
:tg-const:`telegram.Poll.MAX_QUESTION_LENGTH` characters.
|
||||
options (List[:obj:`str`]): List of answer options,
|
||||
2-:tg-const:`telegram.Poll.MAX_OPTION_NUMBER` strings
|
||||
1-:tg-const:`telegram.Poll.MAX_OPTION_LENGTH` characters each.
|
||||
:tg-const:`telegram.Poll.MIN_OPTION_NUMBER`-
|
||||
:tg-const:`telegram.Poll.MAX_OPTION_NUMBER` strings
|
||||
:tg-const:`telegram.Poll.MIN_OPTION_LENGTH`-
|
||||
:tg-const:`telegram.Poll.MAX_OPTION_LENGTH` characters each.
|
||||
is_anonymous (:obj:`bool`, optional): :obj:`True`, if the poll needs to be anonymous,
|
||||
defaults to :obj:`True`.
|
||||
type (:obj:`str`, optional): Poll type, :tg-const:`telegram.Poll.QUIZ` or
|
||||
|
@ -5994,8 +6023,10 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
|||
correct_option_id (:obj:`int`, optional): 0-based identifier of the correct answer
|
||||
option, required for polls in quiz mode.
|
||||
explanation (:obj:`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 characters with at most
|
||||
2 line feeds after entities parsing.
|
||||
answer or taps on the lamp icon in a quiz-style poll,
|
||||
0-:tg-const:`telegram.Poll.MAX_EXPLANATION_LENGTH` characters with at most
|
||||
:tg-const:`telegram.Poll.MAX_EXPLANATION_LINE_FEEDS` line feeds after entities
|
||||
parsing.
|
||||
explanation_parse_mode (:obj:`str`, optional): Mode for parsing entities in the
|
||||
explanation. See the constants in :class:`telegram.constants.ParseMode` for the
|
||||
available modes.
|
||||
|
@ -6003,11 +6034,14 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
|||
entities that appear in message text, which can be specified instead of
|
||||
:paramref:`explanation_parse_mode`.
|
||||
open_period (:obj:`int`, optional): Amount of time in seconds the poll will be active
|
||||
after creation, 5-600. Can't be used together with :paramref:`close_date`.
|
||||
after creation, :tg-const:`telegram.Poll.MIN_OPEN_PERIOD`-
|
||||
:tg-const:`telegram.Poll.MAX_OPEN_PERIOD`. Can't be used together with
|
||||
:paramref:`close_date`.
|
||||
close_date (:obj:`int` | :obj:`datetime.datetime`, optional): Point in time (Unix
|
||||
timestamp) when the poll will be automatically closed. Must be at least 5 and no
|
||||
more than 600 seconds in the future. Can't be used together with
|
||||
:paramref:`open_period`.
|
||||
timestamp) when the poll will be automatically closed. Must be at least
|
||||
:tg-const:`telegram.Poll.MIN_OPEN_PERIOD` and no more than
|
||||
:tg-const:`telegram.Poll.MAX_OPEN_PERIOD` seconds in the future.
|
||||
Can't be used together with :paramref:`open_period`.
|
||||
For timezone naive :obj:`datetime.datetime` objects, the default timezone of the
|
||||
bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is
|
||||
used.
|
||||
|
@ -6158,16 +6192,19 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
|||
keyboard, instructions to remove reply keyboard or to force a reply from the user
|
||||
emoji (:obj:`str`, optional): Emoji on which the dice throw animation is based.
|
||||
Currently, must be one of :class:`telegram.constants.DiceEmoji`. Dice can have
|
||||
values 1-6 for :tg-const:`telegram.constants.DiceEmoji.DICE`,
|
||||
:tg-const:`telegram.constants.DiceEmoji.DARTS` and
|
||||
:tg-const:`telegram.constants.DiceEmoji.BOWLING`, values 1-5 for
|
||||
:tg-const:`telegram.constants.DiceEmoji.BASKETBALL` and
|
||||
:tg-const:`telegram.constants.DiceEmoji.FOOTBALL`, and values 1-64
|
||||
for :tg-const:`telegram.constants.DiceEmoji.SLOT_MACHINE`. Defaults to
|
||||
:tg-const:`telegram.constants.DiceEmoji.DICE`.
|
||||
values
|
||||
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BOWLING`
|
||||
for :tg-const:`telegram.Dice.DICE`, :tg-const:`telegram.Dice.DARTS` and
|
||||
:tg-const:`telegram.Dice.BOWLING`, values
|
||||
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BASKETBALL`
|
||||
for :tg-const:`telegram.Dice.BASKETBALL` and :tg-const:`telegram.Dice.FOOTBALL`,
|
||||
and values :tg-const:`telegram.Dice.MIN_VALUE`-
|
||||
:tg-const:`telegram.Dice.MAX_VALUE_SLOT_MACHINE`
|
||||
for :tg-const:`telegram.Dice.SLOT_MACHINE`. Defaults to
|
||||
:tg-const:`telegram.Dice.DICE`.
|
||||
|
||||
.. versionchanged:: 13.4
|
||||
Added the :tg-const:`telegram.constants.DiceEmoji.BOWLING` emoji..
|
||||
Added the :tg-const:`telegram.Dice.BOWLING` emoji.
|
||||
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
|
||||
protect_content (:obj:`bool`, optional): |protect_content|
|
||||
|
||||
|
@ -6377,8 +6414,9 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
|||
|
||||
Args:
|
||||
commands (List[:class:`BotCommand` | (:obj:`str`, :obj:`str`)]): A list
|
||||
of bot commands to be set as the list of the bot's commands. At most 100 commands
|
||||
can be specified.
|
||||
of bot commands to be set as the list of the bot's commands. At most
|
||||
:tg-const:`telegram.constants.BotCommandLimit.MAX_COMMAND_NUMBER` commands can be
|
||||
specified.
|
||||
scope (:class:`telegram.BotCommandScope`, optional): An object,
|
||||
describing scope of users for which the commands are relevant. Defaults to
|
||||
:class:`telegram.BotCommandScopeDefault`.
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains an object that represents a Telegram Bot Command."""
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from telegram import constants
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils.types import JSONDict
|
||||
|
||||
|
@ -30,9 +33,12 @@ class BotCommand(TelegramObject):
|
|||
considered equal, if their :attr:`command` and :attr:`description` are equal.
|
||||
|
||||
Args:
|
||||
command (:obj:`str`): Text of the command; 1-32 characters. Can contain only lowercase
|
||||
command (:obj:`str`): Text of the command; :tg-const:`telegram.BotCommand.MIN_COMMAND`-
|
||||
:tg-const:`telegram.BotCommand.MAX_COMMAND` characters. Can contain only lowercase
|
||||
English letters, digits and underscores.
|
||||
description (:obj:`str`): Description of the command; 1-256 characters.
|
||||
description (:obj:`str`): Description of the command;
|
||||
:tg-const:`telegram.BotCommand.MIN_DESCRIPTION`-
|
||||
:tg-const:`telegram.BotCommand.MAX_DESCRIPTION` characters.
|
||||
|
||||
Attributes:
|
||||
command (:obj:`str`): Text of the command.
|
||||
|
@ -48,3 +54,24 @@ class BotCommand(TelegramObject):
|
|||
self.description = description
|
||||
|
||||
self._id_attrs = (self.command, self.description)
|
||||
|
||||
MIN_COMMAND: ClassVar[int] = constants.BotCommandLimit.MIN_COMMAND
|
||||
""":const:`telegram.constants.BotCommandLimit.MIN_COMMAND`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_COMMAND: ClassVar[int] = constants.BotCommandLimit.MAX_COMMAND
|
||||
""":const:`telegram.constants.BotCommandLimit.MAX_COMMAND`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_DESCRIPTION: ClassVar[int] = constants.BotCommandLimit.MIN_DESCRIPTION
|
||||
""":const:`telegram.constants.BotCommandLimit.MIN_DESCRIPTION`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_DESCRIPTION: ClassVar[int] = constants.BotCommandLimit.MAX_DESCRIPTION
|
||||
""":const:`telegram.constants.BotCommandLimit.MAX_DESCRIPTION`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -56,7 +56,8 @@ class ChatInviteLink(TelegramObject):
|
|||
has been expired.
|
||||
member_limit (:obj:`int`, optional): Maximum number of users that can be members of the
|
||||
chat simultaneously after joining the chat via this invite link;
|
||||
1-:tg-const:`telegram.constants.ChatInviteLinkLimit.MEMBER_LIMIT`.
|
||||
:tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
|
||||
:tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
|
||||
name (:obj:`str`, optional): Invite link name.
|
||||
0-:tg-const:`telegram.constants.ChatInviteLinkLimit.NAME_LENGTH` characters.
|
||||
|
||||
|
@ -78,7 +79,9 @@ class ChatInviteLink(TelegramObject):
|
|||
expire_date (:class:`datetime.datetime`): Optional. Date when the link will expire or
|
||||
has been expired.
|
||||
member_limit (:obj:`int`): Optional. Maximum number of users that can be members
|
||||
of the chat simultaneously after joining the chat via this invite link; 1-99999.
|
||||
of the chat simultaneously after joining the chat via this invite link;
|
||||
:tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
|
||||
:tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
|
||||
name (:obj:`str`): Optional. Invite link name.
|
||||
|
||||
.. versionadded:: 13.8
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains an object that represents a location to which a chat is connected."""
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from typing import TYPE_CHECKING, ClassVar, Optional
|
||||
|
||||
from telegram import constants
|
||||
from telegram._files.location import Location
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils.types import JSONDict
|
||||
|
@ -37,7 +38,9 @@ class ChatLocation(TelegramObject):
|
|||
Args:
|
||||
location (:class:`telegram.Location`): The location to which the supergroup is connected.
|
||||
Can't be a live location.
|
||||
address (:obj:`str`): Location address; 1-64 characters, as defined by the chat owner
|
||||
address (:obj:`str`): Location address;
|
||||
:tg-const:`telegram.ChatLocation.MIN_ADDRESS`-
|
||||
:tg-const:`telegram.ChatLocation.MAX_ADDRESS` characters, as defined by the chat owner
|
||||
Attributes:
|
||||
location (:class:`telegram.Location`): The location to which the supergroup is connected.
|
||||
address (:obj:`str`): Location address, as defined by the chat owner
|
||||
|
@ -70,3 +73,14 @@ class ChatLocation(TelegramObject):
|
|||
data["location"] = Location.de_json(data.get("location"), bot)
|
||||
|
||||
return super().de_json(data=data, bot=bot)
|
||||
|
||||
MIN_ADDRESS: ClassVar[int] = constants.LocationLimit.MIN_CHAT_LOCATION_ADDRESS
|
||||
""":const:`telegram.constants.LocationLimit.MIN_CHAT_LOCATION_ADDRESS`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_ADDRESS: ClassVar[int] = constants.LocationLimit.MAX_CHAT_LOCATION_ADDRESS
|
||||
""":const:`telegram.constants.LocationLimit.MAX_CHAT_LOCATION_ADDRESS`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -34,30 +34,43 @@ class Dice(TelegramObject):
|
|||
considered equal, if their :attr:`value` and :attr:`emoji` are equal.
|
||||
|
||||
Note:
|
||||
If :attr:`emoji` is "🎯", a value of 6 currently represents a bullseye, while a value of 1
|
||||
indicates that the dartboard was missed. However, this behaviour is undocumented and might
|
||||
be changed by Telegram.
|
||||
If :attr:`emoji` is :tg-const:`telegram.Dice.DARTS`, a value of 6 currently
|
||||
represents a bullseye, while a value of 1 indicates that the dartboard was missed.
|
||||
However, this behaviour is undocumented and might be changed by Telegram.
|
||||
|
||||
If :attr:`emoji` is "🏀", a value of 4 or 5 currently score a basket, while a value of 1 to
|
||||
3 indicates that the basket was missed. However, this behaviour is undocumented and might
|
||||
be changed by Telegram.
|
||||
If :attr:`emoji` is :tg-const:`telegram.Dice.BASKETBALL`, a value of 4 or 5
|
||||
currently score a basket, while a value of 1 to 3 indicates that the basket was missed.
|
||||
However, this behaviour is undocumented and might be changed by Telegram.
|
||||
|
||||
If :attr:`emoji` is "⚽", a value of 4 to 5 currently scores a goal, while a value of 1 to
|
||||
3 indicates that the goal was missed. However, this behaviour is undocumented and might
|
||||
be changed by Telegram.
|
||||
If :attr:`emoji` is :tg-const:`telegram.Dice.FOOTBALL`, a value of 4 to 5
|
||||
currently scores a goal, while a value of 1 to 3 indicates that the goal was missed.
|
||||
However, this behaviour is undocumented and might be changed by Telegram.
|
||||
|
||||
If :attr:`emoji` is "🎳", a value of 6 knocks all the pins, while a value of 1 means all
|
||||
the pins were missed. However, this behaviour is undocumented and might be changed by
|
||||
Telegram.
|
||||
If :attr:`emoji` is :tg-const:`telegram.Dice.BOWLING`, a value of 6 knocks
|
||||
all the pins, while a value of 1 means all the pins were missed.
|
||||
However, this behaviour is undocumented and might be changed by Telegram.
|
||||
|
||||
If :attr:`emoji` is "🎰", each value corresponds to a unique combination of symbols, which
|
||||
If :attr:`emoji` is :tg-const:`telegram.Dice.SLOT_MACHINE`, each value
|
||||
corresponds to a unique combination of symbols, which
|
||||
can be found at our `wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki\
|
||||
/Code-snippets#map-a-slot-machine-dice-value-to-the-corresponding-symbols>`_.
|
||||
However, this behaviour is undocumented and might be changed by Telegram.
|
||||
|
||||
..
|
||||
In args, some links for limits of `value` intentionally point to constants for only
|
||||
one emoji of a group to avoid duplication. For example, maximum value for Dice, Darts and
|
||||
Bowling is linked to a constant for Bowling.
|
||||
|
||||
Args:
|
||||
value (:obj:`int`): Value of the dice. 1-6 for dice, darts and bowling balls, 1-5 for
|
||||
basketball and football/soccer ball, 1-64 for slot machine.
|
||||
value (:obj:`int`): Value of the dice.
|
||||
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BOWLING`
|
||||
for :tg-const:`telegram.Dice.DICE`, :tg-const:`telegram.Dice.DARTS` and
|
||||
:tg-const:`telegram.Dice.BOWLING` base emoji,
|
||||
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BASKETBALL`
|
||||
for :tg-const:`telegram.Dice.BASKETBALL` and :tg-const:`telegram.Dice.FOOTBALL`
|
||||
base emoji,
|
||||
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_SLOT_MACHINE`
|
||||
for :tg-const:`telegram.Dice.SLOT_MACHINE` base emoji.
|
||||
emoji (:obj:`str`): Emoji on which the dice throw animation is based.
|
||||
|
||||
Attributes:
|
||||
|
@ -93,3 +106,45 @@ class Dice(TelegramObject):
|
|||
"""
|
||||
ALL_EMOJI: ClassVar[List[str]] = list(constants.DiceEmoji)
|
||||
"""List[:obj:`str`]: A list of all available dice emoji."""
|
||||
|
||||
MIN_VALUE: ClassVar[int] = constants.DiceLimit.MIN_VALUE
|
||||
""":const:`telegram.constants.DiceLimit.MIN_VALUE`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
MAX_VALUE_BOWLING: ClassVar[int] = constants.DiceLimit.MAX_VALUE_BOWLING
|
||||
""":const:`telegram.constants.DiceLimit.MAX_VALUE_BOWLING`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
MAX_VALUE_DARTS: ClassVar[int] = constants.DiceLimit.MAX_VALUE_DARTS
|
||||
""":const:`telegram.constants.DiceLimit.MAX_VALUE_DARTS`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
MAX_VALUE_DICE: ClassVar[int] = constants.DiceLimit.MAX_VALUE_DICE
|
||||
""":const:`telegram.constants.DiceLimit.MAX_VALUE_DICE`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
MAX_VALUE_BASKETBALL: ClassVar[int] = constants.DiceLimit.MAX_VALUE_BASKETBALL
|
||||
""":const:`telegram.constants.DiceLimit.MAX_VALUE_BASKETBALL`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
MAX_VALUE_FOOTBALL: ClassVar[int] = constants.DiceLimit.MAX_VALUE_FOOTBALL
|
||||
""":const:`telegram.constants.DiceLimit.MAX_VALUE_FOOTBALL`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
MAX_VALUE_SLOT_MACHINE: ClassVar[int] = constants.DiceLimit.MAX_VALUE_SLOT_MACHINE
|
||||
""":const:`telegram.constants.DiceLimit.MAX_VALUE_SLOT_MACHINE`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains an object that represents a Telegram ChatPhoto."""
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, ClassVar
|
||||
|
||||
from telegram import constants
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils.defaultvalue import DEFAULT_NONE
|
||||
from telegram._utils.types import JSONDict, ODVInput
|
||||
|
@ -35,30 +36,39 @@ class ChatPhoto(TelegramObject):
|
|||
equal.
|
||||
|
||||
Args:
|
||||
small_file_id (:obj:`str`): Unique file identifier of small (160x160) chat photo. This
|
||||
file_id can be used only for photo download and only for as long
|
||||
small_file_id (:obj:`str`): Unique file identifier of small
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
|
||||
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 (:obj:`str`): Unique file identifier of small (160x160) chat photo,
|
||||
which is supposed to be the same over time and for different bots.
|
||||
small_file_unique_id (:obj:`str`): Unique file identifier of small
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
|
||||
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 (:obj:`str`): Unique 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 (:obj:`str`): Unique file identifier of big (640x640) chat photo,
|
||||
which is supposed to be the same over time and for different bots.
|
||||
big_file_id (:obj:`str`): Unique file identifier of big
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
|
||||
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 (:obj:`str`): Unique file identifier of big
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
|
||||
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.
|
||||
|
||||
Attributes:
|
||||
small_file_id (:obj:`str`): File identifier of small (160x160) chat photo.
|
||||
This file_id can be used only for photo download and only for as long
|
||||
small_file_id (:obj:`str`): File identifier of small
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
|
||||
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 (:obj:`str`): Unique file identifier of small (160x160) chat photo,
|
||||
which is supposed to be the same over time and for different bots.
|
||||
small_file_unique_id (:obj:`str`): Unique file identifier of small
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
|
||||
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 (:obj:`str`): File identifier of big (640x640) chat photo.
|
||||
This file_id can be used only for photo download and only for as long as
|
||||
big_file_id (:obj:`str`): File identifier of big
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
|
||||
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 (:obj:`str`): Unique file identifier of big (640x640) chat photo,
|
||||
which is supposed to be the same over time and for different bots.
|
||||
big_file_unique_id (:obj:`str`): Unique file identifier of big
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
|
||||
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.
|
||||
|
||||
"""
|
||||
|
@ -99,8 +109,9 @@ class ChatPhoto(TelegramObject):
|
|||
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
api_kwargs: JSONDict = None,
|
||||
) -> "File":
|
||||
"""Convenience wrapper over :attr:`telegram.Bot.get_file` for getting the
|
||||
small (160x160) chat photo
|
||||
"""Convenience wrapper over :attr:`telegram.Bot.get_file` for getting the small
|
||||
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
|
||||
chat photo
|
||||
|
||||
For the documentation of the arguments, please see :meth:`telegram.Bot.get_file`.
|
||||
|
||||
|
@ -130,7 +141,8 @@ class ChatPhoto(TelegramObject):
|
|||
api_kwargs: JSONDict = None,
|
||||
) -> "File":
|
||||
"""Convenience wrapper over :attr:`telegram.Bot.get_file` for getting the
|
||||
big (640x640) chat photo
|
||||
big (:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
|
||||
chat photo
|
||||
|
||||
For the documentation of the arguments, please see :meth:`telegram.Bot.get_file`.
|
||||
|
||||
|
@ -149,3 +161,14 @@ class ChatPhoto(TelegramObject):
|
|||
pool_timeout=pool_timeout,
|
||||
api_kwargs=api_kwargs,
|
||||
)
|
||||
|
||||
SIZE_SMALL: ClassVar[int] = constants.ChatPhotoSize.SMALL
|
||||
""":const:`telegram.constants.ChatPhotoSize.SMALL`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
SIZE_BIG: ClassVar[int] = constants.ChatPhotoSize.BIG
|
||||
""":const:`telegram.constants.ChatPhotoSize.BIG`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains an object that represents a Telegram Location."""
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from telegram import constants
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils.types import JSONDict
|
||||
|
||||
|
@ -32,11 +35,12 @@ class Location(TelegramObject):
|
|||
longitude (:obj:`float`): Longitude as defined by sender.
|
||||
latitude (:obj:`float`): Latitude as defined by sender.
|
||||
horizontal_accuracy (:obj:`float`, optional): The radius of uncertainty for the location,
|
||||
measured in meters; 0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
|
||||
measured in meters; 0-:tg-const:`telegram.Location.HORIZONTAL_ACCURACY`.
|
||||
live_period (:obj:`int`, optional): Time relative to the message sending date, during which
|
||||
the location can be updated, in seconds. For active live locations only.
|
||||
heading (:obj:`int`, optional): The direction in which user is moving, in degrees;
|
||||
1-:tg-const:`telegram.constants.LocationLimit.HEADING`. For active live locations only.
|
||||
:tg-const:`telegram.Location.MIN_HEADING`-:tg-const:`telegram.Location.MAX_HEADING`.
|
||||
For active live locations only.
|
||||
proximity_alert_radius (:obj:`int`, optional): Maximum distance for proximity alerts about
|
||||
approaching another chat member, in meters. For sent live locations only.
|
||||
|
||||
|
@ -88,3 +92,19 @@ class Location(TelegramObject):
|
|||
)
|
||||
|
||||
self._id_attrs = (self.longitude, self.latitude)
|
||||
|
||||
HORIZONTAL_ACCURACY: ClassVar[int] = constants.LocationLimit.HORIZONTAL_ACCURACY
|
||||
""":const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_HEADING: ClassVar[int] = constants.LocationLimit.MIN_HEADING
|
||||
""":const:`telegram.constants.LocationLimit.MIN_HEADING`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_HEADING: ClassVar[int] = constants.LocationLimit.MAX_HEADING
|
||||
""":const:`telegram.constants.LocationLimit.MAX_HEADING`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains an object that represents a Telegram ForceReply."""
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from telegram import constants
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils.types import JSONDict
|
||||
|
||||
|
@ -46,7 +49,10 @@ class ForceReply(TelegramObject):
|
|||
original message.
|
||||
|
||||
input_field_placeholder (:obj:`str`, optional): The placeholder to be shown in the input
|
||||
field when the reply is active; 1-64 characters.
|
||||
field when the reply is active;
|
||||
:tg-const:`telegram.ForceReply.MIN_INPUT_FIELD_PLACEHOLDER`-
|
||||
:tg-const:`telegram.ForceReply.MAX_INPUT_FIELD_PLACEHOLDER`
|
||||
characters.
|
||||
|
||||
.. versionadded:: 13.7
|
||||
|
||||
|
@ -76,3 +82,14 @@ class ForceReply(TelegramObject):
|
|||
self.input_field_placeholder = input_field_placeholder
|
||||
|
||||
self._id_attrs = (self.selective,)
|
||||
|
||||
MIN_INPUT_FIELD_PLACEHOLDER: ClassVar[int] = constants.ReplyLimit.MIN_INPUT_FIELD_PLACEHOLDER
|
||||
""":const:`telegram.constants.ReplyLimit.MIN_INPUT_FIELD_PLACEHOLDER`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_INPUT_FIELD_PLACEHOLDER: ClassVar[int] = constants.ReplyLimit.MAX_INPUT_FIELD_PLACEHOLDER
|
||||
""":const:`telegram.constants.ReplyLimit.MAX_INPUT_FIELD_PLACEHOLDER`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -48,7 +48,7 @@ class Game(TelegramObject):
|
|||
game message. Can be automatically edited to include current high scores for the game
|
||||
when the bot calls :meth:`telegram.Bot.set_game_score`, or manually edited
|
||||
using :meth:`telegram.Bot.edit_message_text`.
|
||||
0-:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` characters.
|
||||
0-:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters.
|
||||
text_entities (List[:class:`telegram.MessageEntity`], optional): Special entities that
|
||||
appear in text, such as usernames, URLs, bot commands, etc.
|
||||
animation (:class:`telegram.Animation`, optional): Animation that will be displayed in the
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains an object that represents a Telegram InlineKeyboardButton."""
|
||||
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
from typing import TYPE_CHECKING, ClassVar, Optional, Union
|
||||
|
||||
from telegram import constants
|
||||
from telegram._games.callbackgame import CallbackGame
|
||||
from telegram._loginurl import LoginUrl
|
||||
from telegram._telegramobject import TelegramObject
|
||||
|
@ -86,8 +87,10 @@ class InlineKeyboardButton(TelegramObject):
|
|||
Caution:
|
||||
Only ``HTTPS`` links are allowed after Bot API 6.1.
|
||||
callback_data (:obj:`str` | :obj:`object`, optional): Data to be sent in a callback query
|
||||
to the bot when button is pressed, UTF-8 1-64 bytes. If the bot instance allows
|
||||
arbitrary callback data, anything can be passed.
|
||||
to the bot when button is pressed, UTF-8
|
||||
:tg-const:`telegram.InlineKeyboardButton.MIN_CALLBACK_DATA`-
|
||||
:tg-const:`telegram.InlineKeyboardButton.MAX_CALLBACK_DATA` bytes.
|
||||
If the bot instance allows arbitrary callback data, anything can be passed.
|
||||
|
||||
Tip:
|
||||
The value entered here will be available in :attr:`telegram.CallbackQuery.data`.
|
||||
|
@ -135,7 +138,9 @@ class InlineKeyboardButton(TelegramObject):
|
|||
Caution:
|
||||
Only ``HTTPS`` links are allowed after Bot API 6.1.
|
||||
callback_data (:obj:`str` | :obj:`object`): Optional. Data to be sent in a callback query
|
||||
to the bot when button is pressed, UTF-8 1-64 bytes.
|
||||
to the bot when button is pressed, UTF-8
|
||||
:tg-const:`telegram.InlineKeyboardButton.MIN_CALLBACK_DATA`-
|
||||
:tg-const:`telegram.InlineKeyboardButton.MAX_CALLBACK_DATA` bytes.
|
||||
web_app (:obj:`telegram.WebAppInfo`): Optional. Description of the `Web App
|
||||
<https://core.telegram.org/bots/webapps>`_ 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
|
||||
|
@ -236,3 +241,14 @@ class InlineKeyboardButton(TelegramObject):
|
|||
"""
|
||||
self.callback_data = callback_data
|
||||
self._set_id_attrs()
|
||||
|
||||
MIN_CALLBACK_DATA: ClassVar[int] = constants.InlineKeyboardButtonLimit.MIN_CALLBACK_DATA
|
||||
""":const:`telegram.constants.InlineKeyboardButtonLimit.MIN_CALLBACK_DATA`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_CALLBACK_DATA: ClassVar[int] = constants.InlineKeyboardButtonLimit.MAX_CALLBACK_DATA
|
||||
""":const:`telegram.constants.InlineKeyboardButtonLimit.MAX_CALLBACK_DATA`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -52,7 +52,8 @@ class InlineQuery(TelegramObject):
|
|||
Args:
|
||||
id (:obj:`str`): Unique identifier for this query.
|
||||
from_user (:class:`telegram.User`): Sender.
|
||||
query (:obj:`str`): Text of the query (up to 256 characters).
|
||||
query (:obj:`str`): Text of the query (up to
|
||||
:tg-const:`telegram.InlineQuery.MAX_QUERY_LENGTH` characters).
|
||||
offset (:obj:`str`): Offset of the results to be returned, can be controlled by the bot.
|
||||
chat_type (:obj:`str`, optional): Type of the chat, from which the inline query was sent.
|
||||
Can be either :tg-const:`telegram.Chat.SENDER` for a private chat with the inline query
|
||||
|
@ -68,7 +69,8 @@ class InlineQuery(TelegramObject):
|
|||
Attributes:
|
||||
id (:obj:`str`): Unique identifier for this query.
|
||||
from_user (:class:`telegram.User`): Sender.
|
||||
query (:obj:`str`): Text of the query (up to 256 characters).
|
||||
query (:obj:`str`): Text of the query (up to
|
||||
:tg-const:`telegram.InlineQuery.MAX_QUERY_LENGTH` characters).
|
||||
offset (:obj:`str`): Offset of the results to be returned, can be controlled by the bot.
|
||||
location (:class:`telegram.Location`): Optional. Sender location, only for bots that
|
||||
request user location.
|
||||
|
@ -185,8 +187,23 @@ class InlineQuery(TelegramObject):
|
|||
|
||||
.. versionadded:: 13.2
|
||||
"""
|
||||
MAX_SWITCH_PM_TEXT_LENGTH: ClassVar[int] = constants.InlineQueryLimit.SWITCH_PM_TEXT_LENGTH
|
||||
""":const:`telegram.constants.InlineQueryLimit.SWITCH_PM_TEXT_LENGTH`
|
||||
MIN_SWITCH_PM_TEXT_LENGTH: ClassVar[int] = constants.InlineQueryLimit.MIN_SWITCH_PM_TEXT_LENGTH
|
||||
""":const:`telegram.constants.InlineQueryLimit.MIN_SWITCH_PM_TEXT_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_SWITCH_PM_TEXT_LENGTH: ClassVar[int] = constants.InlineQueryLimit.MAX_SWITCH_PM_TEXT_LENGTH
|
||||
""":const:`telegram.constants.InlineQueryLimit.MAX_SWITCH_PM_TEXT_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_OFFSET_LENGTH: ClassVar[int] = constants.InlineQueryLimit.MAX_OFFSET_LENGTH
|
||||
""":const:`telegram.constants.InlineQueryLimit.MAX_OFFSET_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_QUERY_LENGTH: ClassVar[int] = constants.InlineQueryLimit.MAX_QUERY_LENGTH
|
||||
""":const:`telegram.constants.InlineQueryLimit.MAX_QUERY_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
# pylint: disable=redefined-builtin
|
||||
"""This module contains the classes that represent Telegram InlineQueryResult."""
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from telegram import constants
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils.types import JSONDict
|
||||
|
||||
|
@ -38,11 +41,15 @@ class InlineQueryResult(TelegramObject):
|
|||
|
||||
Args:
|
||||
type (:obj:`str`): Type of the result.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
|
||||
Attributes:
|
||||
type (:obj:`str`): Type of the result.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
|
||||
"""
|
||||
|
||||
|
@ -56,3 +63,14 @@ class InlineQueryResult(TelegramObject):
|
|||
self.id = str(id) # pylint: disable=invalid-name
|
||||
|
||||
self._id_attrs = (self.id,)
|
||||
|
||||
MIN_ID_LENGTH: ClassVar[int] = constants.InlineQueryResultLimit.MIN_ID_LENGTH
|
||||
""":const:`telegram.constants.InlineQueryResultLimit.MIN_ID_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_ID_LENGTH: ClassVar[int] = constants.InlineQueryResultLimit.MAX_ID_LENGTH
|
||||
""":const:`telegram.constants.InlineQueryResultLimit.MAX_ID_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -36,7 +36,9 @@ class InlineQueryResultArticle(InlineQueryResult):
|
|||
:any:`Inline Bot <examples.inlinebot>`
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
title (:obj:`str`): Title of the result.
|
||||
input_message_content (:class:`telegram.InputMessageContent`): Content of the message to
|
||||
be sent.
|
||||
|
@ -52,7 +54,9 @@ class InlineQueryResultArticle(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.ARTICLE`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
title (:obj:`str`): Title of the result.
|
||||
input_message_content (:class:`telegram.InputMessageContent`): Content of the message to
|
||||
be sent.
|
||||
|
|
|
@ -38,7 +38,9 @@ class InlineQueryResultAudio(InlineQueryResult):
|
|||
content instead of the audio.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
audio_url (:obj:`str`): A valid URL for the audio file.
|
||||
title (:obj:`str`): Title.
|
||||
performer (:obj:`str`, optional): Performer.
|
||||
|
@ -55,7 +57,9 @@ class InlineQueryResultAudio(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.AUDIO`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
audio_url (:obj:`str`): A valid URL for the audio file.
|
||||
title (:obj:`str`): Title.
|
||||
performer (:obj:`str`): Optional. Performer.
|
||||
|
|
|
@ -38,7 +38,9 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
|
|||
send a message with the specified content instead of the audio.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
audio_file_id (:obj:`str`): A valid file identifier for the audio file.
|
||||
caption (:obj:`str`, optional): Caption,
|
||||
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities
|
||||
|
@ -52,7 +54,9 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.AUDIO`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
audio_file_id (:obj:`str`): A valid file identifier for the audio file.
|
||||
caption (:obj:`str`): Optional. Caption,
|
||||
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities
|
||||
|
|
|
@ -38,7 +38,9 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
|
|||
to send a message with the specified content instead of the file.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
title (:obj:`str`): Title for the result.
|
||||
document_file_id (:obj:`str`): A valid file identifier for the file.
|
||||
description (:obj:`str`, optional): Short description of the result.
|
||||
|
@ -54,7 +56,9 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.DOCUMENT`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
title (:obj:`str`): Title for the result.
|
||||
document_file_id (:obj:`str`): A valid file identifier for the file.
|
||||
description (:obj:`str`): Optional. Short description of the result.
|
||||
|
|
|
@ -39,7 +39,9 @@ class InlineQueryResultCachedGif(InlineQueryResult):
|
|||
the animation.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
gif_file_id (:obj:`str`): A valid file identifier for the GIF file.
|
||||
title (:obj:`str`, optional): Title for the result.caption (:obj:`str`, optional):
|
||||
caption (:obj:`str`, optional): Caption of the GIF file to be sent,
|
||||
|
@ -54,7 +56,9 @@ class InlineQueryResultCachedGif(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.GIF`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
gif_file_id (:obj:`str`): A valid file identifier for the GIF file.
|
||||
title (:obj:`str`): Optional. Title for the result.
|
||||
caption (:obj:`str`): Optional. Caption of the GIF file to be sent,
|
||||
|
|
|
@ -39,7 +39,9 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
|
|||
with the specified content instead of the animation.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
mpeg4_file_id (:obj:`str`): A valid file identifier for the MP4 file.
|
||||
title (:obj:`str`, optional): Title for the result.
|
||||
caption (:obj:`str`, optional): Caption of the MPEG-4 file to be sent,
|
||||
|
@ -54,7 +56,9 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.MPEG4GIF`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
mpeg4_file_id (:obj:`str`): A valid file identifier for the MP4 file.
|
||||
title (:obj:`str`): Optional. Title for the result.
|
||||
caption (:obj:`str`): Optional. Caption of the MPEG-4 file to be sent,
|
||||
|
|
|
@ -39,7 +39,9 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
|
|||
of the photo.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
photo_file_id (:obj:`str`): A valid file identifier of the photo.
|
||||
title (:obj:`str`, optional): Title for the result.
|
||||
description (:obj:`str`, optional): Short description of the result.
|
||||
|
@ -55,7 +57,9 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.PHOTO`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
photo_file_id (:obj:`str`): A valid file identifier of the photo.
|
||||
title (:obj:`str`): Optional. Title for the result.
|
||||
description (:obj:`str`): Optional. Short description of the result.
|
||||
|
|
|
@ -36,7 +36,9 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
|
|||
message with the specified content instead of the sticker.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
sticker_file_id (:obj:`str`): A valid file identifier of the sticker.
|
||||
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached
|
||||
to the message.
|
||||
|
@ -45,7 +47,9 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.STICKER`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
sticker_file_id (:obj:`str`): A valid file identifier of the sticker.
|
||||
reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached
|
||||
to the message.
|
||||
|
|
|
@ -39,7 +39,9 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
|
|||
of the video.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
video_file_id (:obj:`str`): A valid file identifier for the video file.
|
||||
title (:obj:`str`): Title for the result.
|
||||
description (:obj:`str`, optional): Short description of the result.
|
||||
|
@ -55,7 +57,9 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.VIDEO`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
video_file_id (:obj:`str`): A valid file identifier for the video file.
|
||||
title (:obj:`str`): Title for the result.
|
||||
description (:obj:`str`): Optional. Short description of the result.
|
||||
|
|
|
@ -38,7 +38,9 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
|
|||
send a message with the specified content instead of the voice message.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
voice_file_id (:obj:`str`): A valid file identifier for the voice message.
|
||||
title (:obj:`str`): Voice message title.
|
||||
caption (:obj:`str`, optional): Caption,
|
||||
|
@ -53,7 +55,9 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.VOICE`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
voice_file_id (:obj:`str`): A valid file identifier for the voice message.
|
||||
title (:obj:`str`): Voice message title.
|
||||
caption (:obj:`str`): Optional. Caption,
|
||||
|
|
|
@ -36,12 +36,14 @@ class InlineQueryResultContact(InlineQueryResult):
|
|||
content instead of the contact.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
phone_number (:obj:`str`): Contact's phone number.
|
||||
first_name (:obj:`str`): Contact's first name.
|
||||
last_name (:obj:`str`, optional): Contact's last name.
|
||||
vcard (:obj:`str`, optional): Additional data about the contact in the form of a vCard,
|
||||
0-2048 bytes.
|
||||
0-:tg-const:`telegram.constants.ContactLimit.VCARD` bytes.
|
||||
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached
|
||||
to the message.
|
||||
input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the
|
||||
|
@ -52,12 +54,14 @@ class InlineQueryResultContact(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.CONTACT`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
phone_number (:obj:`str`): Contact's phone number.
|
||||
first_name (:obj:`str`): Contact's first name.
|
||||
last_name (:obj:`str`): Optional. Contact's last name.
|
||||
vcard (:obj:`str`): Optional. Additional data about the contact in the form of a vCard,
|
||||
0-2048 bytes.
|
||||
0-:tg-const:`telegram.constants.ContactLimit.VCARD` bytes.
|
||||
reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached
|
||||
to the message.
|
||||
input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the
|
||||
|
|
|
@ -39,7 +39,9 @@ class InlineQueryResultDocument(InlineQueryResult):
|
|||
using this method.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
title (:obj:`str`): Title for the result.
|
||||
caption (:obj:`str`, optional): Caption of the document to be sent,
|
||||
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters
|
||||
|
@ -60,7 +62,9 @@ class InlineQueryResultDocument(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.DOCUMENT`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
title (:obj:`str`): Title for the result.
|
||||
caption (:obj:`str`): Optional. Caption of the document to be sent,
|
||||
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters
|
||||
|
|
|
@ -28,14 +28,18 @@ class InlineQueryResultGame(InlineQueryResult):
|
|||
"""Represents a :class:`telegram.Game`.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
game_short_name (:obj:`str`): Short name of the game.
|
||||
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached
|
||||
to the message.
|
||||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.GAME`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
game_short_name (:obj:`str`): Short name of the game.
|
||||
reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached
|
||||
to the message.
|
||||
|
|
|
@ -38,7 +38,9 @@ class InlineQueryResultGif(InlineQueryResult):
|
|||
send a message with the specified content instead of the animation.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
gif_url (:obj:`str`): A valid URL for the GIF file. File size must not exceed 1MB.
|
||||
gif_width (:obj:`int`, optional): Width of the GIF.
|
||||
gif_height (:obj:`int`, optional): Height of the GIF.
|
||||
|
@ -60,7 +62,9 @@ class InlineQueryResultGif(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.GIF`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
gif_url (:obj:`str`): A valid URL for the GIF file. File size must not exceed 1MB.
|
||||
gif_width (:obj:`int`): Optional. Width of the GIF.
|
||||
gif_height (:obj:`int`): Optional. Height of the GIF.
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains the classes that represent Telegram InlineQueryResultLocation."""
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, ClassVar
|
||||
|
||||
from telegram import constants
|
||||
from telegram._inline.inlinekeyboardmarkup import InlineKeyboardMarkup
|
||||
from telegram._inline.inlinequeryresult import InlineQueryResult
|
||||
from telegram._utils.types import JSONDict
|
||||
from telegram.constants import InlineQueryResultType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from telegram import InputMessageContent
|
||||
|
@ -36,20 +36,28 @@ class InlineQueryResultLocation(InlineQueryResult):
|
|||
content instead of the location.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
latitude (:obj:`float`): Location latitude in degrees.
|
||||
longitude (:obj:`float`): Location longitude in degrees.
|
||||
title (:obj:`str`): Location title.
|
||||
horizontal_accuracy (:obj:`float`, optional): The radius of uncertainty for the location,
|
||||
measured in meters; 0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
|
||||
live_period (:obj:`int`, optional): Period in seconds for which the location can be
|
||||
updated, should be between 60 and 86400.
|
||||
measured in meters; 0-
|
||||
:tg-const:`telegram.InlineQueryResultLocation.HORIZONTAL_ACCURACY`.
|
||||
live_period (:obj:`int`, optional): Period in seconds for which the location will be
|
||||
updated, should be between
|
||||
:tg-const:`telegram.InlineQueryResultLocation.MIN_LIVE_PERIOD` and
|
||||
:tg-const:`telegram.InlineQueryResultLocation.MAX_LIVE_PERIOD`.
|
||||
heading (:obj:`int`, optional): For live locations, a direction in which the user is
|
||||
moving, in degrees. Must be between 1 and
|
||||
:tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
|
||||
proximity_alert_radius (:obj:`int`, optional): For live locations, a maximum distance for
|
||||
proximity alerts about approaching another chat member, in meters. Must be between 1
|
||||
and :tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
|
||||
moving, in degrees. Must be between
|
||||
:tg-const:`telegram.InlineQueryResultLocation.MIN_HEADING` and
|
||||
:tg-const:`telegram.InlineQueryResultLocation.MAX_HEADING` if specified.
|
||||
proximity_alert_radius (:obj:`int`, optional): For live locations, a maximum distance
|
||||
for proximity alerts about approaching another chat member, in meters. Must be
|
||||
between :tg-const:`telegram.InlineQueryResultLocation.MIN_PROXIMITY_ALERT_RADIUS`
|
||||
and :tg-const:`telegram.InlineQueryResultLocation.MAX_PROXIMITY_ALERT_RADIUS`
|
||||
if specified.
|
||||
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached
|
||||
to the message.
|
||||
input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the
|
||||
|
@ -60,7 +68,9 @@ class InlineQueryResultLocation(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.LOCATION`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
latitude (:obj:`float`): Location latitude in degrees.
|
||||
longitude (:obj:`float`): Location longitude in degrees.
|
||||
title (:obj:`str`): Location title.
|
||||
|
@ -116,7 +126,7 @@ class InlineQueryResultLocation(InlineQueryResult):
|
|||
api_kwargs: JSONDict = None,
|
||||
):
|
||||
# Required
|
||||
super().__init__(InlineQueryResultType.LOCATION, id, api_kwargs=api_kwargs)
|
||||
super().__init__(constants.InlineQueryResultType.LOCATION, id, api_kwargs=api_kwargs)
|
||||
self.latitude = latitude
|
||||
self.longitude = longitude
|
||||
self.title = title
|
||||
|
@ -133,3 +143,39 @@ class InlineQueryResultLocation(InlineQueryResult):
|
|||
self.proximity_alert_radius = (
|
||||
int(proximity_alert_radius) if proximity_alert_radius else None
|
||||
)
|
||||
|
||||
HORIZONTAL_ACCURACY: ClassVar[int] = constants.LocationLimit.HORIZONTAL_ACCURACY
|
||||
""":const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_HEADING: ClassVar[int] = constants.LocationLimit.MIN_HEADING
|
||||
""":const:`telegram.constants.LocationLimit.MIN_HEADING`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_HEADING: ClassVar[int] = constants.LocationLimit.MAX_HEADING
|
||||
""":const:`telegram.constants.LocationLimit.MAX_HEADING`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_LIVE_PERIOD: ClassVar[int] = constants.LocationLimit.MIN_LIVE_PERIOD
|
||||
""":const:`telegram.constants.LocationLimit.MIN_LIVE_PERIOD`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_LIVE_PERIOD: ClassVar[int] = constants.LocationLimit.MAX_LIVE_PERIOD
|
||||
""":const:`telegram.constants.LocationLimit.MAX_LIVE_PERIOD`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_PROXIMITY_ALERT_RADIUS: ClassVar[int] = constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS
|
||||
""":const:`telegram.constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_PROXIMITY_ALERT_RADIUS: ClassVar[int] = constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS
|
||||
""":const:`telegram.constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -39,7 +39,9 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
|||
animation.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
mpeg4_url (:obj:`str`): A valid URL for the MP4 file. File size must not exceed 1MB.
|
||||
mpeg4_width (:obj:`int`, optional): Video width.
|
||||
mpeg4_height (:obj:`int`, optional): Video height.
|
||||
|
@ -60,7 +62,9 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.MPEG4GIF`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
mpeg4_url (:obj:`str`): A valid URL for the MP4 file. File size must not exceed 1MB.
|
||||
mpeg4_width (:obj:`int`): Optional. Video width.
|
||||
mpeg4_height (:obj:`int`): Optional. Video height.
|
||||
|
|
|
@ -38,7 +38,9 @@ class InlineQueryResultPhoto(InlineQueryResult):
|
|||
specified content instead of the photo.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
photo_url (:obj:`str`): A valid URL of the photo. Photo must be in JPEG format. Photo size
|
||||
must not exceed 5MB.
|
||||
thumb_url (:obj:`str`): URL of the thumbnail for the photo.
|
||||
|
@ -58,7 +60,9 @@ class InlineQueryResultPhoto(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.PHOTO`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
photo_url (:obj:`str`): A valid URL of the photo. Photo must be in JPEG format. Photo size
|
||||
must not exceed 5MB.
|
||||
thumb_url (:obj:`str`): URL of the thumbnail for the photo.
|
||||
|
|
|
@ -40,7 +40,9 @@ class InlineQueryResultVenue(InlineQueryResult):
|
|||
behaviour is undocumented and might be changed by Telegram.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
latitude (:obj:`float`): Latitude of the venue location in degrees.
|
||||
longitude (:obj:`float`): Longitude of the venue location in degrees.
|
||||
title (:obj:`str`): Title of the venue.
|
||||
|
@ -63,7 +65,9 @@ class InlineQueryResultVenue(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.VENUE`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
latitude (:obj:`float`): Latitude of the venue location in degrees.
|
||||
longitude (:obj:`float`): Longitude of the venue location in degrees.
|
||||
title (:obj:`str`): Title of the venue.
|
||||
|
|
|
@ -43,7 +43,9 @@ class InlineQueryResultVideo(InlineQueryResult):
|
|||
replace its content using :attr:`input_message_content`.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
video_url (:obj:`str`): A valid URL for the embedded video player or video file.
|
||||
mime_type (:obj:`str`): Mime type of the content of video url, "text/html" or "video/mp4".
|
||||
thumb_url (:obj:`str`): URL of the thumbnail (JPEG only) for the video.
|
||||
|
@ -66,7 +68,9 @@ class InlineQueryResultVideo(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.VIDEO`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
video_url (:obj:`str`): A valid URL for the embedded video player or video file.
|
||||
mime_type (:obj:`str`): Mime type of the content of video url, "text/html" or "video/mp4".
|
||||
thumb_url (:obj:`str`): URL of the thumbnail (JPEG only) for the video.
|
||||
|
|
|
@ -39,7 +39,9 @@ class InlineQueryResultVoice(InlineQueryResult):
|
|||
the voice message.
|
||||
|
||||
Args:
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
voice_url (:obj:`str`): A valid URL for the voice recording.
|
||||
title (:obj:`str`): Recording title.
|
||||
caption (:obj:`str`, optional): Caption,
|
||||
|
@ -55,7 +57,9 @@ class InlineQueryResultVoice(InlineQueryResult):
|
|||
|
||||
Attributes:
|
||||
type (:obj:`str`): :tg-const:`telegram.constants.InlineQueryResultType.VOICE`.
|
||||
id (:obj:`str`): Unique identifier for this result, 1-64 bytes.
|
||||
id (:obj:`str`): Unique identifier for this result,
|
||||
:tg-const:`telegram.InlineQueryResult.MIN_ID_LENGTH`-
|
||||
:tg-const:`telegram.InlineQueryResult.MAX_ID_LENGTH` Bytes.
|
||||
voice_url (:obj:`str`): A valid URL for the voice recording.
|
||||
title (:obj:`str`): Recording title.
|
||||
caption (:obj:`str`): Optional. Caption,
|
||||
|
|
|
@ -33,14 +33,14 @@ class InputContactMessageContent(InputMessageContent):
|
|||
first_name (:obj:`str`): Contact's first name.
|
||||
last_name (:obj:`str`, optional): Contact's last name.
|
||||
vcard (:obj:`str`, optional): Additional data about the contact in the form of a vCard,
|
||||
0-2048 bytes.
|
||||
0-:tg-const:`telegram.constants.ContactLimit.VCARD` bytes.
|
||||
|
||||
Attributes:
|
||||
phone_number (:obj:`str`): Contact's phone number.
|
||||
first_name (:obj:`str`): Contact's first name.
|
||||
last_name (:obj:`str`): Optional. Contact's last name.
|
||||
vcard (:obj:`str`): Optional. Additional data about the contact in the form of a vCard,
|
||||
0-2048 bytes.
|
||||
0-:tg-const:`telegram.constants.ContactLimit.VCARD` bytes.
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains the classes that represent Telegram InputLocationMessageContent."""
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from telegram import constants
|
||||
from telegram._inline.inputmessagecontent import InputMessageContent
|
||||
from telegram._utils.types import JSONDict
|
||||
|
||||
|
@ -34,15 +37,21 @@ class InputLocationMessageContent(InputMessageContent):
|
|||
latitude (:obj:`float`): Latitude of the location in degrees.
|
||||
longitude (:obj:`float`): Longitude of the location in degrees.
|
||||
horizontal_accuracy (:obj:`float`, optional): The radius of uncertainty for the location,
|
||||
measured in meters; 0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
|
||||
live_period (:obj:`int`, optional): Period in seconds for which the location can be
|
||||
updated, should be between 60 and 86400.
|
||||
measured in meters; 0-
|
||||
:tg-const:`telegram.InputLocationMessageContent.HORIZONTAL_ACCURACY`.
|
||||
live_period (:obj:`int`, optional): Period in seconds for which the location will be
|
||||
updated, should be between
|
||||
:tg-const:`telegram.InputLocationMessageContent.MIN_LIVE_PERIOD` and
|
||||
:tg-const:`telegram.InputLocationMessageContent.MAX_LIVE_PERIOD`.
|
||||
heading (:obj:`int`, optional): For live locations, a direction in which the user is
|
||||
moving, in degrees. Must be between 1 and
|
||||
:tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
|
||||
proximity_alert_radius (:obj:`int`, optional): For live locations, a maximum distance for
|
||||
proximity alerts about approaching another chat member, in meters. Must be between 1
|
||||
and :tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
|
||||
moving, in degrees. Must be between
|
||||
:tg-const:`telegram.InputLocationMessageContent.MIN_HEADING` and
|
||||
:tg-const:`telegram.InputLocationMessageContent.MAX_HEADING` if specified.
|
||||
proximity_alert_radius (:obj:`int`, optional): For live locations, a maximum distance
|
||||
for proximity alerts about approaching another chat member, in meters. Must be
|
||||
between :tg-const:`telegram.InputLocationMessageContent.MIN_PROXIMITY_ALERT_RADIUS`
|
||||
and :tg-const:`telegram.InputLocationMessageContent.MAX_PROXIMITY_ALERT_RADIUS`
|
||||
if specified.
|
||||
|
||||
Attributes:
|
||||
latitude (:obj:`float`): Latitude of the location in degrees.
|
||||
|
@ -87,3 +96,39 @@ class InputLocationMessageContent(InputMessageContent):
|
|||
)
|
||||
|
||||
self._id_attrs = (self.latitude, self.longitude)
|
||||
|
||||
HORIZONTAL_ACCURACY: ClassVar[int] = constants.LocationLimit.HORIZONTAL_ACCURACY
|
||||
""":const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_HEADING: ClassVar[int] = constants.LocationLimit.MIN_HEADING
|
||||
""":const:`telegram.constants.LocationLimit.MIN_HEADING`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_HEADING: ClassVar[int] = constants.LocationLimit.MAX_HEADING
|
||||
""":const:`telegram.constants.LocationLimit.MAX_HEADING`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_LIVE_PERIOD: ClassVar[int] = constants.LocationLimit.MIN_LIVE_PERIOD
|
||||
""":const:`telegram.constants.LocationLimit.MIN_LIVE_PERIOD`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_LIVE_PERIOD: ClassVar[int] = constants.LocationLimit.MAX_LIVE_PERIOD
|
||||
""":const:`telegram.constants.LocationLimit.MAX_LIVE_PERIOD`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_PROXIMITY_ALERT_RADIUS: ClassVar[int] = constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS
|
||||
""":const:`telegram.constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_PROXIMITY_ALERT_RADIUS: ClassVar[int] = constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS
|
||||
""":const:`telegram.constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -38,7 +38,8 @@ class InputTextMessageContent(InputMessageContent):
|
|||
|
||||
Args:
|
||||
message_text (:obj:`str`): Text of the message to be sent,
|
||||
1-:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` characters after entities
|
||||
:tg-const:`telegram.constants.MessageLimit.MIN_TEXT_LENGTH`-
|
||||
:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters after entities
|
||||
parsing.
|
||||
parse_mode (:obj:`str`, optional): |parse_mode|
|
||||
entities (List[:class:`telegram.MessageEntity`], optional): |caption_entities|
|
||||
|
@ -47,7 +48,7 @@ class InputTextMessageContent(InputMessageContent):
|
|||
|
||||
Attributes:
|
||||
message_text (:obj:`str`): Text of the message to be sent,
|
||||
1-:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` characters after entities
|
||||
1-:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters after entities
|
||||
parsing.
|
||||
parse_mode (:obj:`str`): Optional. |parse_mode|
|
||||
entities (List[:class:`telegram.MessageEntity`]): Optional. |caption_entities|
|
||||
|
|
|
@ -139,7 +139,7 @@ class Message(TelegramObject):
|
|||
media_group_id (:obj:`str`, optional): The unique identifier of a media message group this
|
||||
message belongs to.
|
||||
text (:obj:`str`, optional): For text messages, the actual UTF-8 text of the message,
|
||||
0-:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` characters.
|
||||
0-:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters.
|
||||
entities (List[:class:`telegram.MessageEntity`], optional): For text messages, special
|
||||
entities like usernames, URLs, bot commands, etc. that appear in the text. See
|
||||
:attr:`parse_entity` and :attr:`parse_entities` methods for how to use properly.
|
||||
|
@ -308,7 +308,7 @@ class Message(TelegramObject):
|
|||
media_group_id (:obj:`str`): Optional. The unique identifier of a media message group this
|
||||
message belongs to.
|
||||
text (:obj:`str`): Optional. For text messages, the actual UTF-8 text of the message,
|
||||
0-:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` characters.
|
||||
0-:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` characters.
|
||||
entities (List[:class:`telegram.MessageEntity`]): Optional. For text messages, special
|
||||
entities like usernames, URLs, bot commands, etc. that appear in the text. See
|
||||
:attr:`parse_entity` and :attr:`parse_entities` methods for how to use properly.
|
||||
|
|
|
@ -42,11 +42,15 @@ class PollOption(TelegramObject):
|
|||
considered equal, if their :attr:`text` and :attr:`voter_count` are equal.
|
||||
|
||||
Args:
|
||||
text (:obj:`str`): Option text, 1-100 characters.
|
||||
text (:obj:`str`): Option text,
|
||||
:tg-const:`telegram.PollOption.MIN_LENGTH`-:tg-const:`telegram.PollOption.MAX_LENGTH`
|
||||
characters.
|
||||
voter_count (:obj:`int`): Number of users that voted for this option.
|
||||
|
||||
Attributes:
|
||||
text (:obj:`str`): Option text, 1-100 characters.
|
||||
text (:obj:`str`): Option text,
|
||||
:tg-const:`telegram.PollOption.MIN_LENGTH`-:tg-const:`telegram.PollOption.MAX_LENGTH`
|
||||
characters.
|
||||
voter_count (:obj:`int`): Number of users that voted for this option.
|
||||
|
||||
"""
|
||||
|
@ -60,8 +64,16 @@ class PollOption(TelegramObject):
|
|||
|
||||
self._id_attrs = (self.text, self.voter_count)
|
||||
|
||||
MAX_LENGTH: ClassVar[int] = constants.PollLimit.OPTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.OPTION_LENGTH`"""
|
||||
MIN_LENGTH: ClassVar[int] = constants.PollLimit.MIN_OPTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.MIN_OPTION_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_LENGTH: ClassVar[int] = constants.PollLimit.MAX_OPTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.MAX_OPTION_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
|
||||
class PollAnswer(TelegramObject):
|
||||
|
@ -121,7 +133,8 @@ class Poll(TelegramObject):
|
|||
|
||||
Args:
|
||||
id (:obj:`str`): Unique poll identifier.
|
||||
question (:obj:`str`): Poll question, 1-300 characters.
|
||||
question (:obj:`str`): Poll question, :tg-const:`telegram.Poll.MIN_QUESTION_LENGTH`-
|
||||
:tg-const:`telegram.Poll.MAX_QUESTION_LENGTH` characters.
|
||||
options (List[:class:`PollOption`]): List of poll options.
|
||||
is_closed (:obj:`bool`): :obj:`True`, if the poll is closed.
|
||||
is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous.
|
||||
|
@ -131,7 +144,8 @@ class Poll(TelegramObject):
|
|||
option. Available only for closed polls in the quiz mode, which were sent
|
||||
(not forwarded), by the bot or to a private chat with the bot.
|
||||
explanation (:obj:`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 characters.
|
||||
answer or taps on the lamp icon in a quiz-style poll,
|
||||
0-:tg-const:`telegram.Poll.MAX_EXPLANATION_LENGTH` characters.
|
||||
explanation_entities (List[:class:`telegram.MessageEntity`], optional): Special entities
|
||||
like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`.
|
||||
This list is empty if the message does not contain explanation entities.
|
||||
|
@ -145,7 +159,8 @@ class Poll(TelegramObject):
|
|||
|
||||
Attributes:
|
||||
id (:obj:`str`): Unique poll identifier.
|
||||
question (:obj:`str`): Poll question, 1-300 characters.
|
||||
question (:obj:`str`): Poll question, :tg-const:`telegram.Poll.MIN_QUESTION_LENGTH`-
|
||||
:tg-const:`telegram.Poll.MAX_QUESTION_LENGTH` characters.
|
||||
options (List[:class:`PollOption`]): List of poll options.
|
||||
total_voter_count (:obj:`int`): Total number of users that voted in the poll.
|
||||
is_closed (:obj:`bool`): :obj:`True`, if the poll is closed.
|
||||
|
@ -156,7 +171,8 @@ class Poll(TelegramObject):
|
|||
option. Available only for closed polls in the quiz mode, which were sent
|
||||
(not forwarded), by the bot or to a private chat with the bot.
|
||||
explanation (:obj:`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 characters.
|
||||
answer or taps on the lamp icon in a quiz-style poll,
|
||||
0-:tg-const:`telegram.Poll.MAX_EXPLANATION_LENGTH` characters.
|
||||
explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities
|
||||
like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`.
|
||||
This list is empty if the message does not contain explanation entities.
|
||||
|
@ -299,12 +315,53 @@ class Poll(TelegramObject):
|
|||
""":const:`telegram.constants.PollType.REGULAR`"""
|
||||
QUIZ: ClassVar[str] = constants.PollType.QUIZ
|
||||
""":const:`telegram.constants.PollType.QUIZ`"""
|
||||
MAX_QUESTION_LENGTH: ClassVar[int] = constants.PollLimit.QUESTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.QUESTION_LENGTH`"""
|
||||
MAX_OPTION_LENGTH: ClassVar[int] = constants.PollLimit.OPTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.OPTION_LENGTH`"""
|
||||
MAX_OPTION_NUMBER: ClassVar[int] = constants.PollLimit.OPTION_NUMBER
|
||||
""":const:`telegram.constants.PollLimit.OPTION_NUMBER`
|
||||
MAX_EXPLANATION_LENGTH: ClassVar[int] = constants.PollLimit.MAX_EXPLANATION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.MAX_EXPLANATION_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_EXPLANATION_LINE_FEEDS: ClassVar[int] = constants.PollLimit.MAX_EXPLANATION_LINE_FEEDS
|
||||
""":const:`telegram.constants.PollLimit.MAX_EXPLANATION_LINE_FEEDS`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_OPEN_PERIOD: ClassVar[int] = constants.PollLimit.MIN_OPEN_PERIOD
|
||||
""":const:`telegram.constants.PollLimit.MIN_OPEN_PERIOD`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_OPEN_PERIOD: ClassVar[int] = constants.PollLimit.MAX_OPEN_PERIOD
|
||||
""":const:`telegram.constants.PollLimit.MAX_OPEN_PERIOD`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_QUESTION_LENGTH: ClassVar[int] = constants.PollLimit.MIN_QUESTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.MIN_QUESTION_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_QUESTION_LENGTH: ClassVar[int] = constants.PollLimit.MAX_QUESTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.MAX_QUESTION_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_OPTION_LENGTH: ClassVar[int] = constants.PollLimit.MIN_OPTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.MIN_OPTION_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_OPTION_LENGTH: ClassVar[int] = constants.PollLimit.MAX_OPTION_LENGTH
|
||||
""":const:`telegram.constants.PollLimit.MAX_OPTION_LENGTH`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MIN_OPTION_NUMBER: ClassVar[int] = constants.PollLimit.MIN_OPTION_NUMBER
|
||||
""":const:`telegram.constants.PollLimit.MIN_OPTION_NUMBER`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_OPTION_NUMBER: ClassVar[int] = constants.PollLimit.MAX_OPTION_NUMBER
|
||||
""":const:`telegram.constants.PollLimit.MAX_OPTION_NUMBER`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains an object that represents a Telegram ReplyKeyboardMarkup."""
|
||||
|
||||
from typing import List, Sequence, Union
|
||||
from typing import ClassVar, List, Sequence, Union
|
||||
|
||||
from telegram import constants
|
||||
from telegram._keyboardbutton import KeyboardButton
|
||||
from telegram._telegramobject import TelegramObject
|
||||
from telegram._utils.markup import check_keyboard_type
|
||||
|
@ -61,7 +62,10 @@ class ReplyKeyboardMarkup(TelegramObject):
|
|||
Defaults to :obj:`False`.
|
||||
|
||||
input_field_placeholder (:obj:`str`, optional): The placeholder to be shown in the input
|
||||
field when the keyboard is active; 1-64 characters.
|
||||
field when the keyboard is active;
|
||||
:tg-const:`telegram.ReplyKeyboardMarkup.MIN_INPUT_FIELD_PLACEHOLDER`-
|
||||
:tg-const:`telegram.ReplyKeyboardMarkup.MAX_INPUT_FIELD_PLACEHOLDER`
|
||||
characters.
|
||||
|
||||
.. versionadded:: 13.7
|
||||
|
||||
|
@ -287,3 +291,14 @@ class ReplyKeyboardMarkup(TelegramObject):
|
|||
self.selective,
|
||||
)
|
||||
)
|
||||
|
||||
MIN_INPUT_FIELD_PLACEHOLDER: ClassVar[int] = constants.ReplyLimit.MIN_INPUT_FIELD_PLACEHOLDER
|
||||
""":const:`telegram.constants.ReplyLimit.MIN_INPUT_FIELD_PLACEHOLDER`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
MAX_INPUT_FIELD_PLACEHOLDER: ClassVar[int] = constants.ReplyLimit.MAX_INPUT_FIELD_PLACEHOLDER
|
||||
""":const:`telegram.constants.ReplyLimit.MAX_INPUT_FIELD_PLACEHOLDER`
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
|
|
@ -34,22 +34,29 @@ those classes.
|
|||
__all__ = [
|
||||
"BOT_API_VERSION",
|
||||
"BOT_API_VERSION_INFO",
|
||||
"BotCommandLimit",
|
||||
"BotCommandScopeType",
|
||||
"CallbackQueryLimit",
|
||||
"ChatAction",
|
||||
"ChatDescriptionLimit",
|
||||
"ChatID",
|
||||
"ChatInviteLinkLimit",
|
||||
"ChatLimit",
|
||||
"ChatMemberStatus",
|
||||
"ChatPhotoSize",
|
||||
"ChatType",
|
||||
"ContactLimit",
|
||||
"CustomEmojiStickerLimit",
|
||||
"DiceEmoji",
|
||||
"DiceLimit",
|
||||
"FileSizeLimit",
|
||||
"FloodLimit",
|
||||
"ForumIconColor",
|
||||
"ForumTopicLimit",
|
||||
"InlineKeyboardButtonLimit",
|
||||
"InlineKeyboardMarkupLimit",
|
||||
"InlineQueryLimit",
|
||||
"InlineQueryResultLimit",
|
||||
"InlineQueryResultType",
|
||||
"InputMediaType",
|
||||
"InvoiceLimit",
|
||||
|
@ -60,13 +67,17 @@ __all__ = [
|
|||
"MessageEntityType",
|
||||
"MessageLimit",
|
||||
"MessageType",
|
||||
"PollingLimit",
|
||||
"ParseMode",
|
||||
"PollLimit",
|
||||
"PollType",
|
||||
"ReplyLimit",
|
||||
"SUPPORTED_WEBHOOK_PORTS",
|
||||
"StickerLimit",
|
||||
"StickerType",
|
||||
"WebhookLimit",
|
||||
"UpdateType",
|
||||
"UserProfilePhotosLimit",
|
||||
]
|
||||
|
||||
import sys
|
||||
|
@ -115,6 +126,39 @@ BOT_API_VERSION = str(BOT_API_VERSION_INFO)
|
|||
SUPPORTED_WEBHOOK_PORTS: List[int] = [443, 80, 88, 8443]
|
||||
|
||||
|
||||
class BotCommandLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.BotCommand` and
|
||||
:meth:`telegram.Bot.set_my_commands`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_COMMAND = 1
|
||||
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.BotCommand.command` parameter of
|
||||
:class:`telegram.BotCommand`.
|
||||
"""
|
||||
MAX_COMMAND = 32
|
||||
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.BotCommand.command` parameter of
|
||||
:class:`telegram.BotCommand`.
|
||||
"""
|
||||
MIN_DESCRIPTION = 1
|
||||
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.BotCommand.description`
|
||||
parameter of :class:`telegram.BotCommand`.
|
||||
"""
|
||||
MAX_DESCRIPTION = 256
|
||||
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.BotCommand.description`
|
||||
parameter of :class:`telegram.BotCommand`.
|
||||
"""
|
||||
MAX_COMMAND_NUMBER = 100
|
||||
""":obj:`int`: Maximum number of bot commands passed in a :obj:`list` to the
|
||||
:paramref:`~telegram.Bot.set_my_commands.commands`
|
||||
parameter of :meth:`telegram.Bot.set_my_commands`.
|
||||
"""
|
||||
|
||||
|
||||
class BotCommandScopeType(StringEnum):
|
||||
"""This enum contains the available types of :class:`telegram.BotCommandScope`. The enum
|
||||
members of this enumeration are instances of :class:`str` and can be treated as such.
|
||||
|
@ -151,7 +195,8 @@ class CallbackQueryLimit(IntEnum):
|
|||
__slots__ = ()
|
||||
|
||||
ANSWER_CALLBACK_QUERY_TEXT_LENGTH = 200
|
||||
""":obj:`int`: Maximum number of characters for the ``text`` parameter of
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.answer_callback_query.text` parameter of
|
||||
:meth:`telegram.Bot.answer_callback_query`."""
|
||||
|
||||
|
||||
|
@ -188,6 +233,22 @@ class ChatAction(StringEnum):
|
|||
""":obj:`str`: Chat action indicating that the bot is uploading a video note."""
|
||||
|
||||
|
||||
class ChatDescriptionLimit(IntEnum):
|
||||
"""This enum contains limitations for :meth:`telegram.Bot.set_chat_description`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
DESCRIPTION_LENGTH = 255
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.set_chat_description.description` parameter of
|
||||
:meth:`telegram.Bot.set_chat_description`.
|
||||
"""
|
||||
|
||||
|
||||
class ChatID(IntEnum):
|
||||
"""This enum contains some special chat IDs. The enum
|
||||
members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
@ -232,12 +293,27 @@ class ChatInviteLinkLimit(IntEnum):
|
|||
|
||||
__slots__ = ()
|
||||
|
||||
MEMBER_LIMIT = 99999
|
||||
""":obj:`int`: Maximum value allowed for the ``member_limit`` parameter of
|
||||
:meth:`telegram.Bot.create_chat_invite_link` and :meth:`telegram.Bot.edit_chat_invite_link`."""
|
||||
MIN_MEMBER_LIMIT = 1
|
||||
""":obj:`int`: Minimum value allowed for the
|
||||
:paramref:`~telegram.Bot.create_chat_invite_link.member_limit` parameter of
|
||||
:meth:`telegram.Bot.create_chat_invite_link` and
|
||||
:paramref:`~telegram.Bot.edit_chat_invite_link.member_limit` of
|
||||
:meth:`telegram.Bot.edit_chat_invite_link`.
|
||||
"""
|
||||
MAX_MEMBER_LIMIT = 99999
|
||||
""":obj:`int`: Maximum value allowed for the
|
||||
:paramref:`~telegram.Bot.create_chat_invite_link.member_limit` parameter of
|
||||
:meth:`telegram.Bot.create_chat_invite_link` and
|
||||
:paramref:`~telegram.Bot.edit_chat_invite_link.member_limit` of
|
||||
:meth:`telegram.Bot.edit_chat_invite_link`.
|
||||
"""
|
||||
NAME_LENGTH = 32
|
||||
""":obj:`int`: Maximum number of characters allowed for the ``name`` parameter of
|
||||
:meth:`telegram.Bot.create_chat_invite_link` and :meth:`telegram.Bot.edit_chat_invite_link`."""
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.create_chat_invite_link.name` parameter of
|
||||
:meth:`telegram.Bot.create_chat_invite_link` and
|
||||
:paramref:`~telegram.Bot.edit_chat_invite_link.name` of
|
||||
:meth:`telegram.Bot.edit_chat_invite_link`.
|
||||
"""
|
||||
|
||||
|
||||
class ChatLimit(IntEnum):
|
||||
|
@ -291,6 +367,29 @@ class ChatMemberStatus(StringEnum):
|
|||
""":obj:`str`: A :class:`telegram.ChatMember` who was restricted in this chat."""
|
||||
|
||||
|
||||
class ChatPhotoSize(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.ChatPhoto`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
SMALL = 160
|
||||
""":obj:`int`: Width and height of a small chat photo, ID of which is passed in
|
||||
:paramref:`~telegram.ChatPhoto.small_file_id` and
|
||||
:paramref:`~telegram.ChatPhoto.small_file_unique_id` parameters of
|
||||
:class:`telegram.ChatPhoto`.
|
||||
"""
|
||||
BIG = 640
|
||||
""":obj:`int`: Width and height of a big chat photo, ID of which is passed in
|
||||
:paramref:`~telegram.ChatPhoto.big_file_id` and
|
||||
:paramref:`~telegram.ChatPhoto.big_file_unique_id` parameters of
|
||||
:class:`telegram.ChatPhoto`.
|
||||
"""
|
||||
|
||||
|
||||
class ChatType(StringEnum):
|
||||
"""This enum contains the available types of :class:`telegram.Chat`. The enum
|
||||
members of this enumeration are instances of :class:`str` and can be treated as such.
|
||||
|
@ -313,6 +412,27 @@ class ChatType(StringEnum):
|
|||
""":obj:`str`: A :class:`telegram.Chat` that is a channel."""
|
||||
|
||||
|
||||
class ContactLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.InlineQueryResultContact`,
|
||||
:class:`telegram.InputContactMessageContent`, and :meth:`telegram.Bot.send_contact`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
VCARD = 2048
|
||||
""":obj:`int`: Maximum value allowed for:
|
||||
|
||||
* :paramref:`~telegram.Bot.send_contact.vcard` parameter of :meth:`~telegram.Bot.send_contact`
|
||||
* :paramref:`~telegram.InlineQueryResultContact.vcard` parameter of
|
||||
:class:`~telegram.InlineQueryResultContact`
|
||||
* :paramref:`~telegram.InputContactMessageContent.vcard` parameter of
|
||||
:class:`~telegram.InputContactMessageContent`
|
||||
"""
|
||||
|
||||
|
||||
class CustomEmojiStickerLimit(IntEnum):
|
||||
"""This enum contains limitations for :meth:`telegram.Bot.get_custom_emoji_stickers`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
@ -353,6 +473,52 @@ class DiceEmoji(StringEnum):
|
|||
""":obj:`str`: A :class:`telegram.Dice` with the emoji ``🎳``."""
|
||||
|
||||
|
||||
class DiceLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.Dice`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_VALUE = 1
|
||||
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.Dice.value` parameter of
|
||||
:class:`telegram.Dice` (any emoji).
|
||||
"""
|
||||
|
||||
MAX_VALUE_BASKETBALL = 5
|
||||
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
|
||||
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
|
||||
:tg-const:`telegram.constants.DiceEmoji.BASKETBALL`.
|
||||
"""
|
||||
MAX_VALUE_BOWLING = 6
|
||||
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
|
||||
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
|
||||
:tg-const:`telegram.constants.DiceEmoji.BOWLING`.
|
||||
"""
|
||||
MAX_VALUE_DARTS = 6
|
||||
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
|
||||
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
|
||||
:tg-const:`telegram.constants.DiceEmoji.DARTS`.
|
||||
"""
|
||||
MAX_VALUE_DICE = 6
|
||||
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
|
||||
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
|
||||
:tg-const:`telegram.constants.DiceEmoji.DICE`.
|
||||
"""
|
||||
MAX_VALUE_FOOTBALL = 5
|
||||
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
|
||||
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
|
||||
:tg-const:`telegram.constants.DiceEmoji.FOOTBALL`.
|
||||
"""
|
||||
MAX_VALUE_SLOT_MACHINE = 64
|
||||
""":obj:`int`: Maximum value allowed for :paramref:`~telegram.Dice.value` parameter of
|
||||
:class:`telegram.Dice` if :paramref:`~telegram.Dice.emoji` is
|
||||
:tg-const:`telegram.constants.DiceEmoji.SLOT_MACHINE`.
|
||||
"""
|
||||
|
||||
|
||||
class FileSizeLimit(IntEnum):
|
||||
"""This enum contains limitations regarding the upload and download of files. The enum
|
||||
members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
@ -375,6 +541,11 @@ class FileSizeLimit(IntEnum):
|
|||
"""
|
||||
PHOTOSIZE_UPLOAD = int(10e6) # (10MB)
|
||||
""":obj:`int`: Bots can upload photo files of up to 10MB in size."""
|
||||
VOICE_NOTE_FILE_SIZE = int(1e6) # (1MB)
|
||||
""":obj:`int`: File size limit for the :meth:`~telegram.Bot.send_voice` method of
|
||||
:class:`telegram.Bot`. Bots can send :mimetype:`audio/ogg` files of up to 1MB in size as
|
||||
a voice note. Larger voice notes (up to 20MB) will be sent as files."""
|
||||
# It seems OK to link 20MB limit to FILESIZE_DOWNLOAD rather than creating a new constant
|
||||
|
||||
|
||||
class FloodLimit(IntEnum):
|
||||
|
@ -461,6 +632,27 @@ class ForumIconColor(IntEnum):
|
|||
"""
|
||||
|
||||
|
||||
class InlineKeyboardButtonLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.InlineKeyboardButton`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_CALLBACK_DATA = 1
|
||||
""":obj:`int`: Minimum value allowed for
|
||||
:paramref:`~telegram.InlineKeyboardButton.callback_data` parameter of
|
||||
:class:`telegram.InlineKeyboardButton`
|
||||
"""
|
||||
MAX_CALLBACK_DATA = 64
|
||||
""":obj:`int`: Maximum value allowed for
|
||||
:paramref:`~telegram.InlineKeyboardButton.callback_data` parameter of
|
||||
:class:`telegram.InlineKeyboardButton`
|
||||
"""
|
||||
|
||||
|
||||
class InlineKeyboardMarkupLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.InlineKeyboardMarkup`/
|
||||
:meth:`telegram.Bot.send_message` & friends. The enum
|
||||
|
@ -519,9 +711,42 @@ class InlineQueryLimit(IntEnum):
|
|||
RESULTS = 50
|
||||
""":obj:`int`: Maximum number of results that can be passed to
|
||||
:meth:`telegram.Bot.answer_inline_query`."""
|
||||
SWITCH_PM_TEXT_LENGTH = 64
|
||||
""":obj:`int`: Maximum number of characters for the ``switch_pm_text`` parameter of
|
||||
MAX_OFFSET_LENGTH = 64
|
||||
""":obj:`int`: Maximum number of bytes in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.answer_inline_query.next_offset` parameter of
|
||||
:meth:`telegram.Bot.answer_inline_query`."""
|
||||
MAX_QUERY_LENGTH = 256
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.InlineQuery.query` parameter of :class:`telegram.InlineQuery`."""
|
||||
MIN_SWITCH_PM_TEXT_LENGTH = 1
|
||||
""":obj:`int`: Minimum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.answer_inline_query.switch_pm_parameter` parameter of
|
||||
:meth:`telegram.Bot.answer_inline_query`."""
|
||||
MAX_SWITCH_PM_TEXT_LENGTH = 64
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.answer_inline_query.switch_pm_parameter` parameter of
|
||||
:meth:`telegram.Bot.answer_inline_query`."""
|
||||
|
||||
|
||||
class InlineQueryResultLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.InlineQueryResult` and its subclasses.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_ID_LENGTH = 1
|
||||
""":obj:`int`: Minimum number of bytes in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.InlineQueryResult.id` parameter of
|
||||
:class:`telegram.InlineQueryResult` and its subclasses
|
||||
"""
|
||||
MAX_ID_LENGTH = 64
|
||||
""":obj:`int`: Maximum number of bytes in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.InlineQueryResult.id` parameter of
|
||||
:class:`telegram.InlineQueryResult` and its subclasses
|
||||
"""
|
||||
|
||||
|
||||
class InlineQueryResultType(StringEnum):
|
||||
|
@ -576,25 +801,114 @@ class InlineQueryResultType(StringEnum):
|
|||
|
||||
|
||||
class LocationLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.Location`/
|
||||
:meth:`telegram.Bot.send_location`. The enum members of this enumeration are instances
|
||||
of :class:`int` and can be treated as such.
|
||||
"""This enum contains limitations for
|
||||
:class:`telegram.Location`/:class:`telegram.ChatLocation`/
|
||||
:meth:`telegram.Bot.edit_message_live_location`/:meth:`telegram.Bot.send_location`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
HORIZONTAL_ACCURACY = 1500
|
||||
""":obj:`int`: Maximum radius of uncertainty for the location, measured in meters."""
|
||||
|
||||
HEADING = 360
|
||||
""":obj:`int`: Maximum value allowed for the direction in which the user is moving,
|
||||
in degrees.
|
||||
MIN_CHAT_LOCATION_ADDRESS = 1
|
||||
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.ChatLocation.address` parameter
|
||||
of :class:`telegram.ChatLocation`
|
||||
"""
|
||||
PROXIMITY_ALERT_RADIUS = 100000
|
||||
""":obj:`int`: Maximum distance for proximity alerts about approaching another chat member, in
|
||||
meters.
|
||||
MAX_CHAT_LOCATION_ADDRESS = 64
|
||||
""":obj:`int`: Minimum value allowed for :paramref:`~telegram.ChatLocation.address` parameter
|
||||
of :class:`telegram.ChatLocation`
|
||||
"""
|
||||
|
||||
HORIZONTAL_ACCURACY = 1500
|
||||
""":obj:`int`: Maximum value allowed for:
|
||||
|
||||
* :paramref:`~telegram.Location.horizontal_accuracy` parameter of :class:`telegram.Location`
|
||||
* :paramref:`~telegram.InlineQueryResultLocation.horizontal_accuracy` parameter of
|
||||
:class:`telegram.InlineQueryResultLocation`
|
||||
* :paramref:`~telegram.InputLocationMessageContent.horizontal_accuracy` parameter of
|
||||
:class:`telegram.InputLocationMessageContent`
|
||||
* :paramref:`~telegram.Bot.edit_message_live_location.horizontal_accuracy` parameter of
|
||||
:meth:`telegram.Bot.edit_message_live_location`
|
||||
* :paramref:`~telegram.Bot.send_location.horizontal_accuracy` parameter of
|
||||
:meth:`telegram.Bot.send_location`
|
||||
"""
|
||||
|
||||
MIN_HEADING = 1
|
||||
""":obj:`int`: Minimum value allowed for:
|
||||
|
||||
* :paramref:`~telegram.Location.heading` parameter of :class:`telegram.Location`
|
||||
* :paramref:`~telegram.InlineQueryResultLocation.heading` parameter of
|
||||
:class:`telegram.InlineQueryResultLocation`
|
||||
* :paramref:`~telegram.InputLocationMessageContent.heading` parameter of
|
||||
:class:`telegram.InputLocationMessageContent`
|
||||
* :paramref:`~telegram.Bot.edit_message_live_location.heading` parameter of
|
||||
:meth:`telegram.Bot.edit_message_live_location`
|
||||
* :paramref:`~telegram.Bot.send_location.heading` parameter of
|
||||
:meth:`telegram.Bot.send_location`
|
||||
"""
|
||||
MAX_HEADING = 360
|
||||
""":obj:`int`: Maximum value allowed for:
|
||||
|
||||
* :paramref:`~telegram.Location.heading` parameter of :class:`telegram.Location`
|
||||
* :paramref:`~telegram.InlineQueryResultLocation.heading` parameter of
|
||||
:class:`telegram.InlineQueryResultLocation`
|
||||
* :paramref:`~telegram.InputLocationMessageContent.heading` parameter of
|
||||
:class:`telegram.InputLocationMessageContent`
|
||||
* :paramref:`~telegram.Bot.edit_message_live_location.heading` parameter of
|
||||
:meth:`telegram.Bot.edit_message_live_location`
|
||||
* :paramref:`~telegram.Bot.send_location.heading` parameter of
|
||||
:meth:`telegram.Bot.send_location`
|
||||
"""
|
||||
|
||||
MIN_LIVE_PERIOD = 60
|
||||
""":obj:`int`: Minimum value allowed for:
|
||||
|
||||
* :paramref:`~telegram.InlineQueryResultLocation.live_period` parameter of
|
||||
:class:`telegram.InlineQueryResultLocation`
|
||||
* :paramref:`~telegram.InputLocationMessageContent.live_period` parameter of
|
||||
:class:`telegram.InputLocationMessageContent`
|
||||
* :paramref:`~telegram.Bot.edit_message_live_location.live_period` parameter of
|
||||
:meth:`telegram.Bot.edit_message_live_location`
|
||||
* :paramref:`~telegram.Bot.send_location.live_period` parameter of
|
||||
:meth:`telegram.Bot.send_location`
|
||||
"""
|
||||
MAX_LIVE_PERIOD = 86400
|
||||
""":obj:`int`: Maximum value allowed for:
|
||||
|
||||
* :paramref:`~telegram.InlineQueryResultLocation.live_period` parameter of
|
||||
:class:`telegram.InlineQueryResultLocation`
|
||||
* :paramref:`~telegram.InputLocationMessageContent.live_period` parameter of
|
||||
:class:`telegram.InputLocationMessageContent`
|
||||
* :paramref:`~telegram.Bot.edit_message_live_location.live_period` parameter of
|
||||
:meth:`telegram.Bot.edit_message_live_location`
|
||||
* :paramref:`~telegram.Bot.send_location.live_period` parameter of
|
||||
:meth:`telegram.Bot.send_location`
|
||||
"""
|
||||
|
||||
MIN_PROXIMITY_ALERT_RADIUS = 1
|
||||
""":obj:`int`: Minimum value allowed for:
|
||||
|
||||
* :paramref:`~telegram.InlineQueryResultLocation.proximity_alert_radius` parameter of
|
||||
:class:`telegram.InlineQueryResultLocation`
|
||||
* :paramref:`~telegram.InputLocationMessageContent.proximity_alert_radius` parameter of
|
||||
:class:`telegram.InputLocationMessageContent`
|
||||
* :paramref:`~telegram.Bot.edit_message_live_location.proximity_alert_radius` parameter of
|
||||
:meth:`telegram.Bot.edit_message_live_location`
|
||||
* :paramref:`~telegram.Bot.send_location.proximity_alert_radius` parameter of
|
||||
:meth:`telegram.Bot.send_location`
|
||||
"""
|
||||
MAX_PROXIMITY_ALERT_RADIUS = 100000
|
||||
""":obj:`int`: Maximum value allowed for:
|
||||
|
||||
* :paramref:`~telegram.InlineQueryResultLocation.proximity_alert_radius` parameter of
|
||||
:class:`telegram.InlineQueryResultLocation`
|
||||
* :paramref:`~telegram.InputLocationMessageContent.proximity_alert_radius` parameter of
|
||||
:class:`telegram.InputLocationMessageContent`
|
||||
* :paramref:`~telegram.Bot.edit_message_live_location.proximity_alert_radius` parameter of
|
||||
:meth:`telegram.Bot.edit_message_live_location`
|
||||
* :paramref:`~telegram.Bot.send_location.proximity_alert_radius` parameter of
|
||||
:meth:`telegram.Bot.send_location`
|
||||
"""
|
||||
|
||||
|
||||
|
@ -733,6 +1047,7 @@ class MessageEntityType(StringEnum):
|
|||
|
||||
class MessageLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.Message`/
|
||||
:class:`telegram.InputTextMessageContent`/
|
||||
:meth:`telegram.Bot.send_message` & friends. The enum
|
||||
members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
|
@ -741,13 +1056,42 @@ class MessageLimit(IntEnum):
|
|||
|
||||
__slots__ = ()
|
||||
|
||||
TEXT_LENGTH = 4096
|
||||
""":obj:`int`: Maximum number of characters for a text message."""
|
||||
# TODO add links to params?
|
||||
MAX_TEXT_LENGTH = 4096
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as:
|
||||
|
||||
* :paramref:`~telegram.Game.text` parameter of :class:`telegram.Game`
|
||||
* :paramref:`~telegram.Message.text` parameter of :class:`telegram.Message`
|
||||
* :paramref:`~telegram.InputTextMessageContent.message_text` parameter of
|
||||
:class:`telegram.InputTextMessageContent`
|
||||
* :paramref:`~telegram.Bot.send_message.text` parameter of :meth:`telegram.Bot.send_message`
|
||||
* :paramref:`~telegram.Bot.edit_message_text.text` parameter of
|
||||
:meth:`telegram.Bot.edit_message_text`
|
||||
"""
|
||||
CAPTION_LENGTH = 1024
|
||||
""":obj:`int`: Maximum number of characters for a message caption."""
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as:
|
||||
|
||||
* :paramref:`~telegram.Message.caption` parameter of :class:`telegram.Message`
|
||||
* :paramref:`~telegram.InputMedia.caption` parameter of :class:`telegram.InputMedia`
|
||||
and its subclasses
|
||||
* ``caption`` parameter of subclasses of :class:`telegram.InlineQueryResult`
|
||||
* ``caption`` parameter of :meth:`telegram.Bot.send_photo`, :meth:`telegram.Bot.send_audio`,
|
||||
:meth:`telegram.Bot.send_document`, :meth:`telegram.Bot.send_video`,
|
||||
:meth:`telegram.Bot.send_animation`, :meth:`telegram.Bot.send_voice`,
|
||||
:meth:`telegram.Bot.edit_message_caption`, :meth:`telegram.Bot.copy_message`
|
||||
"""
|
||||
# constants above this line are tested
|
||||
MIN_TEXT_LENGTH = 1
|
||||
""":obj:`int`: Minimum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.InputTextMessageContent.message_text` parameter of
|
||||
:class:`telegram.InputTextMessageContent` and the
|
||||
:paramref:`~telegram.Bot.edit_message_text.text` parameter of
|
||||
:meth:`telegram.Bot.edit_message_text`.
|
||||
"""
|
||||
# TODO this constant is not used. helpers.py contains 64 as a number
|
||||
DEEP_LINK_LENGTH = 64
|
||||
""":obj:`int`: Maximum number of characters for a deep link."""
|
||||
# TODO this constant is not used anywhere
|
||||
MESSAGE_ENTITIES = 100
|
||||
""":obj:`int`: Maximum number of entities that can be displayed in a message. Further entities
|
||||
will simply be ignored by Telegram.
|
||||
|
@ -844,6 +1188,74 @@ class MessageType(StringEnum):
|
|||
""":obj:`str`: Messages with :attr:`telegram.Message.video_chat_participants_invited`."""
|
||||
|
||||
|
||||
class PollingLimit(IntEnum):
|
||||
"""This enum contains limitations for :paramref:`telegram.Bot.get_updates.limit`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_LIMIT = 1
|
||||
""":obj:`int`: Minimum value allowed for the :paramref:`~telegram.Bot.get_updates.limit`
|
||||
parameter of :meth:`telegram.Bot.get_updates`.
|
||||
"""
|
||||
MAX_LIMIT = 100
|
||||
""":obj:`int`: Maximum value allowed for the :paramref:`~telegram.Bot.get_updates.limit`
|
||||
parameter of :meth:`telegram.Bot.get_updates`.
|
||||
"""
|
||||
|
||||
|
||||
class ReplyLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.ForceReply`
|
||||
and :class:`telegram.ReplyKeyboardMarkup`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_INPUT_FIELD_PLACEHOLDER = 1
|
||||
""":obj:`int`: Minimum value allowed for
|
||||
:paramref:`~telegram.ForceReply.input_field_placeholder` parameter of
|
||||
:class:`telegram.ForceReply` and
|
||||
:paramref:`~telegram.ReplyKeyboardMarkup.input_field_placeholder` parameter of
|
||||
:class:`telegram.ReplyKeyboardMarkup`
|
||||
"""
|
||||
MAX_INPUT_FIELD_PLACEHOLDER = 64
|
||||
""":obj:`int`: Maximum value allowed for
|
||||
:paramref:`~telegram.ForceReply.input_field_placeholder` parameter of
|
||||
:class:`telegram.ForceReply` and
|
||||
:paramref:`~telegram.ReplyKeyboardMarkup.input_field_placeholder` parameter of
|
||||
:class:`telegram.ReplyKeyboardMarkup`
|
||||
"""
|
||||
|
||||
|
||||
class StickerLimit(IntEnum):
|
||||
"""This enum contains limitations for :meth:`telegram.Bot.create_new_sticker_set`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_NAME_AND_TITLE = 1
|
||||
""":obj:`int`: Minimum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.create_new_sticker_set.name` parameter or the
|
||||
:paramref:`~telegram.Bot.create_new_sticker_set.title` parameter of
|
||||
:meth:`telegram.Bot.create_new_sticker_set`.
|
||||
"""
|
||||
MAX_NAME_AND_TITLE = 64
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.create_new_sticker_set.name` parameter or the
|
||||
:paramref:`~telegram.Bot.create_new_sticker_set.title` parameter of
|
||||
:meth:`telegram.Bot.create_new_sticker_set`.
|
||||
"""
|
||||
|
||||
|
||||
class StickerType(StringEnum):
|
||||
"""This enum contains the available types of :class:`telegram.Sticker`. The enum
|
||||
members of this enumeration are instances of :class:`str` and can be treated as such.
|
||||
|
@ -884,7 +1296,7 @@ class ParseMode(StringEnum):
|
|||
|
||||
|
||||
class PollLimit(IntEnum):
|
||||
"""This enum contains limitations for :class:`telegram.Poll`/
|
||||
"""This enum contains limitations for :class:`telegram.Poll`/:class:`telegram.PollOption`/
|
||||
:meth:`telegram.Bot.send_poll`. The enum
|
||||
members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
|
@ -893,12 +1305,58 @@ class PollLimit(IntEnum):
|
|||
|
||||
__slots__ = ()
|
||||
|
||||
QUESTION_LENGTH = 300
|
||||
""":obj:`str`: Maximum number of characters of the polls question."""
|
||||
OPTION_LENGTH = 100
|
||||
""":obj:`str`: Maximum number of characters for each option for the poll."""
|
||||
OPTION_NUMBER = 10
|
||||
""":obj:`str`: Maximum number of available options for the poll."""
|
||||
MIN_QUESTION_LENGTH = 1
|
||||
""":obj:`int`: Minimum value allowed for the :paramref:`~telegram.Poll.question`
|
||||
parameter of :class:`telegram.Poll` and the :paramref:`~telegram.Bot.send_poll.question`
|
||||
parameter of :meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
MAX_QUESTION_LENGTH = 300
|
||||
""":obj:`int`: Maximum value allowed for the :paramref:`~telegram.Poll.question`
|
||||
parameter of :class:`telegram.Poll` and the :paramref:`~telegram.Bot.send_poll.question`
|
||||
parameter of :meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
MIN_OPTION_LENGTH = 1
|
||||
""":obj:`int`: Minimum length of each :obj:`str` passed in a :obj:`list`
|
||||
to the :paramref:`~telegram.Bot.send_poll.options` parameter of
|
||||
:meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
MAX_OPTION_LENGTH = 100
|
||||
""":obj:`int`: Maximum length of each :obj:`str` passed in a :obj:`list`
|
||||
to the :paramref:`~telegram.Bot.send_poll.options` parameter of
|
||||
:meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
MIN_OPTION_NUMBER = 2
|
||||
""":obj:`int`: Minimum number of strings passed in a :obj:`list`
|
||||
to the :paramref:`~telegram.Bot.send_poll.options` parameter of
|
||||
:meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
MAX_OPTION_NUMBER = 10
|
||||
""":obj:`int`: Maximum number of strings passed in a :obj:`list`
|
||||
to the :paramref:`~telegram.Bot.send_poll.options` parameter of
|
||||
:meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
MAX_EXPLANATION_LENGTH = 200
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Poll.explanation` parameter of :class:`telegram.Poll` and the
|
||||
:paramref:`~telegram.Bot.send_poll.explanation` parameter of :meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
MAX_EXPLANATION_LINE_FEEDS = 2
|
||||
""":obj:`int`: Maximum number of line feeds in a :obj:`str` passed as the
|
||||
:paramref:`~telegram.Bot.send_poll.explanation` parameter of :meth:`telegram.Bot.send_poll`
|
||||
after entities parsing.
|
||||
"""
|
||||
MIN_OPEN_PERIOD = 5
|
||||
""":obj:`int`: Minimum value allowed for the
|
||||
:paramref:`~telegram.Bot.send_poll.open_period` parameter of :meth:`telegram.Bot.send_poll`.
|
||||
Also used in the :paramref:`~telegram.Bot.send_poll.close_date` parameter of
|
||||
:meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
MAX_OPEN_PERIOD = 600
|
||||
""":obj:`int`: Maximum value allowed for the
|
||||
:paramref:`~telegram.Bot.send_poll.open_period` parameter of :meth:`telegram.Bot.send_poll`.
|
||||
Also used in the :paramref:`~telegram.Bot.send_poll.close_date` parameter of
|
||||
:meth:`telegram.Bot.send_poll`.
|
||||
"""
|
||||
|
||||
|
||||
class PollType(StringEnum):
|
||||
|
@ -966,32 +1424,118 @@ class InvoiceLimit(IntEnum):
|
|||
__slots__ = ()
|
||||
|
||||
MIN_TITLE_LENGTH = 1
|
||||
""":obj:`int`: Minimum number of characters of the invoice title."""
|
||||
""":obj:`int`: Minimum number of characters in a :obj:`str` passed as:
|
||||
|
||||
* :paramref:`~telegram.InputInvoiceMessageContent.title` parameter of
|
||||
:class:`telegram.InputInvoiceMessageContent`
|
||||
* :paramref:`~telegram.Bot.send_invoice.title` parameter of
|
||||
:meth:`telegram.Bot.send_invoice`.
|
||||
* :paramref:`~telegram.Bot.create_invoice_link.title` parameter of
|
||||
:meth:`telegram.Bot.create_invoice_link`.
|
||||
"""
|
||||
MAX_TITLE_LENGTH = 32
|
||||
""":obj:`int`: Maximum number of characters of the invoice title."""
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as:
|
||||
|
||||
* :paramref:`~telegram.InputInvoiceMessageContent.title` parameter of
|
||||
:class:`telegram.InputInvoiceMessageContent`
|
||||
* :paramref:`~telegram.Bot.send_invoice.title` parameter of
|
||||
:meth:`telegram.Bot.send_invoice`.
|
||||
* :paramref:`~telegram.Bot.create_invoice_link.title` parameter of
|
||||
:meth:`telegram.Bot.create_invoice_link`.
|
||||
"""
|
||||
MIN_DESCRIPTION_LENGTH = 1
|
||||
""":obj:`int`: Minimum number of characters of the invoice description."""
|
||||
""":obj:`int`: Minimum number of characters in a :obj:`str` passed as:
|
||||
|
||||
* :paramref:`~telegram.InputInvoiceMessageContent.description` parameter of
|
||||
:class:`telegram.InputInvoiceMessageContent`
|
||||
* :paramref:`~telegram.Bot.send_invoice.description` parameter of
|
||||
:meth:`telegram.Bot.send_invoice`.
|
||||
* :paramref:`~telegram.Bot.create_invoice_link.description` parameter of
|
||||
:meth:`telegram.Bot.create_invoice_link`.
|
||||
"""
|
||||
MAX_DESCRIPTION_LENGTH = 255
|
||||
""":obj:`int`: Maximum number of characters of the invoice description."""
|
||||
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as:
|
||||
|
||||
* :paramref:`~telegram.InputInvoiceMessageContent.description` parameter of
|
||||
:class:`telegram.InputInvoiceMessageContent`
|
||||
* :paramref:`~telegram.Bot.send_invoice.description` parameter of
|
||||
:meth:`telegram.Bot.send_invoice`.
|
||||
* :paramref:`~telegram.Bot.create_invoice_link.description` parameter of
|
||||
:meth:`telegram.Bot.create_invoice_link`.
|
||||
"""
|
||||
MIN_PAYLOAD_LENGTH = 1
|
||||
""":obj:`int`: Minimum amount of bytes for the internal payload."""
|
||||
""":obj:`int`: Minimum amount of bytes in a :obj:`str` passed as:
|
||||
|
||||
* :paramref:`~telegram.InputInvoiceMessageContent.payload` parameter of
|
||||
:class:`telegram.InputInvoiceMessageContent`
|
||||
* :paramref:`~telegram.Bot.send_invoice.payload` parameter of
|
||||
:meth:`telegram.Bot.send_invoice`.
|
||||
* :paramref:`~telegram.Bot.create_invoice_link.payload` parameter of
|
||||
:meth:`telegram.Bot.create_invoice_link`.
|
||||
"""
|
||||
MAX_PAYLOAD_LENGTH = 128
|
||||
""":obj:`int`: Maximum amount of bytes for the internal payload."""
|
||||
""":obj:`int`: Maximum amount of bytes in a :obj:`str` passed as:
|
||||
|
||||
* :paramref:`~telegram.InputInvoiceMessageContent.payload` parameter of
|
||||
:class:`telegram.InputInvoiceMessageContent`
|
||||
* :paramref:`~telegram.Bot.send_invoice.payload` parameter of
|
||||
:meth:`telegram.Bot.send_invoice`.
|
||||
* :paramref:`~telegram.Bot.create_invoice_link.payload` parameter of
|
||||
:meth:`telegram.Bot.create_invoice_link`.
|
||||
"""
|
||||
|
||||
|
||||
class WebhookLimit(IntEnum):
|
||||
"""This enum contains limitations for :paramref:`telegram.Bot.set_webhook.secret_token`. The
|
||||
enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
class UserProfilePhotosLimit(IntEnum):
|
||||
"""This enum contains limitations for :paramref:`telegram.Bot.get_user_profile_photos.limit`.
|
||||
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_LIMIT = 1
|
||||
""":obj:`int`: Minimum value allowed for
|
||||
:paramref:`~telegram.Bot.get_user_profile_photos.limit` parameter of
|
||||
:meth:`telegram.Bot.get_user_profile_photos`.
|
||||
"""
|
||||
MAX_LIMIT = 100
|
||||
""":obj:`int`: Maximum value allowed for
|
||||
:paramref:`~telegram.Bot.get_user_profile_photos.limit` parameter of
|
||||
:meth:`telegram.Bot.get_user_profile_photos`.
|
||||
"""
|
||||
|
||||
|
||||
class WebhookLimit(IntEnum):
|
||||
"""This enum contains limitations for :paramref:`telegram.Bot.set_webhook.max_connections` and
|
||||
:paramref:`telegram.Bot.set_webhook.secret_token`. The enum members of this enumeration are
|
||||
instances of :class:`int` and can be treated as such.
|
||||
|
||||
.. versionadded:: 20.0
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
MIN_CONNECTIONS_LIMIT = 1
|
||||
""":obj:`int`: Minimum value allowed for the
|
||||
:paramref:`~telegram.Bot.set_webhook.max_connections` parameter of
|
||||
:meth:`telegram.Bot.set_webhook`.
|
||||
"""
|
||||
MAX_CONNECTIONS_LIMIT = 100
|
||||
""":obj:`int`: Maximum value allowed for the
|
||||
:paramref:`~telegram.Bot.set_webhook.max_connections` parameter of
|
||||
:meth:`telegram.Bot.set_webhook`.
|
||||
"""
|
||||
MIN_SECRET_TOKEN_LENGTH = 1
|
||||
""":obj:`int`: Minimum length of the secret token."""
|
||||
""":obj:`int`: Minimum length of the secret token for the
|
||||
:paramref:`~telegram.Bot.set_webhook.secret_token` parameter of
|
||||
:meth:`telegram.Bot.set_webhook`.
|
||||
"""
|
||||
MAX_SECRET_TOKEN_LENGTH = 256
|
||||
""":obj:`int`: Maximum length of the secret token."""
|
||||
""":obj:`int`: Maximum length of the secret token for the
|
||||
:paramref:`~telegram.Bot.set_webhook.secret_token` parameter of
|
||||
:meth:`telegram.Bot.set_webhook`.
|
||||
"""
|
||||
|
||||
|
||||
class ForumTopicLimit(IntEnum):
|
||||
|
|
|
@ -112,14 +112,14 @@ class TestConstants:
|
|||
|
||||
@pytest.mark.flaky(3, 1)
|
||||
async def test_max_message_length(self, bot, chat_id):
|
||||
await bot.send_message(chat_id=chat_id, text="a" * constants.MessageLimit.TEXT_LENGTH)
|
||||
await bot.send_message(chat_id=chat_id, text="a" * constants.MessageLimit.MAX_TEXT_LENGTH)
|
||||
|
||||
with pytest.raises(
|
||||
BadRequest,
|
||||
match="Message is too long",
|
||||
):
|
||||
await bot.send_message(
|
||||
chat_id=chat_id, text="a" * (constants.MessageLimit.TEXT_LENGTH + 1)
|
||||
chat_id=chat_id, text="a" * (constants.MessageLimit.MAX_TEXT_LENGTH + 1)
|
||||
)
|
||||
|
||||
@pytest.mark.flaky(3, 1)
|
||||
|
|
Loading…
Reference in a new issue