Skip to content

Commit

Permalink
Add New Constants (#3444)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemontree210 committed Dec 30, 2022
1 parent 0a67258 commit d996e8f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
20 changes: 11 additions & 9 deletions telegram/_bot.py
Expand Up @@ -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|
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions telegram/_payment/invoice.py
Expand Up @@ -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
"""
35 changes: 33 additions & 2 deletions telegram/constants.py
Expand Up @@ -61,6 +61,7 @@
"InvoiceLimit",
"LocationLimit",
"MaskPosition",
"MediaGroupLimit",
"MenuButtonType",
"MessageAttachmentType",
"MessageEntityType",
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d996e8f

Please sign in to comment.