disable_notifications изменен на notify
This commit is contained in:
parent
8f5fc9f398
commit
8aa9c65fcc
@ -78,7 +78,7 @@ class Bot(BaseConnection):
|
|||||||
self,
|
self,
|
||||||
token: str,
|
token: str,
|
||||||
parse_mode: Optional[ParseMode] = None,
|
parse_mode: Optional[ParseMode] = None,
|
||||||
disable_notifications: Optional[bool] = None,
|
notify: Optional[bool] = None,
|
||||||
auto_requests: bool = True,
|
auto_requests: bool = True,
|
||||||
):
|
):
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class Bot(BaseConnection):
|
|||||||
|
|
||||||
:param token: Токен доступа к API бота
|
:param token: Токен доступа к API бота
|
||||||
:param parse_mode: Форматирование по умолчанию
|
:param parse_mode: Форматирование по умолчанию
|
||||||
:param disable_notifications: Отключение уведомлений при отправке сообщений (по умолчанию игнорируется)
|
:param notify: Отключение уведомлений при отправке сообщений (по умолчанию игнорируется) (не работает на стороне MAX)
|
||||||
:param auto_requests: Автоматическое заполнение полей chat и from_user в Update
|
:param auto_requests: Автоматическое заполнение полей chat и from_user в Update
|
||||||
с помощью API запросов если они не заложены как полноценные объекты в Update (по умолчанию True, при False chat и from_user в некоторых событиях будут выдавать None)
|
с помощью API запросов если они не заложены как полноценные объекты в Update (по умолчанию True, при False chat и from_user в некоторых событиях будут выдавать None)
|
||||||
"""
|
"""
|
||||||
@ -100,30 +100,28 @@ class Bot(BaseConnection):
|
|||||||
self.marker_updates = None
|
self.marker_updates = None
|
||||||
|
|
||||||
self.parse_mode = parse_mode
|
self.parse_mode = parse_mode
|
||||||
self.disable_notifications = disable_notifications
|
self.notify = notify
|
||||||
self.auto_requests = auto_requests
|
self.auto_requests = auto_requests
|
||||||
|
|
||||||
async def send_message(
|
async def send_message(
|
||||||
self,
|
self,
|
||||||
chat_id: int = None,
|
chat_id: int = None,
|
||||||
user_id: int = None,
|
user_id: int = None,
|
||||||
disable_link_preview: bool = False,
|
|
||||||
text: str = None,
|
text: str = None,
|
||||||
attachments: List[Attachment] = None,
|
attachments: List[Attachment] = None,
|
||||||
link: NewMessageLink = None,
|
link: NewMessageLink = None,
|
||||||
notify: bool = True,
|
notify: Optional[bool] = None,
|
||||||
parse_mode: ParseMode = None
|
parse_mode: Optional[ParseMode] = None
|
||||||
) -> SendedMessage:
|
) -> SendedMessage:
|
||||||
|
|
||||||
"""Отправляет сообщение в чат или пользователю.
|
"""Отправляет сообщение в чат или пользователю.
|
||||||
|
|
||||||
:param chat_id: ID чата для отправки (обязателен, если не указан user_id)
|
:param chat_id: ID чата для отправки (обязателен, если не указан user_id)
|
||||||
:param user_id: ID пользователя для отправки (обязателен, если не указан chat_id)
|
:param user_id: ID пользователя для отправки (обязателен, если не указан chat_id)
|
||||||
:param disable_link_preview: Отключить предпросмотр ссылок (по умолчанию False)
|
|
||||||
:param text: Текст сообщения
|
:param text: Текст сообщения
|
||||||
:param attachments: Список вложений к сообщению
|
:param attachments: Список вложений к сообщению
|
||||||
:param link: Данные ссылки сообщения
|
:param link: Данные ссылки сообщения
|
||||||
:param notify: Отправлять уведомление получателю (по умолчанию True)
|
:param notify: Отправлять уведомление получателю (по умолчанию берется значение из бота)
|
||||||
:param parse_mode: Режим форматирования текста
|
:param parse_mode: Режим форматирования текста
|
||||||
|
|
||||||
:return: Объект отправленного сообщения
|
:return: Объект отправленного сообщения
|
||||||
@ -133,12 +131,11 @@ class Bot(BaseConnection):
|
|||||||
bot=self,
|
bot=self,
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
disable_link_preview=disable_link_preview,
|
|
||||||
text=text,
|
text=text,
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
link=link,
|
link=link,
|
||||||
notify=notify if not self.disable_notifications \
|
notify=notify if notify \
|
||||||
else self.disable_notifications,
|
else self.notify,
|
||||||
parse_mode=parse_mode if parse_mode \
|
parse_mode=parse_mode if parse_mode \
|
||||||
else self.parse_mode
|
else self.parse_mode
|
||||||
).request()
|
).request()
|
||||||
@ -169,8 +166,8 @@ class Bot(BaseConnection):
|
|||||||
text: str = None,
|
text: str = None,
|
||||||
attachments: List[Attachment] = None,
|
attachments: List[Attachment] = None,
|
||||||
link: NewMessageLink = None,
|
link: NewMessageLink = None,
|
||||||
notify: bool = True,
|
notify: Optional[bool] = None,
|
||||||
parse_mode: ParseMode = None
|
parse_mode: Optional[ParseMode] = None
|
||||||
) -> EditedMessage:
|
) -> EditedMessage:
|
||||||
|
|
||||||
"""Редактирует существующее сообщение.
|
"""Редактирует существующее сообщение.
|
||||||
@ -179,7 +176,7 @@ class Bot(BaseConnection):
|
|||||||
:param text: Новый текст сообщения
|
:param text: Новый текст сообщения
|
||||||
:param attachments: Новые вложения
|
:param attachments: Новые вложения
|
||||||
:param link: Новая ссылка сообщения
|
:param link: Новая ссылка сообщения
|
||||||
:param notify: Уведомлять получателя об изменении (по умолчанию True)
|
:param notify: Отправлять уведомление получателю (по умолчанию берется значение из бота)
|
||||||
:param parse_mode: Режим форматирования текста
|
:param parse_mode: Режим форматирования текста
|
||||||
|
|
||||||
:return: Объект отредактированного сообщения
|
:return: Объект отредактированного сообщения
|
||||||
@ -191,8 +188,8 @@ class Bot(BaseConnection):
|
|||||||
text=text,
|
text=text,
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
link=link,
|
link=link,
|
||||||
notify=notify if not self.disable_notifications \
|
notify=notify if notify \
|
||||||
else self.disable_notifications,
|
else self.notify,
|
||||||
parse_mode=parse_mode if parse_mode \
|
parse_mode=parse_mode if parse_mode \
|
||||||
else self.parse_mode
|
else self.parse_mode
|
||||||
).request()
|
).request()
|
||||||
@ -382,7 +379,7 @@ class Bot(BaseConnection):
|
|||||||
icon: PhotoAttachmentRequestPayload = None,
|
icon: PhotoAttachmentRequestPayload = None,
|
||||||
title: str = None,
|
title: str = None,
|
||||||
pin: str = None,
|
pin: str = None,
|
||||||
notify: bool = True,
|
notify: Optional[bool] = None,
|
||||||
) -> Chat:
|
) -> Chat:
|
||||||
|
|
||||||
"""Редактирует параметры чата.
|
"""Редактирует параметры чата.
|
||||||
@ -391,7 +388,7 @@ class Bot(BaseConnection):
|
|||||||
:param icon: Данные иконки чата
|
:param icon: Данные иконки чата
|
||||||
:param title: Новый заголовок чата
|
:param title: Новый заголовок чата
|
||||||
:param pin: ID сообщения для закрепления
|
:param pin: ID сообщения для закрепления
|
||||||
:param notify: Уведомлять участников (по умолчанию True)
|
:param notify: Отправлять уведомление получателю (по умолчанию берется значение из бота)
|
||||||
|
|
||||||
:return: Обновленный объект чата
|
:return: Обновленный объект чата
|
||||||
"""
|
"""
|
||||||
@ -402,8 +399,8 @@ class Bot(BaseConnection):
|
|||||||
icon=icon,
|
icon=icon,
|
||||||
title=title,
|
title=title,
|
||||||
pin=pin,
|
pin=pin,
|
||||||
notify=notify if not self.disable_notifications \
|
notify=notify if notify \
|
||||||
else self.disable_notifications,
|
else self.notify,
|
||||||
).request()
|
).request()
|
||||||
|
|
||||||
async def get_video(
|
async def get_video(
|
||||||
@ -450,14 +447,14 @@ class Bot(BaseConnection):
|
|||||||
self,
|
self,
|
||||||
chat_id: int,
|
chat_id: int,
|
||||||
message_id: str,
|
message_id: str,
|
||||||
notify: bool = True
|
notify: Optional[bool] = None
|
||||||
) -> PinnedMessage:
|
) -> PinnedMessage:
|
||||||
|
|
||||||
"""Закрепляет сообщение в чате.
|
"""Закрепляет сообщение в чате.
|
||||||
|
|
||||||
:param chat_id: ID чата
|
:param chat_id: ID чата
|
||||||
:param message_id: ID сообщения
|
:param message_id: ID сообщения
|
||||||
:param notify: Уведомлять участников (по умолчанию True)
|
:param notify: Отправлять уведомление получателю (по умолчанию берется значение из бота)
|
||||||
|
|
||||||
:return: Закрепленное сообщение
|
:return: Закрепленное сообщение
|
||||||
"""
|
"""
|
||||||
@ -466,8 +463,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 if not self.disable_notifications \
|
notify=notify if notify \
|
||||||
else self.disable_notifications,
|
else self.notify,
|
||||||
).request()
|
).request()
|
||||||
|
|
||||||
async def delete_pin_message(
|
async def delete_pin_message(
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import List, TYPE_CHECKING
|
from typing import List, TYPE_CHECKING, Optional
|
||||||
|
|
||||||
from .types.edited_message import EditedMessage
|
from .types.edited_message import EditedMessage
|
||||||
from ..types.message import NewMessageLink
|
from ..types.message import NewMessageLink
|
||||||
@ -38,7 +38,7 @@ class EditMessage(BaseConnection):
|
|||||||
attachments: List['Attachment'] = None,
|
attachments: List['Attachment'] = None,
|
||||||
link: 'NewMessageLink' = None,
|
link: 'NewMessageLink' = None,
|
||||||
notify: bool = True,
|
notify: bool = True,
|
||||||
parse_mode: ParseMode = None
|
parse_mode: Optional[ParseMode] = None
|
||||||
):
|
):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.message_id = message_id
|
self.message_id = message_id
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import List, TYPE_CHECKING
|
from typing import List, TYPE_CHECKING, Optional
|
||||||
|
|
||||||
from json import loads as json_loads
|
from json import loads as json_loads
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ class SendMessage(BaseConnection):
|
|||||||
bot (Bot): Экземпляр бота для выполнения запроса.
|
bot (Bot): Экземпляр бота для выполнения запроса.
|
||||||
chat_id (int, optional): Идентификатор чата, куда отправлять сообщение.
|
chat_id (int, optional): Идентификатор чата, куда отправлять сообщение.
|
||||||
user_id (int, optional): Идентификатор пользователя, если нужно отправить личное сообщение.
|
user_id (int, optional): Идентификатор пользователя, если нужно отправить личное сообщение.
|
||||||
disable_link_preview (bool, optional): Отключить предпросмотр ссылок. По умолчанию False.
|
|
||||||
text (str, optional): Текст сообщения.
|
text (str, optional): Текст сообщения.
|
||||||
attachments (List[Attachment | InputMedia], optional): Список вложений к сообщению.
|
attachments (List[Attachment | InputMedia], optional): Список вложений к сообщению.
|
||||||
link (NewMessageLink, optional): Связь с другим сообщением (например, ответ или пересылка).
|
link (NewMessageLink, optional): Связь с другим сообщением (например, ответ или пересылка).
|
||||||
@ -51,17 +50,15 @@ class SendMessage(BaseConnection):
|
|||||||
bot: 'Bot',
|
bot: 'Bot',
|
||||||
chat_id: int = None,
|
chat_id: int = None,
|
||||||
user_id: int = None,
|
user_id: int = None,
|
||||||
disable_link_preview: bool = False,
|
|
||||||
text: str = None,
|
text: str = None,
|
||||||
attachments: List[Attachment | InputMedia] = None,
|
attachments: List[Attachment | InputMedia] = None,
|
||||||
link: NewMessageLink = None,
|
link: NewMessageLink = None,
|
||||||
notify: bool = True,
|
notify: bool = True,
|
||||||
parse_mode: ParseMode = None
|
parse_mode: Optional[ParseMode] = None
|
||||||
):
|
):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.chat_id = chat_id
|
self.chat_id = chat_id
|
||||||
self.user_id = user_id
|
self.user_id = user_id
|
||||||
self.disable_link_preview = disable_link_preview
|
|
||||||
self.text = text
|
self.text = text
|
||||||
self.attachments = attachments
|
self.attachments = attachments
|
||||||
self.link = link
|
self.link = link
|
||||||
@ -129,7 +126,6 @@ class SendMessage(BaseConnection):
|
|||||||
elif self.user_id: params['user_id'] = self.user_id
|
elif self.user_id: params['user_id'] = self.user_id
|
||||||
|
|
||||||
json['text'] = self.text
|
json['text'] = self.text
|
||||||
json['disable_link_preview'] = str(self.disable_link_preview).lower()
|
|
||||||
|
|
||||||
if self.attachments:
|
if self.attachments:
|
||||||
|
|
||||||
|
@ -172,11 +172,10 @@ class Message(BaseModel):
|
|||||||
async def answer(
|
async def answer(
|
||||||
self,
|
self,
|
||||||
text: str = None,
|
text: str = None,
|
||||||
disable_link_preview: bool = False,
|
|
||||||
attachments: List[Attachment] = None,
|
attachments: List[Attachment] = None,
|
||||||
link: NewMessageLink = None,
|
link: NewMessageLink = None,
|
||||||
notify: bool = True,
|
notify: Optional[bool] = None,
|
||||||
parse_mode: ParseMode = None
|
parse_mode: Optional[ParseMode] = None
|
||||||
):
|
):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -184,7 +183,6 @@ class Message(BaseModel):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
text (str, optional): Текст ответа. Может быть None.
|
text (str, optional): Текст ответа. Может быть None.
|
||||||
disable_link_preview (bool): Отключить предпросмотр ссылок. По умолчанию False.
|
|
||||||
attachments (List[Attachment], optional): Список вложений. Может быть None.
|
attachments (List[Attachment], optional): Список вложений. Может быть None.
|
||||||
link (NewMessageLink, optional): Связь с другим сообщением. Может быть None.
|
link (NewMessageLink, optional): Связь с другим сообщением. Может быть None.
|
||||||
notify (bool): Флаг отправки уведомления. По умолчанию True.
|
notify (bool): Флаг отправки уведомления. По умолчанию True.
|
||||||
@ -198,7 +196,6 @@ class Message(BaseModel):
|
|||||||
chat_id=self.recipient.chat_id,
|
chat_id=self.recipient.chat_id,
|
||||||
user_id=self.recipient.user_id,
|
user_id=self.recipient.user_id,
|
||||||
text=text,
|
text=text,
|
||||||
disable_link_preview=disable_link_preview,
|
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
link=link,
|
link=link,
|
||||||
notify=notify,
|
notify=notify,
|
||||||
@ -208,10 +205,9 @@ class Message(BaseModel):
|
|||||||
async def reply(
|
async def reply(
|
||||||
self,
|
self,
|
||||||
text: str = None,
|
text: str = None,
|
||||||
disable_link_preview: bool = False,
|
|
||||||
attachments: List[Attachment] = None,
|
attachments: List[Attachment] = None,
|
||||||
notify: bool = True,
|
notify: Optional[bool] = None,
|
||||||
parse_mode: ParseMode = None
|
parse_mode: Optional[ParseMode] = None
|
||||||
):
|
):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -219,7 +215,6 @@ class Message(BaseModel):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
text (str, optional): Текст ответа. Может быть None.
|
text (str, optional): Текст ответа. Может быть None.
|
||||||
disable_link_preview (bool): Отключить предпросмотр ссылок. По умолчанию False.
|
|
||||||
attachments (List[Attachment], optional): Список вложений. Может быть None.
|
attachments (List[Attachment], optional): Список вложений. Может быть None.
|
||||||
notify (bool): Флаг отправки уведомления. По умолчанию True.
|
notify (bool): Флаг отправки уведомления. По умолчанию True.
|
||||||
parse_mode (ParseMode, optional): Режим форматирования текста. Может быть None.
|
parse_mode (ParseMode, optional): Режим форматирования текста. Может быть None.
|
||||||
@ -232,7 +227,6 @@ class Message(BaseModel):
|
|||||||
chat_id=self.recipient.chat_id,
|
chat_id=self.recipient.chat_id,
|
||||||
user_id=self.recipient.user_id,
|
user_id=self.recipient.user_id,
|
||||||
text=text,
|
text=text,
|
||||||
disable_link_preview=disable_link_preview,
|
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
link=NewMessageLink(
|
link=NewMessageLink(
|
||||||
type=MessageLinkType.REPLY,
|
type=MessageLinkType.REPLY,
|
||||||
@ -246,10 +240,9 @@ class Message(BaseModel):
|
|||||||
self,
|
self,
|
||||||
chat_id,
|
chat_id,
|
||||||
user_id: int = None,
|
user_id: int = None,
|
||||||
disable_link_preview: bool = False,
|
|
||||||
attachments: List[Attachment] = None,
|
attachments: List[Attachment] = None,
|
||||||
notify: bool = True,
|
notify: Optional[bool] = None,
|
||||||
parse_mode: ParseMode = None
|
parse_mode: Optional[ParseMode] = None
|
||||||
):
|
):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -258,7 +251,6 @@ class Message(BaseModel):
|
|||||||
Args:
|
Args:
|
||||||
chat_id (int): ID чата для отправки (обязателен, если не указан user_id)
|
chat_id (int): ID чата для отправки (обязателен, если не указан user_id)
|
||||||
user_id (int): ID пользователя для отправки (обязателен, если не указан chat_id). По умолчанию None
|
user_id (int): ID пользователя для отправки (обязателен, если не указан chat_id). По умолчанию None
|
||||||
disable_link_preview (bool): Отключить предпросмотр ссылок. По умолчанию False.
|
|
||||||
attachments (List[Attachment], optional): Список вложений. Может быть None.
|
attachments (List[Attachment], optional): Список вложений. Может быть None.
|
||||||
notify (bool): Флаг отправки уведомления. По умолчанию True.
|
notify (bool): Флаг отправки уведомления. По умолчанию True.
|
||||||
parse_mode (ParseMode, optional): Режим форматирования текста. Может быть None.
|
parse_mode (ParseMode, optional): Режим форматирования текста. Может быть None.
|
||||||
@ -270,7 +262,6 @@ class Message(BaseModel):
|
|||||||
return await self.bot.send_message(
|
return await self.bot.send_message(
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
disable_link_preview=disable_link_preview,
|
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
link=NewMessageLink(
|
link=NewMessageLink(
|
||||||
type=MessageLinkType.FORWARD,
|
type=MessageLinkType.FORWARD,
|
||||||
@ -286,7 +277,7 @@ class Message(BaseModel):
|
|||||||
attachments: List[Attachment] = None,
|
attachments: List[Attachment] = None,
|
||||||
link: NewMessageLink = None,
|
link: NewMessageLink = None,
|
||||||
notify: bool = True,
|
notify: bool = True,
|
||||||
parse_mode: ParseMode = None
|
parse_mode: Optional[ParseMode] = None
|
||||||
):
|
):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -90,7 +90,7 @@ class MessageCallback(Update):
|
|||||||
new_text: str = None,
|
new_text: str = None,
|
||||||
link: NewMessageLink = None,
|
link: NewMessageLink = None,
|
||||||
notify: bool = True,
|
notify: bool = True,
|
||||||
format: ParseMode = None,
|
format: Optional[ParseMode] = None,
|
||||||
):
|
):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user