1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #1020 from Badiboy/master

added only_if_banned to unban_chat_member
This commit is contained in:
Badiboy 2020-11-20 15:05:41 +03:00 committed by GitHub
commit a9db217c64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -1052,14 +1052,15 @@ class TeleBot:
"""
return apihelper.kick_chat_member(self.token, chat_id, user_id, until_date)
def unban_chat_member(self, chat_id, user_id):
def unban_chat_member(self, chat_id, user_id, only_if_banned = False):
"""
Removes member from the ban
:param chat_id:
:param user_id:
:param only_if_banned:
:return:
"""
return apihelper.unban_chat_member(self.token, chat_id, user_id)
return apihelper.unban_chat_member(self.token, chat_id, user_id, only_if_banned)
def restrict_chat_member(
self, chat_id, user_id, until_date=None,

View File

@ -700,9 +700,11 @@ def kick_chat_member(token, chat_id, user_id, until_date=None):
return _make_request(token, method_url, params=payload, method='post')
def unban_chat_member(token, chat_id, user_id):
def unban_chat_member(token, chat_id, user_id, only_if_banned):
method_url = 'unbanChatMember'
payload = {'chat_id': chat_id, 'user_id': user_id}
if only_if_banned:
payload['only_if_banned'] = only_if_banned
return _make_request(token, method_url, params=payload, method='post')

View File

@ -413,6 +413,7 @@ class Message(JsonDeserializable):
def __init__(self, message_id, from_user, date, chat, content_type, options, json_string):
self.content_type = content_type
self.id = message_id # Lets fix the telegram usability ####up with ID in Message :)
self.message_id = message_id
self.from_user = from_user
self.date = date