From 174a9c410bb1ac7a34d8e9b7e1cf0e6d51860fa4 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Thu, 11 Mar 2021 09:15:32 +0300 Subject: [PATCH] updated kick_chat_member shortcut for Chat --- aiogram/types/chat.py | 45 +++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index 40ca0898..957ee78b 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -186,30 +186,47 @@ class Chat(base.TelegramObject): """ return await self.bot.set_chat_description(self.id, description) - async def kick(self, user_id: base.Integer, - until_date: typing.Union[ - base.Integer, datetime.datetime, datetime.timedelta, None] = None) -> base.Boolean: + async def kick(self, + user_id: base.Integer, + until_date: typing.Union[base.Integer, datetime.datetime, + datetime.timedelta, None] = None, + revoke_messages: typing.Optional[base.Boolean] = None, + ) -> base.Boolean: """ Use this method to kick 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 invite links, etc., unless unbanned first. + In the case of supergroups and channels, the user will not be able to return + to the chat on their own using invite links, etc., unless unbanned first. - The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. - - Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting - is off in the target group. - Otherwise members may only be removed by the group's creator or by the member that added them. + The bot must be an administrator in the chat for this to work and must have + the appropriate admin rights. Source: https://core.telegram.org/bots/api#kickchatmember :param user_id: Unique identifier of the target user :type user_id: :obj:`base.Integer` - :param until_date: Date when the user will be unbanned, unix time. - :type until_date: :obj:`typing.Optional[base.Integer]` - :return: Returns True on success. + + :param until_date: Date when the user will be unbanned. 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. Applied for supergroups and channels + only. + :type until_date: :obj:`typing.Union[base.Integer, datetime.datetime, + datetime.timedelta, None` + + :param revoke_messages: 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. + :type revoke_messages: :obj:`typing.Optional[base.Boolean]` + + :return: Returns True on success :rtype: :obj:`base.Boolean` """ - return await self.bot.kick_chat_member(self.id, user_id=user_id, until_date=until_date) + return await self.bot.kick_chat_member( + chat_id=self.id, + user_id=user_id, + until_date=until_date, + revoke_messages=revoke_messages, + ) async def unban(self, user_id: base.Integer,