From e922132319ad2c30382d30d8f911babae356bfe8 Mon Sep 17 00:00:00 2001 From: Denis Date: Tue, 5 Aug 2025 00:53:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BF=D1=80=D0=B5=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=BB=D0=BE?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B4=D0=BB=D1=8F=20=D0=BE?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D1=82=D0=B0=20=D0=BD=D0=B0=20callback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maxapi/types/attachments/__init__.py | 25 +++++++++++++++++++++++ maxapi/types/message.py | 25 ++--------------------- maxapi/types/updates/message_callback.py | 26 ++++-------------------- 3 files changed, 31 insertions(+), 45 deletions(-) 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