From b41c009962468f56f373e02a4c1e697bbedbc131 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 30 Apr 2018 14:24:05 +0200 Subject: [PATCH] Make forward_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 208b84ca..6f3b41ce 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1188,7 +1188,7 @@ class Client: def forward_messages(self, chat_id: int or str, from_chat_id: int or str, - message_ids: list or int, + message_ids, disable_notification: bool = None): """Use this method to forward messages of any kind. @@ -1205,8 +1205,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 *from_chat_id* or a single message id. + Iterators and Generators are also accepted. disable_notification (``bool``, optional): Sends the message silently. @@ -1221,8 +1222,8 @@ class Client: Raises: :class:`Error ` """ - 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] r = self.send( functions.messages.ForwardMessages( @@ -1245,7 +1246,7 @@ class Client: utils.parse_message(self, i.message, users, chats) ) - return messages if is_list else messages[0] + return messages if is_iterable else messages[0] def send_photo(self, chat_id: int or str,