Skip to content

Commit

Permalink
add limit for suggested_tip_amounts, fix docstr of InvoiceLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
lemontree210 committed Dec 28, 2022
1 parent a6f8c99 commit c4c3160
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
12 changes: 6 additions & 6 deletions telegram/_bot.py
Expand Up @@ -4211,9 +4211,9 @@ async def send_invoice(
.. versionadded:: 13.5
suggested_tip_amounts (Sequence[: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
Expand Down Expand Up @@ -6764,9 +6764,9 @@ async def create_invoice_link(
majority of currencies). Defaults to ``0``.
suggested_tip_amounts (Sequence[: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`.
.. versionchanged:: 20.0
Accept :obj:`Sequence` instead of :obj:`List`.
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
"""
13 changes: 11 additions & 2 deletions telegram/constants.py
Expand Up @@ -1425,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 @@ -1493,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 c4c3160

Please sign in to comment.