From 736d62e20d932956949fb85fb9aff7d7428481b6 Mon Sep 17 00:00:00 2001 From: Leandro Toledo Date: Tue, 12 Apr 2016 00:46:50 -0300 Subject: [PATCH] New methods kickChatMember and unbanChatMember #232 --- telegram/bot.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/telegram/bot.py b/telegram/bot.py index a252596f4..6e5721da7 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -752,6 +752,64 @@ class Bot(TelegramObject): return File.de_json(result) + @log + def kickChatMember(self, + chat_id, + user_id): + """Use this method to kick a user from a group or a supergroup. In the + case of supergroups, the user will not be able to return to the group + on their own using invite links, etc., unless unbanned first. The bot + must be an administrator in the group for this to work. + + Args: + chat_id: + Unique identifier for the target group or username of the target + supergroup (in the format @supergroupusername). + user_id: + Unique identifier of the target user. + + Returns: + True on success. + """ + + url = '%s/kickChatMember' % self.base_url + + data = {'chat_id': chat_id, + 'user_id': user_id} + + result = request.post(url, data) + + return result + + @log + def unbanChatMember(self, + chat_id, + user_id): + """Use this method to unban a previously kicked user in a supergroup. + The user will not return to the group automatically, but will be able + to join via link, etc. The bot must be an administrator in the group + for this to work. + + Args: + chat_id: + Unique identifier for the target group or username of the target + supergroup (in the format @supergroupusername). + user_id: + Unique identifier of the target user. + + Returns: + True on success. + """ + + url = '%s/unbanChatMember' % self.base_url + + data = {'chat_id': chat_id, + 'user_id': user_id} + + result = request.post(url, data) + + return result + @log def getUpdates(self, offset=None,