From c60ee8e40e89db2de6100c3a389a2d0be57bc53f Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Tue, 22 Nov 2022 23:20:27 +0200 Subject: [PATCH] Added InputMediaType enum --- .butcher/enums/InputMediaType.yml | 14 ++++++++++++++ aiogram/enums/__init__.py | 2 ++ aiogram/enums/input_media_type.py | 15 +++++++++++++++ aiogram/types/input_media_animation.py | 3 ++- aiogram/types/input_media_audio.py | 3 ++- aiogram/types/input_media_document.py | 3 ++- aiogram/types/input_media_photo.py | 3 ++- aiogram/types/input_media_video.py | 3 ++- docs/api/enums/index.rst | 1 + docs/api/enums/input_media_type.rst | 9 +++++++++ 10 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 .butcher/enums/InputMediaType.yml create mode 100644 aiogram/enums/input_media_type.py create mode 100644 docs/api/enums/input_media_type.rst diff --git a/.butcher/enums/InputMediaType.yml b/.butcher/enums/InputMediaType.yml new file mode 100644 index 00000000..39e7e2f1 --- /dev/null +++ b/.butcher/enums/InputMediaType.yml @@ -0,0 +1,14 @@ +name: InputMediaType +description: | + This object represents input media type + + Source: https://core.telegram.org/bots/api#inputmedia +multi_parse: + attribute: type + regexp: 'must be ([a-z_]+)' + entities: + - InputMediaAnimation + - InputMediaAudio + - InputMediaDocument + - InputMediaPhoto + - InputMediaVideo diff --git a/aiogram/enums/__init__.py b/aiogram/enums/__init__.py index 0d197052..c6620f0b 100644 --- a/aiogram/enums/__init__.py +++ b/aiogram/enums/__init__.py @@ -4,6 +4,7 @@ from .chat_member_status import ChatMemberStatus from .chat_type import ChatType from .content_type import ContentType from .dice_emoji import DiceEmoji +from .input_media_type import InputMediaType from .menu_button_type import MenuButtonType from .message_entity_type import MessageEntityType from .parse_mode import ParseMode @@ -18,6 +19,7 @@ __all__ = ( "ChatType", "ContentType", "DiceEmoji", + "InputMediaType", "MenuButtonType", "MessageEntityType", "ParseMode", diff --git a/aiogram/enums/input_media_type.py b/aiogram/enums/input_media_type.py new file mode 100644 index 00000000..30741dd4 --- /dev/null +++ b/aiogram/enums/input_media_type.py @@ -0,0 +1,15 @@ +from enum import Enum + + +class InputMediaType(str, Enum): + """ + This object represents input media type + + Source: https://core.telegram.org/bots/api#inputmedia + """ + + ANIMATION = "animation" + AUDIO = "audio" + DOCUMENT = "document" + PHOTO = "photo" + VIDEO = "video" diff --git a/aiogram/types/input_media_animation.py b/aiogram/types/input_media_animation.py index 7e25a8a2..194428ec 100644 --- a/aiogram/types/input_media_animation.py +++ b/aiogram/types/input_media_animation.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, List, Optional, Union from pydantic import Field +from ..enums import InputMediaType from .base import UNSET from .input_media import InputMedia @@ -19,7 +20,7 @@ class InputMediaAnimation(InputMedia): Source: https://core.telegram.org/bots/api#inputmediaanimation """ - type: str = Field("animation", const=True) + type: str = Field(InputMediaType.ANIMATION, const=True) """Type of the result, must be *animation*""" media: Union[str, InputFile] """File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/input_media_audio.py b/aiogram/types/input_media_audio.py index 35884192..a9d69610 100644 --- a/aiogram/types/input_media_audio.py +++ b/aiogram/types/input_media_audio.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, List, Optional, Union from pydantic import Field +from ..enums import InputMediaType from .base import UNSET from .input_media import InputMedia @@ -19,7 +20,7 @@ class InputMediaAudio(InputMedia): Source: https://core.telegram.org/bots/api#inputmediaaudio """ - type: str = Field("audio", const=True) + type: str = Field(InputMediaType.AUDIO, const=True) """Type of the result, must be *audio*""" media: Union[str, InputFile] """File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/input_media_document.py b/aiogram/types/input_media_document.py index 639be1ed..22aea188 100644 --- a/aiogram/types/input_media_document.py +++ b/aiogram/types/input_media_document.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, List, Optional, Union from pydantic import Field +from ..enums import InputMediaType from .base import UNSET from .input_media import InputMedia @@ -19,7 +20,7 @@ class InputMediaDocument(InputMedia): Source: https://core.telegram.org/bots/api#inputmediadocument """ - type: str = Field("document", const=True) + type: str = Field(InputMediaType.DOCUMENT, const=True) """Type of the result, must be *document*""" media: Union[str, InputFile] """File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/input_media_photo.py b/aiogram/types/input_media_photo.py index d824f5f5..d3eb85d1 100644 --- a/aiogram/types/input_media_photo.py +++ b/aiogram/types/input_media_photo.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, List, Optional, Union from pydantic import Field +from ..enums import InputMediaType from .base import UNSET from .input_media import InputMedia @@ -19,7 +20,7 @@ class InputMediaPhoto(InputMedia): Source: https://core.telegram.org/bots/api#inputmediaphoto """ - type: str = Field("photo", const=True) + type: str = Field(InputMediaType.PHOTO, const=True) """Type of the result, must be *photo*""" media: Union[str, InputFile] """File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/aiogram/types/input_media_video.py b/aiogram/types/input_media_video.py index 224663e3..eb9dd4dd 100644 --- a/aiogram/types/input_media_video.py +++ b/aiogram/types/input_media_video.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, List, Optional, Union from pydantic import Field +from ..enums import InputMediaType from .base import UNSET from .input_media import InputMedia @@ -19,7 +20,7 @@ class InputMediaVideo(InputMedia): Source: https://core.telegram.org/bots/api#inputmediavideo """ - type: str = Field("video", const=True) + type: str = Field(InputMediaType.VIDEO, const=True) """Type of the result, must be *video*""" media: Union[str, InputFile] """File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. :ref:`More information on Sending Files » `""" diff --git a/docs/api/enums/index.rst b/docs/api/enums/index.rst index e392a4d1..85073cd4 100644 --- a/docs/api/enums/index.rst +++ b/docs/api/enums/index.rst @@ -14,6 +14,7 @@ Here is list of all available enums: chat_type content_type dice_emoji + input_media_type menu_button_type message_entity_type parse_mode diff --git a/docs/api/enums/input_media_type.rst b/docs/api/enums/input_media_type.rst new file mode 100644 index 00000000..7cb3451b --- /dev/null +++ b/docs/api/enums/input_media_type.rst @@ -0,0 +1,9 @@ +############## +InputMediaType +############## + + +.. automodule:: aiogram.enums.input_media_type + :members: + :member-order: bysource + :undoc-members: True