From e6b4f0e74370c926e1c46e57bd50f8782736e450 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 30 Apr 2018 14:25:11 +0200 Subject: [PATCH] Make delete_messages accept iterables --- pyrogram/client/client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 6f3b41ce..31bb0e01 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -2729,7 +2729,7 @@ class Client: def delete_messages(self, chat_id: int or str, - message_ids: list or int, + message_ids, revoke: bool = True): """Use this method to delete messages, including service messages, with the following limitations: @@ -2746,8 +2746,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 to delete or a single message id. + Iterators and Generators are also accepted. revoke (``bool``, optional): Deletes messages on both parts. @@ -2762,7 +2763,7 @@ class Client: :class:`Error ` """ peer = self.resolve_peer(chat_id) - message_ids = message_ids if isinstance(message_ids, list) else [message_ids] + message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids] if isinstance(peer, types.InputPeerChannel): self.send(