From be473d46010f005c848b5f23f31729f207e86f65 Mon Sep 17 00:00:00 2001
From: KurimuzonAkuma <31959970+KurimuzonAkuma@users.noreply.github.com>
Date: Mon, 30 Oct 2023 13:35:16 +0300
Subject: [PATCH] Add quote support
---
pyrogram/methods/bots/send_game.py | 5 +-
.../methods/bots/send_inline_bot_result.py | 28 +-
pyrogram/methods/messages/send_animation.py | 19 +-
pyrogram/methods/messages/send_audio.py | 19 +-
.../methods/messages/send_cached_media.py | 22 +-
pyrogram/methods/messages/send_contact.py | 28 +-
pyrogram/methods/messages/send_dice.py | 30 ++-
pyrogram/methods/messages/send_document.py | 19 +-
pyrogram/methods/messages/send_location.py | 28 +-
pyrogram/methods/messages/send_media_group.py | 27 +-
pyrogram/methods/messages/send_message.py | 18 +-
pyrogram/methods/messages/send_photo.py | 19 +-
pyrogram/methods/messages/send_poll.py | 23 +-
pyrogram/methods/messages/send_sticker.py | 27 +-
pyrogram/methods/messages/send_venue.py | 26 +-
pyrogram/methods/messages/send_video.py | 19 +-
pyrogram/methods/messages/send_video_note.py | 27 +-
pyrogram/methods/messages/send_voice.py | 18 +-
pyrogram/methods/stories/forward_story.py | 4 +-
pyrogram/types/messages_and_media/message.py | 247 +++++++++++++++++-
pyrogram/utils.py | 12 +-
21 files changed, 620 insertions(+), 45 deletions(-)
diff --git a/pyrogram/methods/bots/send_game.py b/pyrogram/methods/bots/send_game.py
index c2515b74..af2e2dea 100644
--- a/pyrogram/methods/bots/send_game.py
+++ b/pyrogram/methods/bots/send_game.py
@@ -90,7 +90,10 @@ class SendGame:
),
message="",
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id
+ ),
random_id=self.rnd_id(),
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None
diff --git a/pyrogram/methods/bots/send_inline_bot_result.py b/pyrogram/methods/bots/send_inline_bot_result.py
index 135edc4f..de81bbe2 100644
--- a/pyrogram/methods/bots/send_inline_bot_result.py
+++ b/pyrogram/methods/bots/send_inline_bot_result.py
@@ -16,10 +16,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from typing import Union
+from typing import Union, List, Optional
import pyrogram
-from pyrogram import raw
+from pyrogram import raw, enums, types
from pyrogram import utils
@@ -31,7 +31,10 @@ class SendInlineBotResult:
result_id: str,
disable_notification: bool = None,
message_thread_id: int = None,
- reply_to_message_id: int = None
+ reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None
) -> "raw.base.Updates":
"""Send an inline bot result.
Bot results can be retrieved using :meth:`~pyrogram.Client.get_inline_bot_results`
@@ -61,6 +64,16 @@ class SendInlineBotResult:
reply_to_message_id (``bool``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
Returns:
:obj:`~pyrogram.raw.base.Updates`: Currently, on success, a raw result is returned.
@@ -69,6 +82,8 @@ class SendInlineBotResult:
await app.send_inline_bot_result(chat_id, query_id, result_id)
"""
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
return await self.invoke(
raw.functions.messages.SendInlineBotResult(
peer=await self.resolve_peer(chat_id),
@@ -76,6 +91,11 @@ class SendInlineBotResult:
id=result_id,
random_id=self.rnd_id(),
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id)
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities
+ )
)
)
diff --git a/pyrogram/methods/messages/send_animation.py b/pyrogram/methods/messages/send_animation.py
index a5f4a7e6..8c857f12 100644
--- a/pyrogram/methods/messages/send_animation.py
+++ b/pyrogram/methods/messages/send_animation.py
@@ -49,6 +49,8 @@ class SendAnimation:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -127,6 +129,12 @@ class SendAnimation:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -232,6 +240,8 @@ class SendAnimation:
]
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
while True:
try:
peer = await self.resolve_peer(chat_id)
@@ -240,7 +250,14 @@ class SendAnimation:
peer=peer,
media=media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_audio.py b/pyrogram/methods/messages/send_audio.py
index ab814ef4..3fc98ad7 100644
--- a/pyrogram/methods/messages/send_audio.py
+++ b/pyrogram/methods/messages/send_audio.py
@@ -47,6 +47,8 @@ class SendAudio:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -120,6 +122,12 @@ class SendAudio:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -219,6 +227,8 @@ class SendAudio:
]
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
while True:
try:
peer = await self.resolve_peer(chat_id)
@@ -227,7 +237,14 @@ class SendAudio:
peer=peer,
media=media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_cached_media.py b/pyrogram/methods/messages/send_cached_media.py
index b19df49a..af458c9b 100644
--- a/pyrogram/methods/messages/send_cached_media.py
+++ b/pyrogram/methods/messages/send_cached_media.py
@@ -20,8 +20,7 @@ from datetime import datetime
from typing import Union, List, Optional
import pyrogram
-from pyrogram import raw, enums
-from pyrogram import types
+from pyrogram import raw, enums, types
from pyrogram import utils
@@ -37,6 +36,8 @@ class SendCachedMedia:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
invert_media: bool = None,
@@ -89,6 +90,12 @@ class SendCachedMedia:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -110,6 +117,8 @@ class SendCachedMedia:
await app.send_cached_media("me", file_id)
"""
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
peer = await self.resolve_peer(chat_id)
r = await self.invoke(
raw.functions.messages.SendMedia(
@@ -117,7 +126,14 @@ class SendCachedMedia:
media=utils.get_input_media_from_file_id(file_id),
silent=disable_notification or None,
invert_media=invert_media,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_contact.py b/pyrogram/methods/messages/send_contact.py
index 0cfcb202..2bac3b8f 100644
--- a/pyrogram/methods/messages/send_contact.py
+++ b/pyrogram/methods/messages/send_contact.py
@@ -17,10 +17,12 @@
# along with Pyrogram. If not, see .
from datetime import datetime
-from typing import Union
+from typing import Union, List, Optional
import pyrogram
-from pyrogram import raw, utils
+from pyrogram import raw
+from pyrogram import utils
+from pyrogram import enums
from pyrogram import types
@@ -35,6 +37,9 @@ class SendContact:
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -77,6 +82,16 @@ class SendContact:
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -95,6 +110,8 @@ class SendContact:
await app.send_contact("me", "+1-123-456-7890", "Name")
"""
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
@@ -106,7 +123,12 @@ class SendContact:
),
message="",
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_dice.py b/pyrogram/methods/messages/send_dice.py
index 63bf8c6d..2445af11 100644
--- a/pyrogram/methods/messages/send_dice.py
+++ b/pyrogram/methods/messages/send_dice.py
@@ -17,11 +17,11 @@
# along with Pyrogram. If not, see .
from datetime import datetime
-from typing import Union, Optional
+from typing import Union, List, Optional
import pyrogram
-from pyrogram import raw, utils
-from pyrogram import types
+from pyrogram import raw, enums, types
+from pyrogram import utils
class SendDice:
@@ -33,6 +33,9 @@ class SendDice:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -73,6 +76,16 @@ class SendDice:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -98,13 +111,22 @@ class SendDice:
# Send a basketball
await app.send_dice(chat_id, "🏀")
"""
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
peer = await self.resolve_peer(chat_id)
r = await self.invoke(
raw.functions.messages.SendMedia(
peer=peer,
media=raw.types.InputMediaDice(emoticon=emoji),
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_document.py b/pyrogram/methods/messages/send_document.py
index 8685d75e..f4275fa0 100644
--- a/pyrogram/methods/messages/send_document.py
+++ b/pyrogram/methods/messages/send_document.py
@@ -45,6 +45,8 @@ class SendDocument:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -112,6 +114,12 @@ class SendDocument:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -197,6 +205,8 @@ class SendDocument:
]
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
while True:
try:
peer = await self.resolve_peer(chat_id)
@@ -205,7 +215,14 @@ class SendDocument:
peer=peer,
media=media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_location.py b/pyrogram/methods/messages/send_location.py
index 9aadd951..8d2ddd0a 100644
--- a/pyrogram/methods/messages/send_location.py
+++ b/pyrogram/methods/messages/send_location.py
@@ -17,11 +17,11 @@
# along with Pyrogram. If not, see .
from datetime import datetime
-from typing import Union
+from typing import Optional, List, Union
import pyrogram
-from pyrogram import raw, utils
-from pyrogram import types
+from pyrogram import raw, enums, types
+from pyrogram import utils
class SendLocation:
@@ -33,6 +33,9 @@ class SendLocation:
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -69,6 +72,16 @@ class SendLocation:
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -87,6 +100,8 @@ class SendLocation:
app.send_location("me", latitude, longitude)
"""
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
@@ -98,7 +113,12 @@ class SendLocation:
),
message="",
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_media_group.py b/pyrogram/methods/messages/send_media_group.py
index a1b18fe0..5abf4a39 100644
--- a/pyrogram/methods/messages/send_media_group.py
+++ b/pyrogram/methods/messages/send_media_group.py
@@ -20,12 +20,13 @@ import logging
import os
import re
from datetime import datetime
-from typing import Union, List
+from typing import Union, List, Optional
import pyrogram
from pyrogram import raw
from pyrogram import types
from pyrogram import utils
+from pyrogram import enums
from pyrogram.file_id import FileType
log = logging.getLogger(__name__)
@@ -46,6 +47,9 @@ class SendMediaGroup:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
invert_media: bool = None,
@@ -77,6 +81,16 @@ class SendMediaGroup:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -403,13 +417,22 @@ class SendMediaGroup:
)
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
peer = await self.resolve_peer(chat_id)
r = await self.invoke(
raw.functions.messages.SendMultiMedia(
peer=peer,
multi_media=multi_media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
invert_media=invert_media
diff --git a/pyrogram/methods/messages/send_message.py b/pyrogram/methods/messages/send_message.py
index 0bdb73f9..70779aae 100644
--- a/pyrogram/methods/messages/send_message.py
+++ b/pyrogram/methods/messages/send_message.py
@@ -36,6 +36,8 @@ class SendMessage:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -82,6 +84,12 @@ class SendMessage:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -131,6 +139,7 @@ class SendMessage:
"""
message, entities = (await utils.parse_text_entities(self, text, parse_mode, entities)).values()
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
peer = await self.resolve_peer(chat_id)
r = await self.invoke(
@@ -138,7 +147,14 @@ class SendMessage:
peer=peer,
no_webpage=disable_web_page_preview or None,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
reply_markup=await reply_markup.write(self) if reply_markup else None,
diff --git a/pyrogram/methods/messages/send_photo.py b/pyrogram/methods/messages/send_photo.py
index 9688d54d..54c70dd7 100644
--- a/pyrogram/methods/messages/send_photo.py
+++ b/pyrogram/methods/messages/send_photo.py
@@ -43,6 +43,8 @@ class SendPhoto:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -103,6 +105,12 @@ class SendPhoto:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -181,6 +189,8 @@ class SendPhoto:
spoiler=has_spoiler
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
while True:
try:
peer = await self.resolve_peer(chat_id)
@@ -189,7 +199,14 @@ class SendPhoto:
peer=peer,
media=media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_poll.py b/pyrogram/methods/messages/send_poll.py
index e32d66d3..71dc509b 100644
--- a/pyrogram/methods/messages/send_poll.py
+++ b/pyrogram/methods/messages/send_poll.py
@@ -17,7 +17,7 @@
# along with Pyrogram. If not, see .
from datetime import datetime
-from typing import Union, List
+from typing import Union, List, Optional
import pyrogram
from pyrogram import raw, utils
@@ -44,6 +44,9 @@ class SendPoll:
protect_content: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
@@ -122,6 +125,16 @@ class SendPoll:
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -140,6 +153,7 @@ class SendPoll:
solution, solution_entities = (await utils.parse_text_entities(
self, explanation, explanation_parse_mode, explanation_entities
)).values()
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
r = await self.invoke(
raw.functions.messages.SendMedia(
@@ -165,7 +179,12 @@ class SendPoll:
),
message="",
silent=disable_notification,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_sticker.py b/pyrogram/methods/messages/send_sticker.py
index fe83085c..f4468c05 100644
--- a/pyrogram/methods/messages/send_sticker.py
+++ b/pyrogram/methods/messages/send_sticker.py
@@ -19,13 +19,14 @@
import os
import re
from datetime import datetime
-from typing import Union, BinaryIO, Optional, Callable
+from typing import Union, BinaryIO, Optional, Callable, List
import pyrogram
from pyrogram import StopTransmission
from pyrogram import raw
from pyrogram import types
from pyrogram import utils
+from pyrogram import enums
from pyrogram.errors import FilePartMissing
from pyrogram.file_id import FileType
@@ -39,6 +40,9 @@ class SendSticker:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -81,6 +85,16 @@ class SendSticker:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -156,6 +170,8 @@ class SendSticker:
]
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
while True:
try:
peer = await self.resolve_peer(chat_id)
@@ -164,7 +180,14 @@ class SendSticker:
peer=peer,
media=media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_venue.py b/pyrogram/methods/messages/send_venue.py
index 9f00ac36..2194bdfe 100644
--- a/pyrogram/methods/messages/send_venue.py
+++ b/pyrogram/methods/messages/send_venue.py
@@ -17,11 +17,11 @@
# along with Pyrogram. If not, see .
from datetime import datetime
-from typing import Union
+from typing import Union, List, Optional
import pyrogram
from pyrogram import raw, utils
-from pyrogram import types
+from pyrogram import types, enums
class SendVenue:
@@ -37,6 +37,9 @@ class SendVenue:
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -86,6 +89,16 @@ class SendVenue:
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -106,6 +119,8 @@ class SendVenue:
"me", latitude, longitude,
"Venue title", "Venue address")
"""
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
r = await self.invoke(
raw.functions.messages.SendMedia(
peer=await self.resolve_peer(chat_id),
@@ -122,7 +137,12 @@ class SendVenue:
),
message="",
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_video.py b/pyrogram/methods/messages/send_video.py
index 041e0d70..e4261382 100644
--- a/pyrogram/methods/messages/send_video.py
+++ b/pyrogram/methods/messages/send_video.py
@@ -50,6 +50,8 @@ class SendVideo:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -133,6 +135,12 @@ class SendVideo:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -238,6 +246,8 @@ class SendVideo:
]
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
while True:
try:
peer = await self.resolve_peer(chat_id)
@@ -246,7 +256,14 @@ class SendVideo:
peer=peer,
media=media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_video_note.py b/pyrogram/methods/messages/send_video_note.py
index 54c924af..e9aaaeed 100644
--- a/pyrogram/methods/messages/send_video_note.py
+++ b/pyrogram/methods/messages/send_video_note.py
@@ -18,13 +18,14 @@
import os
from datetime import datetime
-from typing import Union, BinaryIO, Optional, Callable
+from typing import Union, BinaryIO, Optional, Callable, List
import pyrogram
from pyrogram import StopTransmission
from pyrogram import raw
from pyrogram import types
from pyrogram import utils
+from pyrogram import enums
from pyrogram.errors import FilePartMissing
from pyrogram.file_id import FileType
@@ -41,6 +42,9 @@ class SendVideoNote:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -95,6 +99,16 @@ class SendVideoNote:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -180,6 +194,8 @@ class SendVideoNote:
]
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
while True:
try:
peer = await self.resolve_peer(chat_id)
@@ -188,7 +204,14 @@ class SendVideoNote:
peer=peer,
media=media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/messages/send_voice.py b/pyrogram/methods/messages/send_voice.py
index c9dfde7c..4fc41b66 100644
--- a/pyrogram/methods/messages/send_voice.py
+++ b/pyrogram/methods/messages/send_voice.py
@@ -43,6 +43,8 @@ class SendVoice:
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
@@ -98,6 +100,11 @@ class SendVoice:
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -181,6 +188,8 @@ class SendVoice:
]
)
+ quote_text, quote_entities = (await utils.parse_text_entities(self, quote_text, parse_mode, quote_entities)).values()
+
while True:
try:
peer = await self.resolve_peer(chat_id)
@@ -189,7 +198,14 @@ class SendVoice:
peer=peer,
media=media,
silent=disable_notification or None,
- reply_to=utils.get_reply_to(reply_to_message_id, message_thread_id, peer, reply_to_story_id),
+ reply_to=utils.get_reply_to(
+ reply_to_message_id=reply_to_message_id,
+ message_thread_id=message_thread_id,
+ reply_to_peer=peer,
+ reply_to_story_id=reply_to_story_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
+ ),
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
diff --git a/pyrogram/methods/stories/forward_story.py b/pyrogram/methods/stories/forward_story.py
index 4da60935..c2aa68b0 100644
--- a/pyrogram/methods/stories/forward_story.py
+++ b/pyrogram/methods/stories/forward_story.py
@@ -83,7 +83,9 @@ class ForwardStory:
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
message="",
- reply_to=utils.get_reply_to(message_thread_id=message_thread_id),
+ reply_to=utils.get_reply_to(
+ message_thread_id=message_thread_id
+ ),
)
)
diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py
index 24e7074b..149746c6 100644
--- a/pyrogram/types/messages_and_media/message.py
+++ b/pyrogram/types/messages_and_media/message.py
@@ -167,6 +167,12 @@ class Message(Object, Update):
*text.html* to get the marked up message text. In case there is no entity, the fields
will contain the same text as *text*.
+ quote_text (``str``, *optional*):
+ For quote messages, the actual UTF-8 text of the message, 0-4096 characters.
+ If the quote contains entities (bold, italic, ...) you can access *text.markdown* or
+ *text.html* to get the marked up message text. In case there is no entity, the fields
+ will contain the same text as *text*.
+
entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
@@ -174,6 +180,9 @@ class Message(Object, Update):
For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear
in the caption.
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
+ For quote messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
+
audio (:obj:`~pyrogram.types.Audio`, *optional*):
Message is an audio file, information about the file.
@@ -295,6 +304,9 @@ class Message(Object, Update):
Messages sent from yourself to other chats are outgoing (*outgoing* is True).
An exception is made for your own personal chat; messages sent there will be incoming.
+ quote (``bool``, *optional*):
+ The message contains a quote.
+
matches (List of regex Matches, *optional*):
A list containing all `Match Objects `_ that match
the text of this message. Only applicable when using :obj:`Filters.regex `.
@@ -387,8 +399,10 @@ class Message(Object, Update):
has_protected_content: bool = None,
has_media_spoiler: bool = None,
text: Str = None,
+ quote_text: Str = None,
entities: List["types.MessageEntity"] = None,
caption_entities: List["types.MessageEntity"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
audio: "types.Audio" = None,
document: "types.Document" = None,
photo: "types.Photo" = None,
@@ -422,6 +436,7 @@ class Message(Object, Update):
forwards: int = None,
via_bot: "types.User" = None,
outgoing: bool = None,
+ quote: bool = None,
matches: List[Match] = None,
command: List[str] = None,
forum_topic_created: "types.ForumTopicCreated" = None,
@@ -478,8 +493,10 @@ class Message(Object, Update):
self.has_protected_content = has_protected_content
self.has_media_spoiler = has_media_spoiler
self.text = text
+ self.quote_text = quote_text
self.entities = entities
self.caption_entities = caption_entities
+ self.quote_entities = quote_entities
self.audio = audio
self.document = document
self.photo = photo
@@ -513,6 +530,7 @@ class Message(Object, Update):
self.forwards = forwards
self.via_bot = via_bot
self.outgoing = outgoing
+ self.quote = quote
self.matches = matches
self.command = command
self.reply_markup = reply_markup
@@ -971,6 +989,21 @@ class Message(Object, Update):
except Exception:
pass
else:
+ if message.reply_to.quote:
+ quote_entities = [types.MessageEntity._parse(client, entity, users) for entity in message.reply_to.quote_entities]
+ quote_entities = types.List(filter(lambda x: x is not None, quote_entities))
+
+ parsed_message.quote = message.reply_to.quote
+ parsed_message.quote_text = (
+ Str(message.reply_to.quote_text).init(quote_entities) or None
+ if media is None or web_page is not None
+ else None
+ )
+ parsed_message.quote_entities = (
+ quote_entities or None
+ if media is None or web_page is not None
+ else None
+ )
parsed_message.reply_to_message_id = message.reply_to.reply_to_msg_id
parsed_message.reply_to_top_message_id = message.reply_to.reply_to_top_id
else:
@@ -1058,6 +1091,8 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup=None
@@ -1110,6 +1145,12 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -1141,6 +1182,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
schedule_date=schedule_date,
protect_content=protect_content,
reply_markup=reply_markup
@@ -1169,6 +1212,8 @@ class Message(Object, Update):
] = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
progress: Callable = None,
progress_args: tuple = ()
) -> "Message":
@@ -1238,6 +1283,12 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -1292,6 +1343,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
reply_markup=reply_markup,
progress=progress,
progress_args=progress_args
@@ -1311,6 +1364,8 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -1383,6 +1438,12 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -1436,6 +1497,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
reply_markup=reply_markup,
progress=progress,
progress_args=progress_args
@@ -1451,6 +1514,8 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -1504,6 +1569,12 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -1529,6 +1600,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
reply_markup=reply_markup
)
@@ -1579,6 +1652,9 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -1631,6 +1707,16 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -1656,6 +1742,9 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ parse_mode=parse_mode,
+ quote_entities=quote_entities,
reply_markup=reply_markup
)
@@ -1672,6 +1761,8 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
@@ -1745,6 +1836,16 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -1800,6 +1901,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
schedule_date=schedule_date,
reply_markup=reply_markup,
progress=progress,
@@ -1887,7 +1990,10 @@ class Message(Object, Update):
quote: bool = None,
disable_notification: bool = None,
message_thread_id: bool = None,
- reply_to_message_id: int = None
+ reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None
) -> "Message":
"""Bound method *reply_inline_bot_result* of :obj:`~pyrogram.types.Message`.
@@ -1928,6 +2034,16 @@ class Message(Object, Update):
reply_to_message_id (``bool``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
Returns:
On success, the sent Message is returned.
@@ -1946,7 +2062,10 @@ class Message(Object, Update):
result_id=result_id,
disable_notification=disable_notification,
message_thread_id=message_thread_id,
- reply_to_message_id=reply_to_message_id
+ reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ parse_mode=parse_mode,
+ quote_entities=quote_entities
)
async def reply_location(
@@ -1957,6 +2076,8 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -2003,6 +2124,12 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -2026,6 +2153,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
reply_markup=reply_markup
)
@@ -2035,7 +2164,10 @@ class Message(Object, Update):
quote: bool = None,
disable_notification: bool = None,
message_thread_id: int = None,
- reply_to_message_id: int = None
+ reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None
) -> List["types.Message"]:
"""Bound method *reply_media_group* of :obj:`~pyrogram.types.Message`.
@@ -2074,6 +2206,16 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
Returns:
On success, a :obj:`~pyrogram.types.Messages` object is returned containing all the
single messages sent.
@@ -2092,7 +2234,10 @@ class Message(Object, Update):
media=media,
disable_notification=disable_notification,
message_thread_id=message_thread_id,
- reply_to_message_id=reply_to_message_id
+ reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ parse_mode=parse_mode,
+ quote_entities=quote_entities
)
async def reply_photo(
@@ -2107,6 +2252,8 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -2172,6 +2319,12 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -2223,6 +2376,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
reply_markup=reply_markup,
progress=progress,
progress_args=progress_args
@@ -2247,6 +2402,9 @@ class Message(Object, Update):
protect_content: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
@@ -2337,6 +2495,16 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@@ -2374,6 +2542,9 @@ class Message(Object, Update):
protect_content=protect_content,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ parse_mode=parse_mode,
+ quote_entities=quote_entities,
schedule_date=schedule_date,
reply_markup=reply_markup
)
@@ -2385,6 +2556,9 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -2432,6 +2606,16 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -2478,6 +2662,9 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ parse_mode=parse_mode,
+ quote_entities=quote_entities,
reply_markup=reply_markup,
progress=progress,
progress_args=progress_args
@@ -2495,6 +2682,9 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -2556,6 +2746,16 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -2583,6 +2783,9 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ parse_mode=parse_mode,
+ quote_entities=quote_entities,
reply_markup=reply_markup
)
@@ -2603,6 +2806,8 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -2686,6 +2891,12 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -2742,6 +2953,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
reply_markup=reply_markup,
progress=progress,
progress_args=progress_args
@@ -2757,6 +2970,9 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ parse_mode: Optional["enums.ParseMode"] = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -2816,6 +3032,16 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
+ By default, texts are parsed using both Markdown and HTML styles.
+ You can combine both syntaxes together.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -2865,6 +3091,9 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ parse_mode=parse_mode,
+ quote_entities=quote_entities,
reply_markup=reply_markup,
progress=progress,
progress_args=progress_args
@@ -2881,6 +3110,8 @@ class Message(Object, Update):
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
+ quote_text: str = None,
+ quote_entities: List["types.MessageEntity"] = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@@ -2941,6 +3172,12 @@ class Message(Object, Update):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message
+ quote_text (``str``):
+ Text of the quote to be sent.
+
+ quote_entities (List of :obj:`~pyrogram.types.MessageEntity`):
+ List of special entities that appear in quote text, which can be specified instead of *parse_mode*.
+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@@ -2991,6 +3228,8 @@ class Message(Object, Update):
disable_notification=disable_notification,
message_thread_id=message_thread_id,
reply_to_message_id=reply_to_message_id,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
reply_markup=reply_markup,
progress=progress,
progress_args=progress_args
diff --git a/pyrogram/utils.py b/pyrogram/utils.py
index 4f10dbef..6fafc085 100644
--- a/pyrogram/utils.py
+++ b/pyrogram/utils.py
@@ -288,16 +288,22 @@ def get_peer_type(peer_id: int) -> str:
def get_reply_to(
reply_to_message_id: Optional[int] = None,
message_thread_id: Optional[int] = None,
- user_id: Optional[raw.types.InputUser] = None,
+ reply_to_peer: Optional[raw.base.InputPeer] = None,
+ quote_text: Optional[str] = None,
+ quote_entities: Optional[List[raw.base.MessageEntity]] = None,
reply_to_story_id: Optional[int] = None
) -> Optional[Union[raw.types.InputReplyToMessage, raw.types.InputReplyToStory]]:
- if all((user_id, reply_to_story_id)):
- return raw.types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) # type: ignore[arg-type]
+ """Get InputReply for reply_to argument"""
+ if all((reply_to_peer, reply_to_story_id)):
+ return raw.types.InputReplyToStory(user_id=reply_to_peer, story_id=reply_to_story_id) # type: ignore[arg-type]
if any((reply_to_message_id, message_thread_id)):
return raw.types.InputReplyToMessage(
reply_to_msg_id=reply_to_message_id or message_thread_id, # type: ignore[arg-type]
top_msg_id=message_thread_id if reply_to_message_id else None,
+ reply_to_peer_id=reply_to_peer,
+ quote_text=quote_text,
+ quote_entities=quote_entities,
)
return None