diff --git a/maxapi/types/attachments/__init__.py b/maxapi/types/attachments/__init__.py index e69de29..2ea39b5 100644 --- a/maxapi/types/attachments/__init__.py +++ b/maxapi/types/attachments/__init__.py @@ -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')] \ No newline at end of file diff --git a/maxapi/types/message.py b/maxapi/types/message.py index 5202a03..9621c8b 100644 --- a/maxapi/types/message.py +++ b/maxapi/types/message.py @@ -1,9 +1,9 @@ from __future__ import annotations 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.parse_mode import ParseMode @@ -11,14 +11,6 @@ from ..enums.chat_type import ChatType from ..enums.message_link_type import MessageLinkType 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 @@ -26,19 +18,6 @@ from .users import User if TYPE_CHECKING: from ..bot import Bot 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): diff --git a/maxapi/types/updates/message_callback.py b/maxapi/types/updates/message_callback.py index 63c24c8..c2951d1 100644 --- a/maxapi/types/updates/message_callback.py +++ b/maxapi/types/updates/message_callback.py @@ -1,25 +1,18 @@ -from typing import List, Optional, Union +from typing import List, Optional from pydantic import BaseModel, Field -from ...types.attachments.location import Location +from ...types.attachments import Attachments + from .update import Update from ...enums.parse_mode import ParseMode from ...types.message import NewMessageLink -from ...types.attachments.share import Share from ...types.callback import Callback 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): @@ -37,18 +30,7 @@ class MessageForCallback(BaseModel): text: Optional[str] = None attachments: Optional[ - List[ - Union[ - AttachmentButton, - Audio, - Video, - File, - Image, - Sticker, - Share, - Location - ] - ] + List[Attachments] ] = Field(default_factory=list) # type: ignore link: Optional[NewMessageLink] = None notify: Optional[bool] = True