From 8f8e1cfa254335082f02a124a2ade7f480573870 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 30 Apr 2018 14:18:13 +0200 Subject: [PATCH] Make get_messages accept iterables --- pyrogram/client/client.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index a712df94..312db23a 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -3569,7 +3569,7 @@ class Client: def get_messages(self, chat_id: int or str, - message_ids: list or int, + message_ids, replies: int = 1): """Use this method to get messages that belong to a specific chat. You can retrieve up to 200 messages at once. @@ -3581,8 +3581,9 @@ class Client: For a contact that exists in your Telegram address book you can use his phone number (str). For a private channel/supergroup you can use its *t.me/joinchat/* link. - message_ids (``list`` | ``int``): + message_ids (``iterable``): A list of Message identifiers in the chat specified in *chat_id* or a single message id, as integer. + Iterators and Generators are also accepted. replies (``int``, optional): The number of replies to get for each message. Defaults to 1. @@ -3597,8 +3598,8 @@ class Client: :class:`Error ` """ peer = self.resolve_peer(chat_id) - is_list = isinstance(message_ids, list) - message_ids = message_ids if is_list else [message_ids] + is_iterable = not isinstance(message_ids, int) + message_ids = list(message_ids) if is_iterable else [message_ids] message_ids = [types.InputMessageID(i) for i in message_ids] if isinstance(peer, types.InputPeerChannel): @@ -3639,7 +3640,7 @@ class Client: ) ) - return messages if is_list else messages[0] + return messages if is_iterable else messages[0] def answer_callback_query(self, callback_query_id: str,