From de684aa2003065e753aa1f6e50b050769ce367a2 Mon Sep 17 00:00:00 2001 From: Denis Date: Sat, 21 Jun 2025 19:58:38 +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=D1=8B=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20Bot()=20=D0=BF=D0=BE=20=D1=83?= =?UTF-8?q?=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D1=8E:=20parse=5Fmod?= =?UTF-8?q?e,=20disable=5Fnotifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maxapi/bot.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/maxapi/bot.py b/maxapi/bot.py index 99c4e78..1c0d34b 100644 --- a/maxapi/bot.py +++ b/maxapi/bot.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Dict, List, TYPE_CHECKING +from typing import Any, Dict, List, TYPE_CHECKING, Optional from maxapi.methods.download_media import DownloadMedia @@ -74,11 +74,18 @@ class Bot(BaseConnection): пользователями и другими функциями бота. """ - def __init__(self, token: str): + def __init__( + self, + token: str, + parse_mode: Optional[ParseMode] = None, + disable_notifications: Optional[bool] = None + ): """Инициализирует экземпляр бота с указанным токеном. :param token: Токен доступа к API бота + :param parse_mode: Форматирование по умолчанию + :param disable_notifications: Отключение уведомлений при отправке сообщений (по умолчанию игнорируется) """ super().__init__() @@ -89,6 +96,9 @@ class Bot(BaseConnection): self.params = {'access_token': self.__token} self.marker_updates = None + self.parse_mode = parse_mode + self.disable_notifications = disable_notifications + async def send_message( self, chat_id: int = None, @@ -123,8 +133,10 @@ class Bot(BaseConnection): text=text, attachments=attachments, link=link, - notify=notify, - parse_mode=parse_mode + notify=notify if not self.disable_notifications \ + else self.disable_notifications, + parse_mode=parse_mode if parse_mode \ + else self.parse_mode ).request() async def send_action( @@ -175,8 +187,10 @@ class Bot(BaseConnection): text=text, attachments=attachments, link=link, - notify=notify, - parse_mode=parse_mode + notify=notify if not self.disable_notifications \ + else self.disable_notifications, + parse_mode=parse_mode if parse_mode \ + else self.parse_mode ).request() async def delete_message( @@ -384,7 +398,8 @@ class Bot(BaseConnection): icon=icon, title=title, pin=pin, - notify=notify + notify=notify if not self.disable_notifications \ + else self.disable_notifications, ).request() async def get_video( @@ -447,7 +462,8 @@ class Bot(BaseConnection): bot=self, chat_id=chat_id, message_id=message_id, - notify=notify + notify=notify if not self.disable_notifications \ + else self.disable_notifications, ).request() async def delete_pin_message(