Skip to content

Commit

Permalink
Pyrofork: Add support to reply message in another chat
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <[email protected]>
  • Loading branch information
wulan17 committed Nov 25, 2023
1 parent 5c54499 commit d0ae6d2
Show file tree
Hide file tree
Showing 19 changed files with 453 additions and 34 deletions.
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def send_animation(
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -129,6 +130,10 @@ async def send_animation(
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand Down Expand Up @@ -191,8 +196,16 @@ async def progress(current, total):
file = None

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)
if reply_to_story_id:
user_id = await self.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async def send_audio(
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -122,6 +123,10 @@ async def send_audio(
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand Down Expand Up @@ -185,8 +190,16 @@ async def progress(current, total):
file = None

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)
if reply_to_story_id:
user_id = await self.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_cached_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async def send_cached_media(
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -94,6 +95,10 @@ async def send_cached_media(
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand All @@ -118,8 +123,16 @@ async def send_cached_media(
"""

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)
if reply_to_story_id:
user_id = await self.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def send_contact(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -79,6 +80,10 @@ async def send_contact(
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand All @@ -103,8 +108,16 @@ async def send_contact(
"""

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)

r = await self.invoke(
raw.functions.messages.SendMedia(
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def send_dice(
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -75,6 +76,10 @@ async def send_dice(
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand Down Expand Up @@ -106,8 +111,16 @@ async def send_dice(
"""

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)
if reply_to_story_id:
user_id = await self.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async def send_document(
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -114,6 +115,10 @@ async def send_document(
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand Down Expand Up @@ -172,8 +177,16 @@ async def progress(current, total):
file = None

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)
if reply_to_story_id:
user_id = await self.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def send_location(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -68,6 +69,10 @@ async def send_location(
Unique identifier for the target message thread (topic) of the forum.
for forum supergroups only.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message
Expand Down Expand Up @@ -95,8 +100,16 @@ async def send_location(
"""

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)

r = await self.invoke(
raw.functions.messages.SendMedia(
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async def send_media_group(
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -80,6 +81,10 @@ async def send_media_group(
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand Down Expand Up @@ -110,8 +115,16 @@ async def send_media_group(
multi_media = []

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)
if reply_to_story_id:
user_id = await self.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def send_message(
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -84,6 +85,10 @@ async def send_message(
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand Down Expand Up @@ -139,8 +144,16 @@ async def send_message(
message, entities = (await utils.parse_text_entities(self, text, parse_mode, entities)).values()

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)
if reply_to_story_id:
user_id = await self.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
Expand Down
15 changes: 14 additions & 1 deletion pyrogram/methods/messages/send_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async def send_photo(
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_story_id: int = None,
reply_to_chat_id: int = None,
quote_text: str = None,
schedule_date: datetime = None,
protect_content: bool = None,
Expand Down Expand Up @@ -105,6 +106,10 @@ async def send_photo(
reply_to_story_id (``int``, *optional*):
Unique identifier for the target story.
reply_to_chat_id (``int``, *optional*):
Unique identifier for the origin chat.
for reply to message from another chat.
quote_text (``str``, *optional*):
Text to quote.
for reply_to_message only.
Expand Down Expand Up @@ -163,8 +168,16 @@ async def send_photo(
file = None

reply_to = None
reply_to_chat = None
if reply_to_message_id or message_thread_id:
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id, quote_text=quote_text)
if reply_to_chat_id is not None:
reply_to_chat = await self.resolve_peer(reply_to_chat_id)
reply_to = types.InputReplyToMessage(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_chat=reply_to_chat,
quote_text=quote_text
)
if reply_to_story_id:
user_id = await self.resolve_peer(chat_id)
reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id)
Expand Down
Loading

0 comments on commit d0ae6d2

Please sign in to comment.