Поправлено преобразование вложений для ответа на callback

This commit is contained in:
Денис Семёнов 2025-08-05 00:53:17 +03:00
parent b59d97da8a
commit e922132319
3 changed files with 31 additions and 45 deletions

View File

@ -0,0 +1,25 @@
from typing import Annotated, Union
from pydantic import Field
from ..attachments.share import Share
from ..attachments.buttons.attachment_button import AttachmentButton
from ..attachments.sticker import Sticker
from ..attachments.file import File
from ..attachments.image import Image
from ..attachments.video import Video
from ..attachments.audio import Audio
from ..attachments.location import Location
from ..attachments.contact import Contact
Attachments = Annotated[Union[
Audio,
Video,
File,
Image,
Sticker,
Share,
Location,
AttachmentButton,
Contact
], Field(discriminator='type')]

View File

@ -1,9 +1,9 @@
from __future__ import annotations from __future__ import annotations
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from typing import Annotated, Any, Optional, List, Union, TYPE_CHECKING from typing import Any, Optional, List, Union, TYPE_CHECKING
from ..types.attachments.contact import Contact from ..types.attachments import Attachments
from ..enums.text_style import TextStyle from ..enums.text_style import TextStyle
from ..enums.parse_mode import ParseMode from ..enums.parse_mode import ParseMode
@ -11,14 +11,6 @@ from ..enums.chat_type import ChatType
from ..enums.message_link_type import MessageLinkType from ..enums.message_link_type import MessageLinkType
from .attachments.attachment import Attachment from .attachments.attachment import Attachment
from .attachments.share import Share
from .attachments.buttons.attachment_button import AttachmentButton
from .attachments.sticker import Sticker
from .attachments.file import File
from .attachments.image import Image
from .attachments.video import Video
from .attachments.audio import Audio
from .attachments.location import Location
from .users import User from .users import User
@ -28,19 +20,6 @@ if TYPE_CHECKING:
from ..types.input_media import InputMedia, InputMediaBuffer from ..types.input_media import InputMedia, InputMediaBuffer
Attachments = Annotated[Union[
Audio,
Video,
File,
Image,
Sticker,
Share,
Location,
AttachmentButton,
Contact
], Field(discriminator='type')]
class MarkupElement(BaseModel): class MarkupElement(BaseModel):
""" """

View File

@ -1,25 +1,18 @@
from typing import List, Optional, Union from typing import List, Optional
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from ...types.attachments.location import Location from ...types.attachments import Attachments
from .update import Update from .update import Update
from ...enums.parse_mode import ParseMode from ...enums.parse_mode import ParseMode
from ...types.message import NewMessageLink from ...types.message import NewMessageLink
from ...types.attachments.share import Share
from ...types.callback import Callback from ...types.callback import Callback
from ...types.message import Message from ...types.message import Message
from ..attachments.buttons.attachment_button import AttachmentButton
from ..attachments.sticker import Sticker
from ..attachments.file import File
from ..attachments.image import Image
from ..attachments.video import Video
from ..attachments.audio import Audio
class MessageForCallback(BaseModel): class MessageForCallback(BaseModel):
@ -37,18 +30,7 @@ class MessageForCallback(BaseModel):
text: Optional[str] = None text: Optional[str] = None
attachments: Optional[ attachments: Optional[
List[ List[Attachments]
Union[
AttachmentButton,
Audio,
Video,
File,
Image,
Sticker,
Share,
Location
]
]
] = Field(default_factory=list) # type: ignore ] = Field(default_factory=list) # type: ignore
link: Optional[NewMessageLink] = None link: Optional[NewMessageLink] = None
notify: Optional[bool] = True notify: Optional[bool] = True