From 8ea36645c05bac55baab6e1e79db82773424d3c4 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 28 Apr 2024 04:53:37 +0200 Subject: [PATCH] pyrofork: Add revoke_messages to ban_chat_member pyrogram/pyrogram#1421 Signed-off-by: wulan17 --- pyrogram/methods/chats/ban_chat_member.py | 10 ++++++++-- pyrogram/types/user_and_chats/chat.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pyrogram/methods/chats/ban_chat_member.py b/pyrogram/methods/chats/ban_chat_member.py index fc0134b5..2713ea40 100644 --- a/pyrogram/methods/chats/ban_chat_member.py +++ b/pyrogram/methods/chats/ban_chat_member.py @@ -30,7 +30,8 @@ class BanChatMember: self: "pyrogram.Client", chat_id: Union[int, str], user_id: Union[int, str], - until_date: datetime = utils.zero_datetime() + until_date: datetime = utils.zero_datetime(), + revoke_messages: bool = None ) -> Union["types.Message", bool]: """Ban a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using @@ -59,6 +60,10 @@ class BanChatMember: If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Defaults to epoch (ban forever). + revoke_messages (``bool``, *optional*): + Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. + Always True for supergroups and channels. + Returns: :obj:`~pyrogram.types.Message` | ``bool``: On success, a service message will be returned (when applicable), otherwise, in case a message object couldn't be returned, True is returned. @@ -100,7 +105,8 @@ class BanChatMember: r = await self.invoke( raw.functions.messages.DeleteChatUser( chat_id=abs(chat_id), - user_id=user_peer + user_id=user_peer, + revoke_history=revoke_messages ) ) diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index 34c1a4af..5329ec2c 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -808,7 +808,8 @@ class Chat(Object): async def ban_member( self, user_id: Union[int, str], - until_date: datetime = utils.zero_datetime() + until_date: datetime = utils.zero_datetime(), + revoke_messages: bool = None ) -> Union["types.Message", bool]: """Bound method *ban_member* of :obj:`~pyrogram.types.Chat`. @@ -841,6 +842,10 @@ class Chat(Object): If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Defaults to epoch (ban forever). + revoke_messages (``bool``, *optional*): + Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. + Always True for supergroups and channels. + Returns: :obj:`~pyrogram.types.Message` | ``bool``: On success, a service message will be returned (when applicable), otherwise, in case a message object couldn't be returned, True is returned. @@ -852,7 +857,8 @@ class Chat(Object): return await self._client.ban_chat_member( chat_id=self.id, user_id=user_id, - until_date=until_date + until_date=until_date, + revoke_messages=revoke_messages ) async def unban_member(