Override InputPaidMedia media type to str | InputFile

This commit is contained in:
JRoot Junior 2024-07-06 19:33:47 +03:00
parent c59d328408
commit 7634587fa4
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
4 changed files with 28 additions and 5 deletions

View file

@ -0,0 +1,11 @@
annotations:
media:
parsed_type:
type: union
items:
- type: std
name: str
- type: entity
references:
category: types
name: InputFile

View file

@ -0,0 +1,11 @@
annotations:
media:
parsed_type:
type: union
items:
- type: std
name: str
- type: entity
references:
category: types
name: InputFile

View file

@ -1,9 +1,10 @@
from __future__ import annotations from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal from typing import TYPE_CHECKING, Any, Literal, Union
from ..enums import InputPaidMediaType from ..enums import InputPaidMediaType
from .input_paid_media import InputPaidMedia from .input_paid_media import InputPaidMedia
from .input_file import InputFile
class InputPaidMediaPhoto(InputPaidMedia): class InputPaidMediaPhoto(InputPaidMedia):
@ -15,7 +16,7 @@ class InputPaidMediaPhoto(InputPaidMedia):
type: Literal[InputPaidMediaType.PHOTO] = InputPaidMediaType.PHOTO type: Literal[InputPaidMediaType.PHOTO] = InputPaidMediaType.PHOTO
"""Type of the media, must be *photo*""" """Type of the media, must be *photo*"""
media: str 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://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`""" """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://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
if TYPE_CHECKING: if TYPE_CHECKING:
@ -26,7 +27,7 @@ class InputPaidMediaPhoto(InputPaidMedia):
__pydantic__self__, __pydantic__self__,
*, *,
type: Literal[InputPaidMediaType.PHOTO] = InputPaidMediaType.PHOTO, type: Literal[InputPaidMediaType.PHOTO] = InputPaidMediaType.PHOTO,
media: str, media: Union[str, InputFile],
**__pydantic_kwargs: Any, **__pydantic_kwargs: Any,
) -> None: ) -> None:
# DO NOT EDIT MANUALLY!!! # DO NOT EDIT MANUALLY!!!

View file

@ -16,7 +16,7 @@ class InputPaidMediaVideo(InputPaidMedia):
type: Literal[InputPaidMediaType.VIDEO] = InputPaidMediaType.VIDEO type: Literal[InputPaidMediaType.VIDEO] = InputPaidMediaType.VIDEO
"""Type of the media, must be *video*""" """Type of the media, must be *video*"""
media: str 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://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`""" """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://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
thumbnail: Optional[Union[InputFile, str]] = None thumbnail: Optional[Union[InputFile, str]] = None
"""*Optional*. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`""" """*Optional*. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
@ -37,7 +37,7 @@ class InputPaidMediaVideo(InputPaidMedia):
__pydantic__self__, __pydantic__self__,
*, *,
type: Literal[InputPaidMediaType.VIDEO] = InputPaidMediaType.VIDEO, type: Literal[InputPaidMediaType.VIDEO] = InputPaidMediaType.VIDEO,
media: str, media: Union[str, InputFile],
thumbnail: Optional[Union[InputFile, str]] = None, thumbnail: Optional[Union[InputFile, str]] = None,
width: Optional[int] = None, width: Optional[int] = None,
height: Optional[int] = None, height: Optional[int] = None,