Skip to content

Commit

Permalink
Fix reply_to_peer wrongly be set to the target chat_id.
Browse files Browse the repository at this point in the history
Signed-off-by: Aliwoto <[email protected]>
  • Loading branch information
Aliwoto committed Nov 2, 2023
1 parent 229298d commit 84e6928
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pyrogram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>

__version__ = "2.0.133"
__version__ = "2.0.134"
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
__copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>"

Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/bots/send_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async def send_game(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -92,6 +93,7 @@ async def send_game(
silent=disable_notification or None,
reply_to=utils.get_reply_to(
reply_to_message_id=reply_to_message_id,
reply_to_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
message_thread_id=message_thread_id
),
random_id=self.rnd_id(),
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/bots/send_inline_bot_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ async def send_inline_bot_result(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_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
quote_entities: List["types.MessageEntity"] = None,
parse_mode: Optional["enums.ParseMode"] = None
) -> "raw.base.Updates":
"""Send an inline bot result.
Bot results can be retrieved using :meth:`~pyrogram.Client.get_inline_bot_results`
Expand Down Expand Up @@ -94,7 +96,9 @@ async def send_inline_bot_result(
silent=disable_notification or None,
reply_to=utils.get_reply_to(
reply_to_message_id=reply_to_message_id,
reply_to_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
message_thread_id=message_thread_id,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities
)
Expand Down
19 changes: 14 additions & 5 deletions pyrogram/methods/messages/copy_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ async def copy_media_group(
message_id: int,
captions: Union[List[str], str] = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
reply_to_story_id: int = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
schedule_date: datetime = None,
) -> List["types.Message"]:
"""Copy a media group by providing one of the message ids.
Expand Down Expand Up @@ -85,7 +89,7 @@ async def copy_media_group(
await app.copy_media_group(to_chat, from_chat, 123)
await app.copy_media_group(to_chat, from_chat, 123, captions="single caption")
await app.copy_media_group(to_chat, from_chat, 123,
captions=["caption 1", None, ""])
"""
Expand Down Expand Up @@ -118,14 +122,19 @@ async def copy_media_group(
)
)

reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)

r = await self.invoke(
raw.functions.messages.SendMultiMedia(
peer=await self.resolve_peer(chat_id),
multi_media=multi_media,
silent=disable_notification or None,
reply_to=reply_to,
reply_to=utils.get_reply_to(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
),
schedule_date=utils.datetime_to_timestamp(schedule_date)
),
sleep_threshold=60
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/send_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async def send_animation(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
reply_to_story_id: int = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
Expand Down Expand Up @@ -254,7 +255,7 @@ async def progress(current, total):
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/send_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async def send_audio(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
reply_to_story_id: int = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
Expand Down Expand Up @@ -241,7 +242,7 @@ async def progress(current, total):
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/send_cached_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def send_cached_media(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
reply_to_story_id: int = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
Expand Down Expand Up @@ -131,7 +132,7 @@ async def send_cached_media(
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
6 changes: 5 additions & 1 deletion pyrogram/methods/messages/send_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ 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,
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,
parse_mode: Optional["enums.ParseMode"] = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -128,6 +130,8 @@ async def send_contact(
reply_to=utils.get_reply_to(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
),
Expand Down
5 changes: 3 additions & 2 deletions pyrogram/methods/messages/send_dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ async def send_dice(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_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,
parse_mode: Optional["enums.ParseMode"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
Expand Down Expand Up @@ -124,7 +125,7 @@ async def send_dice(
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/send_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async def send_document(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
reply_to_story_id: int = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
Expand Down Expand Up @@ -219,7 +220,7 @@ async def progress(current, total):
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
6 changes: 5 additions & 1 deletion pyrogram/methods/messages/send_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ 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,
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,
parse_mode: Optional["enums.ParseMode"] = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -118,6 +120,8 @@ async def send_location(
reply_to=utils.get_reply_to(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
),
Expand Down
5 changes: 3 additions & 2 deletions pyrogram/methods/messages/send_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ async def send_media_group(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_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,
parse_mode: Optional["enums.ParseMode"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
invert_media: bool = None,
Expand Down Expand Up @@ -429,7 +430,7 @@ async def send_media_group(
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/send_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def send_message(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
reply_to_story_id: int = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
Expand Down Expand Up @@ -152,7 +153,7 @@ async def send_message(
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/send_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async def send_photo(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
reply_to_story_id: int = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
Expand Down Expand Up @@ -203,7 +204,7 @@ async def send_photo(
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
8 changes: 6 additions & 2 deletions pyrogram/methods/messages/send_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ async def send_poll(
open_period: int = None,
close_date: datetime = None,
is_closed: bool = None,
disable_notification: bool = None,
protect_content: bool = None,
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_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,
parse_mode: Optional["enums.ParseMode"] = None,
schedule_date: datetime = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -184,6 +186,8 @@ async def send_poll(
reply_to=utils.get_reply_to(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
),
Expand Down
5 changes: 3 additions & 2 deletions pyrogram/methods/messages/send_sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ async def send_sticker(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_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,
parse_mode: Optional["enums.ParseMode"] = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -184,7 +185,7 @@ async def send_sticker(
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
6 changes: 5 additions & 1 deletion pyrogram/methods/messages/send_venue.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ async def send_venue(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_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,
parse_mode: Optional["enums.ParseMode"] = None,
schedule_date: datetime = None,
protect_content: bool = None,
reply_markup: Union[
Expand Down Expand Up @@ -142,6 +144,8 @@ async def send_venue(
reply_to=utils.get_reply_to(
reply_to_message_id=reply_to_message_id,
message_thread_id=message_thread_id,
reply_to_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
),
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/send_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async def send_video(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_id: int = None,
reply_to_story_id: int = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
Expand Down Expand Up @@ -260,7 +261,7 @@ async def progress(current, total):
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
5 changes: 3 additions & 2 deletions pyrogram/methods/messages/send_video_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ async def send_video_note(
disable_notification: bool = None,
message_thread_id: int = None,
reply_to_message_id: int = None,
reply_to_chat_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,
parse_mode: Optional["enums.ParseMode"] = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -208,7 +209,7 @@ async def send_video_note(
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_peer=await self.resolve_peer(reply_to_chat_id) if reply_to_chat_id else None,
reply_to_story_id=reply_to_story_id,
quote_text=quote_text,
quote_entities=quote_entities,
Expand Down
Loading

0 comments on commit 84e6928

Please sign in to comment.