Add New Constants (#3444)

This commit is contained in:
Dmitry Kolomatskiy 2022-12-30 16:09:06 +03:00 committed by GitHub
parent 0a6725852f
commit d996e8f9c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 11 deletions

View file

@ -1848,9 +1848,11 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
media (List[:class:`telegram.InputMediaAudio`, :class:`telegram.InputMediaDocument`, \
:class:`telegram.InputMediaPhoto`, :class:`telegram.InputMediaVideo`]): An array
describing messages to be sent, must include 210 items.
media (List[:class:`telegram.InputMediaAudio`, :class:`telegram.InputMediaDocument`,\
:class:`telegram.InputMediaPhoto`, :class:`telegram.InputMediaVideo`]):
An array describing messages to be sent, must include
:tg-const:`telegram.constants.MediaGroupLimit.MIN_MEDIA_LENGTH`
:tg-const:`telegram.constants.MediaGroupLimit.MAX_MEDIA_LENGTH` items.
disable_notification (:obj:`bool`, optional): |disable_notification|
protect_content (:obj:`bool`, optional): |protect_content|
@ -4186,9 +4188,9 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
.. versionadded:: 13.5
suggested_tip_amounts (List[:obj:`int`], optional): An array of
suggested amounts of tips in the *smallest* units of the currency (integer, **not**
float/double). At most 4 suggested tip amounts can be specified. The suggested tip
amounts must be positive, passed in a strictly increased order and must not exceed
:paramref:`max_tip_amount`.
float/double). At most :tg-const:`telegram.Invoice.MAX_TIP_AMOUNTS` suggested tip
amounts can be specified. The suggested tip amounts must be positive, passed in a
strictly increased order and must not exceed :paramref:`max_tip_amount`.
.. versionadded:: 13.5
start_parameter (:obj:`str`, optional): Unique deep-linking parameter. If left empty,
@ -6711,9 +6713,9 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
majority of currencies). Defaults to ``0``.
suggested_tip_amounts (List[:obj:`int`], optional): An array of
suggested amounts of tips in the *smallest* units of the currency (integer, **not**
float/double). At most 4 suggested tip amounts can be specified. The suggested tip
amounts must be positive, passed in a strictly increased order and must not exceed
:paramref:`max_tip_amount`.
float/double). At most :tg-const:`telegram.Invoice.MAX_TIP_AMOUNTS` suggested tip
amounts can be specified. The suggested tip amounts must be positive, passed in a
strictly increased order and must not exceed :paramref:`max_tip_amount`.
provider_data (:obj:`str` | :obj:`object`, optional): Data about the
invoice, which will be shared with the payment provider. A detailed description of
required fields should be provided by the payment provider. When an object is

View file

@ -119,3 +119,8 @@ class Invoice(TelegramObject):
.. versionadded:: 20.0
"""
MAX_TIP_AMOUNTS: ClassVar[int] = constants.InvoiceLimit.MAX_TIP_AMOUNTS
""":const:`telegram.constants.InvoiceLimit.MAX_TIP_AMOUNTS`
.. versionadded:: 20.0
"""

View file

@ -61,6 +61,7 @@ __all__ = [
"InvoiceLimit",
"LocationLimit",
"MaskPosition",
"MediaGroupLimit",
"MenuButtonType",
"MessageAttachmentType",
"MessageEntityType",
@ -919,6 +920,27 @@ class MaskPosition(StringEnum):
""":obj:`str`: Mask position for a sticker on the chin."""
class MediaGroupLimit(IntEnum):
"""This enum contains limitations for :meth:`telegram.Bot.send_media_group`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
__slots__ = ()
MIN_MEDIA_LENGTH = 2
""":obj:`int`: Minimum length of a :obj:`list` passed as the
:paramref:`~telegram.Bot.send_media_group.media` parameter of
:meth:`telegram.Bot.send_media_group`.
"""
MAX_MEDIA_LENGTH = 10
""":obj:`int`: Maximum length of a :obj:`list` passed as the
:paramref:`~telegram.Bot.send_media_group.media` parameter of
:meth:`telegram.Bot.send_media_group`.
"""
class MenuButtonType(StringEnum):
"""This enum contains the available types of :class:`telegram.MenuButton`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
@ -1403,8 +1425,9 @@ class UpdateType(StringEnum):
class InvoiceLimit(IntEnum):
"""This enum contains limitations for :meth:`telegram.Bot.create_invoice_link`. The enum
members of this enumeration are instances of :class:`int` and can be treated as such.
"""This enum contains limitations for :class:`telegram.InputInvoiceMessageContent`,
:meth:`telegram.Bot.send_invoice`, and :meth:`telegram.Bot.create_invoice_link`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.
.. versionadded:: 20.0
"""
@ -1471,6 +1494,14 @@ class InvoiceLimit(IntEnum):
* :paramref:`~telegram.Bot.create_invoice_link.payload` parameter of
:meth:`telegram.Bot.create_invoice_link`.
"""
MAX_TIP_AMOUNTS = 4
""":obj:`int`: Maximum length of a :obj:`Sequence` passed as:
* :paramref:`~telegram.Bot.send_invoice.suggested_tip_amounts` parameter of
:meth:`telegram.Bot.send_invoice`.
* :paramref:`~telegram.Bot.create_invoice_link.suggested_tip_amounts` parameter of
:meth:`telegram.Bot.create_invoice_link`.
"""
class UserProfilePhotosLimit(IntEnum):