Skip to content

Commit

Permalink
add limits for media param of Bot.send_media_group to constants.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lemontree210 committed Dec 28, 2022
1 parent b8fbb89 commit a58cfc8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
8 changes: 5 additions & 3 deletions telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,9 +1828,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
22 changes: 22 additions & 0 deletions telegram/constants.py
Original file line number Diff line number Diff line change
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`: Minimum 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

0 comments on commit a58cfc8

Please sign in to comment.