From d996e8f9c9b9b6f5eac55b7b07bb04a7e864dc49 Mon Sep 17 00:00:00 2001 From: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com> Date: Fri, 30 Dec 2022 16:09:06 +0300 Subject: [PATCH] Add New Constants (#3444) --- telegram/_bot.py | 20 +++++++++++--------- telegram/_payment/invoice.py | 5 +++++ telegram/constants.py | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/telegram/_bot.py b/telegram/_bot.py index 332b8785e3a..cad02962e95 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -1848,9 +1848,11 @@ async def send_media_group( 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 2–10 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 @@ async def send_invoice( .. 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 @@ async def create_invoice_link( 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 diff --git a/telegram/_payment/invoice.py b/telegram/_payment/invoice.py index 22bc17e7abe..2c33e1fdc68 100644 --- a/telegram/_payment/invoice.py +++ b/telegram/_payment/invoice.py @@ -119,3 +119,8 @@ def __init__( .. versionadded:: 20.0 """ + MAX_TIP_AMOUNTS: ClassVar[int] = constants.InvoiceLimit.MAX_TIP_AMOUNTS + """:const:`telegram.constants.InvoiceLimit.MAX_TIP_AMOUNTS` + + .. versionadded:: 20.0 + """ diff --git a/telegram/constants.py b/telegram/constants.py index cf3f033ad1d..3fae673e0d0 100644 --- a/telegram/constants.py +++ b/telegram/constants.py @@ -61,6 +61,7 @@ "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):