2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-09-01 23:05:15 +00:00

Make delete_messages accept iterables

This commit is contained in:
Dan
2018-04-30 14:25:11 +02:00
parent b41c009962
commit e6b4f0e743

View File

@@ -2729,7 +2729,7 @@ class Client:
def delete_messages(self, def delete_messages(self,
chat_id: int or str, chat_id: int or str,
message_ids: list or int, message_ids,
revoke: bool = True): revoke: bool = True):
"""Use this method to delete messages, including service messages, with the following limitations: """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 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. 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. A list of Message identifiers to delete or a single message id.
Iterators and Generators are also accepted.
revoke (``bool``, optional): revoke (``bool``, optional):
Deletes messages on both parts. Deletes messages on both parts.
@@ -2762,7 +2763,7 @@ class Client:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
peer = self.resolve_peer(chat_id) 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): if isinstance(peer, types.InputPeerChannel):
self.send( self.send(