Merge branch 'dev-2.x'

This commit is contained in:
Alex Root Junior 2022-02-01 02:21:35 +02:00
commit ef23b79ad7
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
21 changed files with 470 additions and 48 deletions

View file

@ -6,7 +6,7 @@
[![PyPi status](https://img.shields.io/pypi/status/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram)
[![Downloads](https://img.shields.io/pypi/dm/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram)
[![Supported python versions](https://img.shields.io/pypi/pyversions/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram)
[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-5.5-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-5.7-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
[![Documentation Status](https://img.shields.io/readthedocs/aiogram?style=flat-square)](http://docs.aiogram.dev/en/latest/?badge=latest)
[![Github issues](https://img.shields.io/github/issues/aiogram/aiogram.svg?style=flat-square)](https://github.com/aiogram/aiogram/issues)
[![MIT License](https://img.shields.io/pypi/l/aiogram.svg?style=flat-square)](https://opensource.org/licenses/MIT)

View file

@ -21,7 +21,7 @@ AIOGramBot
:target: https://pypi.python.org/pypi/aiogram
:alt: Supported python versions
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.3-blue.svg?style=flat-square&logo=telegram
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.7-blue.svg?style=flat-square&logo=telegram
:target: https://core.telegram.org/bots/api
:alt: Telegram Bot API

View file

@ -43,5 +43,5 @@ __all__ = (
'utils',
)
__version__ = '2.17.1'
__api_version__ = '5.5'
__version__ = '2.19'
__api_version__ = '5.7'

View file

@ -188,8 +188,6 @@ def compose_data(params=None, files=None):
class Methods(Helper):
"""
Helper for Telegram API Methods listed on https://core.telegram.org/bots/api
List is updated to Bot API 5.5
"""
mode = HelperMode.lowerCamelCase

View file

@ -37,6 +37,7 @@ class BaseBot:
proxy_auth: Optional[aiohttp.BasicAuth] = None,
validate_token: Optional[base.Boolean] = True,
parse_mode: typing.Optional[base.String] = None,
disable_web_page_preview: Optional[base.Boolean] = None,
timeout: typing.Optional[typing.Union[base.Integer, base.Float, aiohttp.ClientTimeout]] = None,
server: TelegramAPIServer = TELEGRAM_PRODUCTION
):
@ -57,6 +58,8 @@ class BaseBot:
:type validate_token: :obj:`bool`
:param parse_mode: You can set default parse mode
:type parse_mode: :obj:`str`
:param disable_web_page_preview: You can set default disable web page preview parameter
:type disable_web_page_preview: :obj:`bool`
:param timeout: Request timeout
:type timeout: :obj:`typing.Optional[typing.Union[base.Integer, base.Float, aiohttp.ClientTimeout]]`
:param server: Telegram Bot API Server endpoint.
@ -107,6 +110,8 @@ class BaseBot:
self.parse_mode = parse_mode
self.disable_web_page_preview = disable_web_page_preview
async def get_new_session(self) -> aiohttp.ClientSession:
return aiohttp.ClientSession(
connector=self._connector_class(**self._connector_init),
@ -333,5 +338,22 @@ class BaseBot:
def parse_mode(self):
self.parse_mode = None
@property
def disable_web_page_preview(self):
return getattr(self, '_disable_web_page_preview', None)
@disable_web_page_preview.setter
def disable_web_page_preview(self, value):
if value is None:
setattr(self, '_disable_web_page_preview', None)
else:
if not isinstance(value, bool):
raise TypeError(f"Disable web page preview must be bool, not {type(value)}")
setattr(self, '_disable_web_page_preview', value)
@disable_web_page_preview.deleter
def disable_web_page_preview(self):
self.disable_web_page_preview = None
def check_auth_widget(self, data):
return check_integrity(self.__token, data)

View file

@ -270,6 +270,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
entities: typing.Optional[typing.List[types.MessageEntity]] = None,
disable_web_page_preview: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
@ -302,6 +303,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -323,26 +328,44 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
payload = generate_payload(**locals())
if self.parse_mode and entities is None:
payload.setdefault('parse_mode', self.parse_mode)
if self.disable_web_page_preview:
payload.setdefault('disable_web_page_preview', self.disable_web_page_preview)
result = await self.request(api.Methods.SEND_MESSAGE, payload)
return types.Message(**result)
async def forward_message(self, chat_id: typing.Union[base.Integer, base.String],
from_chat_id: typing.Union[base.Integer, base.String], message_id: base.Integer,
disable_notification: typing.Optional[base.Boolean] = None) -> types.Message:
async def forward_message(self,
chat_id: typing.Union[base.Integer, base.String],
from_chat_id: typing.Union[base.Integer, base.String],
message_id: base.Integer,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
) -> types.Message:
"""
Use this method to forward messages of any kind.
Source: https://core.telegram.org/bots/api#forwardmessage
:param chat_id: Unique identifier for the target chat or username of the target channel
:param chat_id: Unique identifier for the target chat or
username of the target channel
:type chat_id: :obj:`typing.Union[base.Integer, base.String]`
:param from_chat_id: Unique identifier for the chat where the original message was sent
:param from_chat_id: Unique identifier for the chat where the
original message was sent
:type from_chat_id: :obj:`typing.Union[base.Integer, base.String]`
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:param disable_notification: Sends the message silently. Users
will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param message_id: Message identifier in the chat specified in from_chat_id
:param protect_content: Protects the contents of the forwarded
message from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param message_id: Message identifier in the chat specified in
from_chat_id
:type message_id: :obj:`base.Integer`
:return: On success, the sent Message is returned
:rtype: :obj:`types.Message`
"""
@ -359,6 +382,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
@ -401,6 +425,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original
message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -422,7 +450,6 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
reply_markup = prepare_arg(reply_markup)
caption_entities = prepare_arg(caption_entities)
payload = generate_payload(**locals())
if self.parse_mode and caption_entities is None:
payload.setdefault('parse_mode', self.parse_mode)
@ -436,6 +463,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
@ -468,6 +496,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -506,6 +538,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
title: typing.Optional[base.String] = None,
thumb: typing.Union[base.InputFile, base.String, None] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
@ -553,6 +586,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -590,6 +627,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None,
disable_content_type_detection: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
@ -635,6 +673,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original
message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -677,12 +719,14 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None,
supports_streaming: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove,
types.ForceReply, None] = None) -> types.Message:
types.ForceReply, None] = None,
) -> types.Message:
"""
Use this method to send video files, Telegram clients support mp4 videos
(other formats may be sent as Document).
@ -724,6 +768,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -763,6 +811,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[typing.Union[types.InlineKeyboardMarkup,
@ -814,6 +863,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -850,6 +903,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
caption_entities: typing.Optional[typing.List[types.MessageEntity]] = None,
duration: typing.Optional[base.Integer] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
@ -889,6 +943,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -922,12 +980,14 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
length: typing.Optional[base.Integer] = None,
thumb: typing.Union[base.InputFile, base.String, None] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove,
types.ForceReply, None] = None) -> types.Message:
types.ForceReply, None] = None,
) -> types.Message:
"""
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
Use this method to send video messages.
@ -952,6 +1012,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -980,6 +1044,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
chat_id: typing.Union[base.Integer, base.String],
media: typing.Union[types.MediaGroup, typing.List],
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
) -> typing.List[types.Message]:
@ -1003,6 +1068,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the messages are a reply, ID of the original
message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -1037,12 +1106,14 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
heading: typing.Optional[base.Integer] = None,
proximity_alert_radius: typing.Optional[base.Integer] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove,
types.ForceReply, None] = None) -> types.Message:
types.ForceReply, None] = None,
) -> types.Message:
"""
Use this method to send point on the map.
@ -1076,6 +1147,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -1201,6 +1276,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
google_place_id: typing.Optional[base.String] = None,
google_place_type: typing.Optional[base.String] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
@ -1246,6 +1322,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original
message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -1275,12 +1355,14 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
last_name: typing.Optional[base.String] = None,
vcard: typing.Optional[base.String] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove,
types.ForceReply, None] = None) -> types.Message:
types.ForceReply, None] = None,
) -> types.Message:
"""
Use this method to send phone contacts.
@ -1304,6 +1386,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -1344,6 +1430,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
None] = None,
is_closed: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
@ -1411,6 +1498,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
a notification with no sound.
:type disable_notification: :obj:`typing.Optional[Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original
message
:type reply_to_message_id: :obj:`typing.Optional[Integer]`
@ -1443,6 +1534,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
async def send_dice(self,
chat_id: typing.Union[base.Integer, base.String],
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
emoji: typing.Optional[base.String] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
@ -1471,6 +1563,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -2543,6 +2639,8 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
payload = generate_payload(**locals())
if self.parse_mode and entities is None:
payload.setdefault('parse_mode', self.parse_mode)
if self.disable_web_page_preview:
payload.setdefault('disable_web_page_preview', self.disable_web_page_preview)
result = await self.request(api.Methods.EDIT_MESSAGE_TEXT, payload)
if isinstance(result, bool):
@ -2730,12 +2828,14 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
async def send_sticker(self, chat_id: typing.Union[base.Integer, base.String],
sticker: typing.Union[base.InputFile, base.String],
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup,
types.ReplyKeyboardRemove,
types.ForceReply, None] = None) -> types.Message:
types.ForceReply, None] = None,
) -> types.Message:
"""
Use this method to send .webp stickers.
@ -2750,6 +2850,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -2820,6 +2924,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
emojis: base.String,
png_sticker: typing.Union[base.InputFile, base.String] = None,
tgs_sticker: base.InputFile = None,
webm_sticker: base.InputFile = None,
contains_masks: typing.Optional[base.Boolean] = None,
mask_position: typing.Optional[types.MaskPosition] = None) -> base.Boolean:
"""
@ -2847,6 +2952,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param tgs_sticker: TGS animation with the sticker, uploaded using multipart/form-data.
See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
:type tgs_sticker: :obj:`base.InputFile`
:param webm_sticker: WEBM video with the sticker, uploaded using multipart/form-data.
See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements
:type webm_sticker: :obj:`base.InputFile`
:param emojis: One or more emoji corresponding to the sticker
:type emojis: :obj:`base.String`
:param contains_masks: Pass True, if a set of mask stickers should be created
@ -2857,11 +2965,12 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:rtype: :obj:`base.Boolean`
"""
mask_position = prepare_arg(mask_position)
payload = generate_payload(**locals(), exclude=['png_sticker', 'tgs_sticker'])
payload = generate_payload(**locals(), exclude=['png_sticker', 'tgs_sticker', 'webm_sticker'])
files = {}
prepare_file(payload, files, 'png_sticker', png_sticker)
prepare_file(payload, files, 'tgs_sticker', tgs_sticker)
prepare_file(payload, files, 'webm_sticker', webm_sticker)
return await self.request(api.Methods.CREATE_NEW_STICKER_SET, payload, files)
@ -2871,6 +2980,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
emojis: base.String,
png_sticker: typing.Union[base.InputFile, base.String] = None,
tgs_sticker: base.InputFile = None,
webm_sticker: base.InputFile = None,
mask_position: typing.Optional[types.MaskPosition] = None) -> base.Boolean:
"""
Use this method to add a new sticker to a set created by the bot.
@ -2894,6 +3004,9 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param tgs_sticker: TGS animation with the sticker, uploaded using multipart/form-data.
See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
:type tgs_sticker: :obj:`base.InputFile`
:param webm_sticker: WEBM video with the sticker, uploaded using multipart/form-data.
See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements
:type webm_sticker: :obj:`base.InputFile`
:param emojis: One or more emoji corresponding to the sticker
:type emojis: :obj:`base.String`
:param mask_position: A JSON-serialized object for position where the mask should be placed on faces
@ -2902,11 +3015,12 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:rtype: :obj:`base.Boolean`
"""
mask_position = prepare_arg(mask_position)
payload = generate_payload(**locals(), exclude=['png_sticker', 'tgs_sticker'])
payload = generate_payload(**locals(), exclude=['png_sticker', 'tgs_sticker', 'webm_sticker'])
files = {}
prepare_file(payload, files, 'png_sticker', png_sticker)
prepare_file(payload, files, 'tgs_sticker', tgs_sticker)
prepare_file(payload, files, 'webm_sticker', webm_sticker)
return await self.request(api.Methods.ADD_STICKER_TO_SET, payload, files)
@ -2958,10 +3072,12 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:type user_id: :obj:`base.Integer`
:param thumb: A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height
exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size;
see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical
requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers,
pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using
multipart/form-data. More info on https://core.telegram.org/bots/api#sending-files.
see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical
requirements, or a WEBM video with the thumbnail up to 32 kilobytes in size;
see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements.
Pass a file_id as a String to send a file that already exists on the Telegram servers,
pass an HTTP URL as a String for Telegram to get a file from the Internet,
or upload a new one using multipart/form-data. More info on https://core.telegram.org/bots/api#sending-files.
Animated sticker set thumbnail can't be uploaded via HTTP URL.
:type thumb: :obj:`typing.Union[base.InputFile, base.String]`
:return: Returns True on success
@ -3046,6 +3162,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
send_email_to_provider: typing.Optional[base.Boolean] = None,
is_flexible: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None,
@ -3145,6 +3262,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`
@ -3265,6 +3386,7 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
chat_id: base.Integer,
game_short_name: base.String,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Optional[types.InlineKeyboardMarkup] = None,
@ -3284,6 +3406,10 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_to_message_id: If the message is a reply, ID of the original message
:type reply_to_message_id: :obj:`typing.Optional[base.Integer]`

View file

@ -1,5 +1,4 @@
import copy
import weakref
from aiogram.dispatcher.middlewares import LifetimeControllerMiddleware
from aiogram.dispatcher.storage import FSMContext
@ -8,10 +7,6 @@ from aiogram.dispatcher.storage import FSMContext
class FSMMiddleware(LifetimeControllerMiddleware):
skip_patterns = ['error', 'update']
def __init__(self):
super(FSMMiddleware, self).__init__()
self._proxies = weakref.WeakKeyDictionary()
async def pre_process(self, obj, data, *args):
proxy = await FSMSStorageProxy.create(self.manager.dispatcher.current_state())
data['state_data'] = proxy

View file

@ -92,7 +92,7 @@ class LoggingMiddleware(BaseMiddleware):
text = (f"Received callback query [ID:{callback_query.id}] "
f"from user [ID:{callback_query.from_user.id}] "
f"for message [ID:{message.message_id}] "
f"in chat [{message.chat.type}:{message.chat.id}]"
f"in chat [{message.chat.type}:{message.chat.id}] "
f"with data: {callback_query.data}")
if message.from_user:

View file

@ -222,7 +222,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
"""
await self.bot.get_updates(offset=-1, timeout=1)
async def process_updates(self, updates, fast: typing.Optional[bool] = True):
async def process_updates(self, updates, fast: bool = True):
"""
Process list of updates
@ -337,7 +337,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
relax=0.1,
limit=None,
reset_webhook=None,
fast: typing.Optional[bool] = True,
fast: bool = True,
error_sleep: int = 5,
allowed_updates: typing.Optional[typing.List[str]] = None):
"""
@ -404,7 +404,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
self._close_waiter.set_result(None)
log.warning('Polling is stopped.')
async def _process_polling_updates(self, updates, fast: typing.Optional[bool] = True):
async def _process_polling_updates(self, updates, fast: bool = True):
"""
Process updates received from long-polling.
@ -949,7 +949,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
def register_poll_handler(self, callback, *custom_filters, run_task=None, **kwargs):
"""
Register handler for poll
Example:
.. code-block:: python3
@ -992,7 +992,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
def register_poll_answer_handler(self, callback, *custom_filters, run_task=None, **kwargs):
"""
Register handler for poll_answer
Example:
.. code-block:: python3

View file

@ -435,6 +435,18 @@ class DisableWebPagePreviewMixin:
setattr(self, 'disable_web_page_preview', True)
return self
@staticmethod
def _global_disable_web_page_preview():
"""
Detect global disable web page preview value
:return:
"""
from aiogram import Bot
bot = Bot.get_current()
if bot is not None:
return bot.disable_web_page_preview
class ParseModeMixin:
def as_html(self):
@ -506,6 +518,8 @@ class SendMessage(BaseResponse, ReplyToMixin, ParseModeMixin, DisableNotificatio
text = ''
if parse_mode is None:
parse_mode = self._global_parse_mode()
if disable_web_page_preview is None:
disable_web_page_preview = self._global_disable_web_page_preview()
self.chat_id = chat_id
self.text = text
@ -1591,6 +1605,8 @@ class EditMessageText(BaseResponse, ParseModeMixin, DisableWebPagePreviewMixin):
"""
if parse_mode is None:
parse_mode = self._global_parse_mode()
if disable_web_page_preview is None:
disable_web_page_preview = self._global_disable_web_page_preview()
self.chat_id = chat_id
self.message_id = message_id

View file

@ -211,6 +211,15 @@ class TelegramObject(ContextInstanceMixin, metaclass=MetaTelegramObject):
"""
return self.as_json()
def __repr__(self) -> str:
"""
Return object readable representation.
Example: <ObjectName {"id": 123456}>
:return: object class name and object data as a string
"""
return f"<{type(self).__name__} {self}>"
def __getitem__(self, item: typing.Union[str, int]) -> typing.Any:
"""
Item getter (by key)

View file

@ -11,7 +11,7 @@ class ChatJoinRequest(base.TelegramObject):
"""
Represents a join request sent to a chat.
https://core.telegram.org/bots/api#chatinvitelink
https://core.telegram.org/bots/api#chatjoinrequest
"""
chat: Chat = fields.Field(base=Chat)

View file

@ -154,6 +154,12 @@ class InputTextMessageContent(InputMessageContent):
except RuntimeError:
pass
def safe_get_disable_web_page_preview(self):
try:
return self.bot.disable_web_page_preview
except RuntimeError:
pass
def __init__(
self,
message_text: base.String,
@ -163,6 +169,8 @@ class InputTextMessageContent(InputMessageContent):
):
if parse_mode is None:
parse_mode = self.safe_get_parse_mode()
if disable_web_page_preview is None:
disable_web_page_preview = self.safe_get_disable_web_page_preview()
super().__init__(
message_text=message_text,

View file

@ -315,6 +315,7 @@ class Message(base.TelegramObject):
entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_web_page_preview: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -345,6 +346,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -367,6 +372,7 @@ class Message(base.TelegramObject):
entities=entities,
disable_web_page_preview=disable_web_page_preview,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -379,6 +385,7 @@ class Message(base.TelegramObject):
parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -411,6 +418,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -433,6 +444,7 @@ class Message(base.TelegramObject):
parse_mode=parse_mode,
caption_entities=caption_entities,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -449,6 +461,7 @@ class Message(base.TelegramObject):
title: typing.Optional[base.String] = None,
thumb: typing.Union[typing.Union[base.InputFile, base.String], None] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -497,6 +510,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -523,6 +540,7 @@ class Message(base.TelegramObject):
title=title,
thumb=thumb,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -539,6 +557,7 @@ class Message(base.TelegramObject):
parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -589,6 +608,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -615,6 +638,7 @@ class Message(base.TelegramObject):
parse_mode=parse_mode,
caption_entities=caption_entities,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -629,6 +653,7 @@ class Message(base.TelegramObject):
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_content_type_detection: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -672,6 +697,10 @@ class Message(base.TelegramObject):
notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -698,6 +727,7 @@ class Message(base.TelegramObject):
caption_entities=caption_entities,
disable_content_type_detection=disable_content_type_detection,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -715,6 +745,7 @@ class Message(base.TelegramObject):
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
supports_streaming: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -764,6 +795,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -791,6 +826,7 @@ class Message(base.TelegramObject):
caption_entities=caption_entities,
supports_streaming=supports_streaming,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -804,6 +840,7 @@ class Message(base.TelegramObject):
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
duration: typing.Optional[base.Integer] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -843,6 +880,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -866,6 +907,7 @@ class Message(base.TelegramObject):
caption_entities=caption_entities,
duration=duration,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -878,6 +920,7 @@ class Message(base.TelegramObject):
length: typing.Optional[base.Integer] = None,
thumb: typing.Union[typing.Union[base.InputFile, base.String], None] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -910,6 +953,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -932,6 +979,7 @@ class Message(base.TelegramObject):
length=length,
thumb=thumb,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -941,6 +989,7 @@ class Message(base.TelegramObject):
self,
media: typing.Union[MediaGroup, typing.List],
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply: base.Boolean = False,
) -> typing.List[Message]:
@ -959,6 +1008,10 @@ class Message(base.TelegramObject):
a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -973,6 +1026,7 @@ class Message(base.TelegramObject):
self.chat.id,
media=media,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
)
@ -983,6 +1037,7 @@ class Message(base.TelegramObject):
longitude: base.Float,
live_period: typing.Optional[base.Integer] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
horizontal_accuracy: typing.Optional[base.Float] = None,
heading: typing.Optional[base.Integer] = None,
@ -1026,6 +1081,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1050,6 +1109,7 @@ class Message(base.TelegramObject):
heading=heading,
proximity_alert_radius=proximity_alert_radius,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1066,6 +1126,7 @@ class Message(base.TelegramObject):
google_place_id: typing.Optional[base.String] = None,
google_place_type: typing.Optional[base.String] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1110,6 +1171,10 @@ class Message(base.TelegramObject):
a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1138,6 +1203,7 @@ class Message(base.TelegramObject):
google_place_id=google_place_id,
google_place_type=google_place_type,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1149,6 +1215,7 @@ class Message(base.TelegramObject):
first_name: base.String,
last_name: typing.Optional[base.String] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1176,6 +1243,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1197,6 +1268,7 @@ class Message(base.TelegramObject):
first_name=first_name,
last_name=last_name,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1206,6 +1278,7 @@ class Message(base.TelegramObject):
self,
sticker: typing.Union[base.InputFile, base.String],
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1227,6 +1300,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1246,6 +1323,7 @@ class Message(base.TelegramObject):
chat_id=self.chat.id,
sticker=sticker,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1266,6 +1344,7 @@ class Message(base.TelegramObject):
close_date: typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None] = None,
is_closed: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1332,6 +1411,10 @@ class Message(base.TelegramObject):
a notification with no sound.
:type disable_notification: :obj:`typing.Optional[Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1364,6 +1447,7 @@ class Message(base.TelegramObject):
close_date=close_date,
is_closed=is_closed,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1373,6 +1457,7 @@ class Message(base.TelegramObject):
self,
emoji: typing.Optional[base.String] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1399,6 +1484,10 @@ class Message(base.TelegramObject):
a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1420,6 +1509,7 @@ class Message(base.TelegramObject):
chat_id=self.chat.id,
emoji=emoji,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1456,6 +1546,7 @@ class Message(base.TelegramObject):
entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_web_page_preview: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1486,6 +1577,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1508,6 +1603,7 @@ class Message(base.TelegramObject):
entities=entities,
disable_web_page_preview=disable_web_page_preview,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1520,6 +1616,7 @@ class Message(base.TelegramObject):
parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1552,6 +1649,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1574,6 +1675,7 @@ class Message(base.TelegramObject):
parse_mode=parse_mode,
caption_entities=caption_entities,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1590,6 +1692,7 @@ class Message(base.TelegramObject):
title: typing.Optional[base.String] = None,
thumb: typing.Union[typing.Union[base.InputFile, base.String], None] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1638,6 +1741,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1664,6 +1771,7 @@ class Message(base.TelegramObject):
title=title,
thumb=thumb,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1680,6 +1788,7 @@ class Message(base.TelegramObject):
parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1730,6 +1839,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1756,6 +1869,7 @@ class Message(base.TelegramObject):
parse_mode=parse_mode,
caption_entities=caption_entities,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1770,6 +1884,7 @@ class Message(base.TelegramObject):
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_content_type_detection: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1813,6 +1928,10 @@ class Message(base.TelegramObject):
notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1839,6 +1958,7 @@ class Message(base.TelegramObject):
caption_entities=caption_entities,
disable_content_type_detection=disable_content_type_detection,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1856,6 +1976,7 @@ class Message(base.TelegramObject):
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
supports_streaming: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1905,6 +2026,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -1932,6 +2057,7 @@ class Message(base.TelegramObject):
caption_entities=caption_entities,
supports_streaming=supports_streaming,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -1945,6 +2071,7 @@ class Message(base.TelegramObject):
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
duration: typing.Optional[base.Integer] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -1984,6 +2111,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -2007,6 +2138,7 @@ class Message(base.TelegramObject):
caption_entities=caption_entities,
duration=duration,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -2019,6 +2151,7 @@ class Message(base.TelegramObject):
length: typing.Optional[base.Integer] = None,
thumb: typing.Union[typing.Union[base.InputFile, base.String], None] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -2051,6 +2184,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -2073,6 +2210,7 @@ class Message(base.TelegramObject):
length=length,
thumb=thumb,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -2082,6 +2220,7 @@ class Message(base.TelegramObject):
self,
media: typing.Union[MediaGroup, typing.List],
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply: base.Boolean = True,
) -> typing.List[Message]:
@ -2100,6 +2239,10 @@ class Message(base.TelegramObject):
a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -2114,6 +2257,7 @@ class Message(base.TelegramObject):
self.chat.id,
media=media,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
)
@ -2124,6 +2268,7 @@ class Message(base.TelegramObject):
longitude: base.Float,
live_period: typing.Optional[base.Integer] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
horizontal_accuracy: typing.Optional[base.Float] = None,
heading: typing.Optional[base.Integer] = None,
proximity_alert_radius: typing.Optional[base.Integer] = None,
@ -2166,6 +2311,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard,
custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user
:type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup,
@ -2186,6 +2335,7 @@ class Message(base.TelegramObject):
heading=heading,
proximity_alert_radius=proximity_alert_radius,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
reply_markup=reply_markup,
)
@ -2201,6 +2351,7 @@ class Message(base.TelegramObject):
google_place_id: typing.Optional[base.String] = None,
google_place_type: typing.Optional[base.String] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -2245,6 +2396,10 @@ class Message(base.TelegramObject):
a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -2273,6 +2428,7 @@ class Message(base.TelegramObject):
google_place_id=google_place_id,
google_place_type=google_place_type,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -2284,6 +2440,7 @@ class Message(base.TelegramObject):
first_name: base.String,
last_name: typing.Optional[base.String] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -2311,6 +2468,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -2332,6 +2493,7 @@ class Message(base.TelegramObject):
first_name=first_name,
last_name=last_name,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -2352,6 +2514,7 @@ class Message(base.TelegramObject):
close_date: typing.Union[base.Integer, datetime.datetime, datetime.timedelta, None] = None,
is_closed: typing.Optional[base.Boolean] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -2418,6 +2581,10 @@ class Message(base.TelegramObject):
a notification with no sound.
:type disable_notification: :obj:`typing.Optional[Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -2450,6 +2617,7 @@ class Message(base.TelegramObject):
close_date=close_date,
is_closed=is_closed,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -2459,6 +2627,7 @@ class Message(base.TelegramObject):
self,
sticker: typing.Union[base.InputFile, base.String],
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -2480,6 +2649,10 @@ class Message(base.TelegramObject):
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -2499,6 +2672,7 @@ class Message(base.TelegramObject):
chat_id=self.chat.id,
sticker=sticker,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -2508,6 +2682,7 @@ class Message(base.TelegramObject):
self,
emoji: typing.Optional[base.String] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[
InlineKeyboardMarkup,
@ -2534,6 +2709,10 @@ class Message(base.TelegramObject):
a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of sent messages
from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:param allow_sending_without_reply: Pass True, if the message should be sent
even if the specified replied-to message is not found
:type allow_sending_without_reply: :obj:`typing.Optional[base.Boolean]`
@ -2555,6 +2734,7 @@ class Message(base.TelegramObject):
chat_id=self.chat.id,
emoji=emoji,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=self.message_id if reply else None,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
@ -2564,6 +2744,7 @@ class Message(base.TelegramObject):
self,
chat_id: typing.Union[base.Integer, base.String],
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
) -> Message:
"""
Forward this message
@ -2572,13 +2753,23 @@ class Message(base.TelegramObject):
:param chat_id: Unique identifier for the target chat or username of the target channel
:type chat_id: :obj:`typing.Union[base.Integer, base.String]`
:param disable_notification: Sends the message silently. Users will receive a notification with no sound
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
:param protect_content: Protects the contents of the forwarded
message from forwarding and saving
:type protect_content: :obj:`typing.Optional[base.Boolean]`
:return: On success, the sent Message is returned
:rtype: :obj:`types.Message`
"""
return await self.bot.forward_message(
chat_id, self.chat.id, self.message_id, disable_notification
chat_id=chat_id,
from_chat_id=self.chat.id,
message_id=self.message_id,
disable_notification=disable_notification,
protect_content=protect_content,
)
async def edit_text(
@ -2795,7 +2986,8 @@ class Message(base.TelegramObject):
return await self.bot.delete_message(self.chat.id, self.message_id)
async def pin(
self, disable_notification: typing.Optional[base.Boolean] = None,
self,
disable_notification: typing.Optional[base.Boolean] = None,
) -> base.Boolean:
"""
Use this method to add a message to the list of pinned messages in a chat.
@ -2813,7 +3005,10 @@ class Message(base.TelegramObject):
:return: Returns True on success
:rtype: :obj:`base.Boolean`
"""
return await self.chat.pin_message(self.message_id, disable_notification)
return await self.chat.pin_message(
message_id=self.message_id,
disable_notification=disable_notification,
)
async def unpin(self) -> base.Boolean:
"""
@ -2836,6 +3031,7 @@ class Message(base.TelegramObject):
self: Message,
chat_id: typing.Union[str, int],
disable_notification: typing.Optional[bool] = None,
protect_content: typing.Optional[base.Boolean] = None,
disable_web_page_preview: typing.Optional[bool] = None,
reply_to_message_id: typing.Optional[int] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
@ -2848,6 +3044,7 @@ class Message(base.TelegramObject):
:param chat_id:
:param disable_notification:
:param protect_content:
:param disable_web_page_preview: for text messages only
:param reply_to_message_id:
:param allow_sending_without_reply:
@ -2860,6 +3057,7 @@ class Message(base.TelegramObject):
"reply_markup": reply_markup or self.reply_markup,
"parse_mode": ParseMode.HTML,
"disable_notification": disable_notification,
"protect_content": protect_content,
"reply_to_message_id": reply_to_message_id,
}
text = self.html_text if (self.text or self.caption) else None
@ -2956,6 +3154,7 @@ class Message(base.TelegramObject):
parse_mode: typing.Optional[base.String] = None,
caption_entities: typing.Optional[typing.List[MessageEntity]] = None,
disable_notification: typing.Optional[base.Boolean] = None,
protect_content: typing.Optional[base.Boolean] = None,
reply_to_message_id: typing.Optional[base.Integer] = None,
allow_sending_without_reply: typing.Optional[base.Boolean] = None,
reply_markup: typing.Union[InlineKeyboardMarkup,
@ -2971,6 +3170,7 @@ class Message(base.TelegramObject):
parse_mode=parse_mode,
caption_entities=caption_entities,
disable_notification=disable_notification,
protect_content=protect_content,
reply_to_message_id=reply_to_message_id,
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup

View file

@ -77,6 +77,9 @@ class MessageEntity(base.TelegramObject):
if self.type == MessageEntityType.ITALIC:
method = markdown.hitalic if as_html else markdown.italic
return method(entity_text)
if self.type == MessageEntityType.SPOILER:
method = markdown.spoiler if as_html else markdown.hspoiler
return method(entity_text)
if self.type == MessageEntityType.PRE:
method = markdown.hpre if as_html else markdown.pre
return method(entity_text)
@ -108,10 +111,11 @@ class MessageEntityType(helper.Helper):
:key: PHONE_NUMBER
:key: BOLD
:key: ITALIC
:key: CODE
:key: PRE
:key: UNDERLINE
:key: STRIKETHROUGH
:key: SPOILER
:key: CODE
:key: PRE
:key: TEXT_LINK
:key: TEXT_MENTION
"""
@ -127,9 +131,10 @@ class MessageEntityType(helper.Helper):
PHONE_NUMBER = helper.Item() # phone_number
BOLD = helper.Item() # bold - bold text
ITALIC = helper.Item() # italic - italic text
CODE = helper.Item() # code - monowidth string
PRE = helper.Item() # pre - monowidth block
UNDERLINE = helper.Item() # underline
STRIKETHROUGH = helper.Item() # strikethrough
SPOILER = helper.Item() # spoiler
CODE = helper.Item() # code - monowidth string
PRE = helper.Item() # pre - monowidth block
TEXT_LINK = helper.Item() # text_link - for clickable text URLs
TEXT_MENTION = helper.Item() # text_mention - for users without usernames

View file

@ -16,6 +16,7 @@ class Sticker(base.TelegramObject, mixins.Downloadable):
width: base.Integer = fields.Field()
height: base.Integer = fields.Field()
is_animated: base.Boolean = fields.Field()
is_video: base.Boolean = fields.Field()
thumb: PhotoSize = fields.Field(base=PhotoSize)
emoji: base.String = fields.Field()
set_name: base.String = fields.Field()

View file

@ -15,6 +15,7 @@ class StickerSet(base.TelegramObject):
name: base.String = fields.Field()
title: base.String = fields.Field()
is_animated: base.Boolean = fields.Field()
is_video: base.Boolean = fields.Field()
contains_masks: base.Boolean = fields.Field()
stickers: typing.List[Sticker] = fields.ListField(base=Sticker)
thumb: PhotoSize = fields.Field(base=PhotoSize)

View file

@ -7,10 +7,13 @@ MD_SYMBOLS = (
(LIST_MD_SYMBOLS[1], LIST_MD_SYMBOLS[1]),
(LIST_MD_SYMBOLS[2], LIST_MD_SYMBOLS[2]),
(LIST_MD_SYMBOLS[2] * 3 + "\n", "\n" + LIST_MD_SYMBOLS[2] * 3),
("||", "||"),
("<b>", "</b>"),
("<i>", "</i>"),
("<code>", "</code>"),
("<pre>", "</pre>"),
('<span class="tg-spoiler">', "</span>"),
("<tg-spoiler>", "</tg-spoiler>"),
)
HTML_QUOTES_MAP = {"<": "&lt;", ">": "&gt;", "&": "&amp;", '"': "&quot;"}
@ -113,6 +116,32 @@ def hitalic(*content, sep=" ") -> str:
)
def spoiler(*content, sep=" ") -> str:
"""
Make spoiler text (Markdown)
:param content:
:param sep:
:return:
"""
return markdown_decoration.spoiler(
value=markdown_decoration.quote(_join(*content, sep=sep))
)
def hspoiler(*content, sep=" ") -> str:
"""
Make spoiler text (HTML)
:param content:
:param sep:
:return:
"""
return html_decoration.spoiler(
value=html_decoration.quote(_join(*content, sep=sep))
)
def code(*content, sep=" ") -> str:
"""
Make mono-width text (Markdown)

View file

@ -27,9 +27,9 @@ class TextDecoration(ABC):
:return:
"""
if entity.type in {"bot_command", "url", "mention", "phone_number"}:
# This entities should not be changed
# These entities should not be changed
return text
if entity.type in {"bold", "italic", "code", "underline", "strikethrough"}:
if entity.type in {"bold", "italic", "spoiler", "code", "underline", "strikethrough"}:
return cast(str, getattr(self, entity.type)(value=text))
if entity.type == "pre":
return (
@ -115,6 +115,10 @@ class TextDecoration(ABC):
def italic(self, value: str) -> str: # pragma: no cover
pass
@abstractmethod
def spoiler(self, value: str) -> str: # pragma: no cover
pass
@abstractmethod
def code(self, value: str) -> str: # pragma: no cover
pass
@ -150,6 +154,9 @@ class HtmlDecoration(TextDecoration):
def italic(self, value: str) -> str:
return f"<i>{value}</i>"
def spoiler(self, value: str) -> str:
return f'<span class="tg-spoiler">{value}</span>'
def code(self, value: str) -> str:
return f"<code>{value}</code>"
@ -181,6 +188,9 @@ class MarkdownDecoration(TextDecoration):
def italic(self, value: str) -> str:
return f"_\r{value}_\r"
def spoiler(self, value: str) -> str:
return f"||{value}||"
def code(self, value: str) -> str:
return f"`{value}`"

View file

@ -22,7 +22,7 @@ Welcome to aiogram's documentation!
:target: https://pypi.python.org/pypi/aiogram
:alt: Supported python versions
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.5-blue.svg?style=flat-square&logo=telegram
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.7-blue.svg?style=flat-square&logo=telegram
:target: https://core.telegram.org/bots/api
:alt: Telegram Bot API

View file

@ -7,7 +7,9 @@ from aiogram.dispatcher.webhook import configure_app
from aiohttp import web
bot = Bot(token=config.bot_token)
API_TOKEN = "BOT_TOKEN_HERE"
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)