diff --git a/pyrogram/methods/messages/delete_messages.py b/pyrogram/methods/messages/delete_messages.py index 07c3a7b8..c19493b6 100644 --- a/pyrogram/methods/messages/delete_messages.py +++ b/pyrogram/methods/messages/delete_messages.py @@ -27,7 +27,8 @@ class DeleteMessages: self: "pyrogram.Client", chat_id: Union[int, str], message_ids: Union[int, Iterable[int]], - revoke: bool = True + revoke: bool = True, + is_scheduled: bool = None ) -> int: """Delete messages, including service messages. @@ -48,6 +49,11 @@ class DeleteMessages: channels and supergroups are always revoked (i.e.: deleted for everyone). Defaults to True. + is_scheduled (``bool``, *optional*): + If True, the message will be deleted from the scheduled messages. + For userbots only. + Defaults to None. + Returns: ``int``: Amount of affected messages @@ -62,11 +68,21 @@ class DeleteMessages: # Delete messages only on your side (without revoking) await app.delete_messages(chat_id, message_id, revoke=False) + + # Delete scheduled messages + await app.delete_messages(chat_id, message_id, is_scheduled=True) """ peer = await self.resolve_peer(chat_id) message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids] - if isinstance(peer, raw.types.InputPeerChannel): + if is_scheduled: + r = await self.invoke( + raw.functions.messages.DeleteScheduledMessages( + peer=peer, + id=message_ids + ) + ) + elif isinstance(peer, raw.types.InputPeerChannel): r = await self.invoke( raw.functions.channels.DeleteMessages( channel=peer, @@ -81,4 +97,4 @@ class DeleteMessages: ) ) - return r.pts_count + return len(r.updates[0].messages) if is_scheduled else r.pts_count diff --git a/pyrogram/methods/messages/get_scheduled_messages.py b/pyrogram/methods/messages/get_scheduled_messages.py index 079dd81f..e28e0120 100644 --- a/pyrogram/methods/messages/get_scheduled_messages.py +++ b/pyrogram/methods/messages/get_scheduled_messages.py @@ -34,7 +34,7 @@ class GetScheduledMessages: ) -> List["types.Message"]: """Get one or more scheduled messages from a chat. - .. include:: /_includes/usable-by/users-bots.rst + .. include:: /_includes/usable-by/users.rst Parameters: chat_id (``int`` | ``str``):