From 42690d24ee1fceb4474338f617a37c28d8979456 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 31 Jul 2025 23:30:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D1=8F=20dialog=5F?= =?UTF-8?q?removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maxapi/dispatcher.py | 1 + maxapi/enums/update.py | 1 + maxapi/methods/types/getted_updates.py | 4 +++- maxapi/types/__init__.py | 3 ++- maxapi/types/updates/dialog_removed.py | 30 ++++++++++++++++++++++++++ wiki/events.md | 1 + 6 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 maxapi/types/updates/dialog_removed.py diff --git a/maxapi/dispatcher.py b/maxapi/dispatcher.py index d46d990..bff402a 100644 --- a/maxapi/dispatcher.py +++ b/maxapi/dispatcher.py @@ -85,6 +85,7 @@ class Dispatcher: self.dialog_cleared = Event(update_type=UpdateType.DIALOG_CLEARED, router=self) self.dialog_muted = Event(update_type=UpdateType.DIALOG_MUTED, router=self) self.dialog_unmuted = Event(update_type=UpdateType.DIALOG_UNMUTED, router=self) + self.dialog_removed = Event(update_type=UpdateType.DIALOG_REMOVED, router=self) self.chat_title_changed = Event(update_type=UpdateType.CHAT_TITLE_CHANGED, router=self) self.message_callback = Event(update_type=UpdateType.MESSAGE_CALLBACK, router=self) self.message_chat_created = Event(update_type=UpdateType.MESSAGE_CHAT_CREATED, router=self) diff --git a/maxapi/enums/update.py b/maxapi/enums/update.py index 78373fe..0babc2d 100644 --- a/maxapi/enums/update.py +++ b/maxapi/enums/update.py @@ -24,6 +24,7 @@ class UpdateType(str, Enum): DIALOG_CLEARED = 'dialog_cleared' DIALOG_MUTED = 'dialog_muted' DIALOG_UNMUTED = 'dialog_unmuted' + DIALOG_REMOVED = 'dialog_removed' # Для начинки диспатчера ON_STARTED = 'on_started' \ No newline at end of file diff --git a/maxapi/methods/types/getted_updates.py b/maxapi/methods/types/getted_updates.py index 97ce595..4b533c1 100644 --- a/maxapi/methods/types/getted_updates.py +++ b/maxapi/methods/types/getted_updates.py @@ -18,6 +18,7 @@ from ...types.updates.user_removed import UserRemoved from ...types.updates.dialog_cleared import DialogCleared from ...types.updates.dialog_muted import DialogMuted from ...types.updates.dialog_unmuted import DialogUnmuted +from ...types.updates.dialog_removed import DialogRemoved if TYPE_CHECKING: from ...bot import Bot @@ -38,7 +39,8 @@ UPDATE_MODEL_MAPPING = { UpdateType.BOT_STOPPED: BotStopped, UpdateType.DIALOG_CLEARED: DialogCleared, UpdateType.DIALOG_MUTED: DialogMuted, - UpdateType.DIALOG_UNMUTED: DialogUnmuted + UpdateType.DIALOG_UNMUTED: DialogUnmuted, + UpdateType.DIALOG_REMOVED: DialogRemoved } diff --git a/maxapi/types/__init__.py b/maxapi/types/__init__.py index fcdf549..f84947d 100644 --- a/maxapi/types/__init__.py +++ b/maxapi/types/__init__.py @@ -29,7 +29,7 @@ from ..types.attachments.buttons.open_app_button import OpenAppButton from ..types.attachments.buttons.request_geo_location_button import RequestGeoLocationButton from ..types.attachments.buttons.message_button import MessageButton from ..types.attachments.image import PhotoAttachmentRequestPayload -from ..types.message import Message +from ..types.message import Message, NewMessageLink from ..types.command import Command, BotCommand, CommandStart @@ -37,6 +37,7 @@ from .input_media import InputMedia from .input_media import InputMediaBuffer __all__ = [ + 'NewMessageLink', 'PhotoAttachmentRequestPayload', 'DialogUnmuted', 'DialogMuted', diff --git a/maxapi/types/updates/dialog_removed.py b/maxapi/types/updates/dialog_removed.py new file mode 100644 index 0000000..a2cce85 --- /dev/null +++ b/maxapi/types/updates/dialog_removed.py @@ -0,0 +1,30 @@ +from typing import TYPE_CHECKING, Optional + +from .update import Update + +from ...types.users import User + +if TYPE_CHECKING: + from ...bot import Bot + + +class DialogRemoved(Update): + + """ + Обновление, сигнализирующее об удалении диалога с ботом. + + Attributes: + chat_id (int): Идентификатор чата. + user (User): Пользователь (бот). + user_locale (Optional[str]): Локаль пользователя. + """ + + chat_id: int + user: User + user_locale: Optional[str] = None + + if TYPE_CHECKING: + bot: Optional[Bot] + + def get_ids(self): + return (self.chat_id, self.user.user_id) \ No newline at end of file diff --git a/wiki/events.md b/wiki/events.md index ebc1c1e..cf6ac61 100644 --- a/wiki/events.md +++ b/wiki/events.md @@ -10,6 +10,7 @@ | `dialog_cleared` | Пользователь очистил историю диалога с ботом | | `dialog_muted` | Пользователь отключил оповещения от чата бота | | `dialog_unmuted` | Пользователь включил оповещения от чата бота | +| `dialog_removed` | Пользователь удалил диалог с ботом | | `chat_title_changed` | Изменено название чата | | `message_callback` | Пользователь нажал на callback-кнопку (inline button) | | `message_chat_created`| Срабатывает когда пользователь нажал на кнопку с действием "Создать чат" (работает некорректно со стороны API MAX, ждем исправлений) |