Добавлены настройки для Bot() по умолчанию: parse_mode, disable_notifications
This commit is contained in:
parent
7b8aa3d092
commit
de684aa200
@ -1,5 +1,5 @@
|
|||||||
from datetime import datetime
|
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
|
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 token: Токен доступа к API бота
|
||||||
|
:param parse_mode: Форматирование по умолчанию
|
||||||
|
:param disable_notifications: Отключение уведомлений при отправке сообщений (по умолчанию игнорируется)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -89,6 +96,9 @@ class Bot(BaseConnection):
|
|||||||
self.params = {'access_token': self.__token}
|
self.params = {'access_token': self.__token}
|
||||||
self.marker_updates = None
|
self.marker_updates = None
|
||||||
|
|
||||||
|
self.parse_mode = parse_mode
|
||||||
|
self.disable_notifications = disable_notifications
|
||||||
|
|
||||||
async def send_message(
|
async def send_message(
|
||||||
self,
|
self,
|
||||||
chat_id: int = None,
|
chat_id: int = None,
|
||||||
@ -123,8 +133,10 @@ class Bot(BaseConnection):
|
|||||||
text=text,
|
text=text,
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
link=link,
|
link=link,
|
||||||
notify=notify,
|
notify=notify if not self.disable_notifications \
|
||||||
parse_mode=parse_mode
|
else self.disable_notifications,
|
||||||
|
parse_mode=parse_mode if parse_mode \
|
||||||
|
else self.parse_mode
|
||||||
).request()
|
).request()
|
||||||
|
|
||||||
async def send_action(
|
async def send_action(
|
||||||
@ -175,8 +187,10 @@ class Bot(BaseConnection):
|
|||||||
text=text,
|
text=text,
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
link=link,
|
link=link,
|
||||||
notify=notify,
|
notify=notify if not self.disable_notifications \
|
||||||
parse_mode=parse_mode
|
else self.disable_notifications,
|
||||||
|
parse_mode=parse_mode if parse_mode \
|
||||||
|
else self.parse_mode
|
||||||
).request()
|
).request()
|
||||||
|
|
||||||
async def delete_message(
|
async def delete_message(
|
||||||
@ -384,7 +398,8 @@ class Bot(BaseConnection):
|
|||||||
icon=icon,
|
icon=icon,
|
||||||
title=title,
|
title=title,
|
||||||
pin=pin,
|
pin=pin,
|
||||||
notify=notify
|
notify=notify if not self.disable_notifications \
|
||||||
|
else self.disable_notifications,
|
||||||
).request()
|
).request()
|
||||||
|
|
||||||
async def get_video(
|
async def get_video(
|
||||||
@ -447,7 +462,8 @@ class Bot(BaseConnection):
|
|||||||
bot=self,
|
bot=self,
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
notify=notify
|
notify=notify if not self.disable_notifications \
|
||||||
|
else self.disable_notifications,
|
||||||
).request()
|
).request()
|
||||||
|
|
||||||
async def delete_pin_message(
|
async def delete_pin_message(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user