mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-02 07:15:23 +00:00
Update get_messages to accept the new reply_to_message_ids argument
This commit is contained in:
@@ -23,9 +23,10 @@ from ...ext import BaseClient, utils
|
|||||||
class GetMessages(BaseClient):
|
class GetMessages(BaseClient):
|
||||||
def get_messages(self,
|
def get_messages(self,
|
||||||
chat_id: int or str,
|
chat_id: int or str,
|
||||||
message_ids,
|
message_ids: int or list = None,
|
||||||
|
reply_to_message_ids: int or list = None,
|
||||||
replies: int = 1):
|
replies: int = 1):
|
||||||
"""Use this method to get messages that belong to a specific chat.
|
"""Use this method to get one or more messages that belong to a specific chat.
|
||||||
You can retrieve up to 200 messages at once.
|
You can retrieve up to 200 messages at once.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -50,20 +51,25 @@ class GetMessages(BaseClient):
|
|||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>`
|
:class:`Error <pyrogram.Error>`
|
||||||
"""
|
"""
|
||||||
|
ids, ids_type = (
|
||||||
|
(message_ids, types.InputMessageID) if message_ids
|
||||||
|
else (reply_to_message_ids, types.InputMessageReplyTo) if reply_to_message_ids
|
||||||
|
else (None, None)
|
||||||
|
)
|
||||||
|
|
||||||
|
if ids is None:
|
||||||
|
raise ValueError("No argument supplied")
|
||||||
|
|
||||||
peer = self.resolve_peer(chat_id)
|
peer = self.resolve_peer(chat_id)
|
||||||
is_iterable = not isinstance(message_ids, int)
|
|
||||||
message_ids = list(message_ids) if is_iterable else [message_ids]
|
is_iterable = not isinstance(ids, int)
|
||||||
message_ids = [types.InputMessageID(i) for i in message_ids]
|
ids = list(ids) if is_iterable else [ids]
|
||||||
|
ids = [types.InputMessageID(i) for i in ids]
|
||||||
|
|
||||||
if isinstance(peer, types.InputPeerChannel):
|
if isinstance(peer, types.InputPeerChannel):
|
||||||
rpc = functions.channels.GetMessages(
|
rpc = functions.channels.GetMessages(channel=peer, id=ids)
|
||||||
channel=peer,
|
|
||||||
id=message_ids
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
rpc = functions.messages.GetMessages(
|
rpc = functions.messages.GetMessages(id=ids)
|
||||||
id=message_ids
|
|
||||||
)
|
|
||||||
|
|
||||||
r = self.send(rpc)
|
r = self.send(rpc)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user