mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
new 5.3 function names
added the new function names (the previous names are still working) from 5.3 and some other small changes
This commit is contained in:
@ -93,6 +93,7 @@ def _make_request(token, method_name, method='get', params=None, files=None):
|
||||
# Long polling hangs for given time. Read timeout should be greater that long_polling_timeout
|
||||
read_timeout = max(params['timeout'] + 10, read_timeout)
|
||||
|
||||
params = params or None #set params to None if empty
|
||||
|
||||
result = None
|
||||
if RETRY_ON_ERROR:
|
||||
@ -335,6 +336,12 @@ def get_chat_members_count(token, chat_id):
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
|
||||
def get_chat_member_count(token, chat_id):
|
||||
method_url = r'getChatMemberCount'
|
||||
payload = {'chat_id': chat_id}
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
|
||||
def set_sticker_set_thumb(token, name, user_id, thumb):
|
||||
method_url = r'setStickerSetThumb'
|
||||
payload = {'name': name, 'user_id': user_id}
|
||||
@ -861,6 +868,18 @@ def kick_chat_member(token, chat_id, user_id, until_date=None, revoke_messages=N
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
|
||||
|
||||
def ban_chat_member(token, chat_id, user_id, until_date=None, revoke_messages=None):
|
||||
method_url = 'banChatMember'
|
||||
payload = {'chat_id': chat_id, 'user_id': user_id}
|
||||
if isinstance(until_date, datetime):
|
||||
payload['until_date'] = until_date.timestamp()
|
||||
else:
|
||||
payload['until_date'] = until_date
|
||||
if revoke_messages is not None:
|
||||
payload['revoke_messages'] = revoke_messages
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
|
||||
|
||||
def unban_chat_member(token, chat_id, user_id, only_if_banned):
|
||||
method_url = 'unbanChatMember'
|
||||
payload = {'chat_id': chat_id, 'user_id': user_id}
|
||||
@ -1027,32 +1046,32 @@ def set_chat_title(token, chat_id, title):
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
|
||||
|
||||
def get_my_commands(token, scope, language_code):
|
||||
def get_my_commands(token, scope=None, language_code=None):
|
||||
method_url = r'getMyCommands'
|
||||
payload = {}
|
||||
if scope is not None:
|
||||
if scope:
|
||||
payload['scope'] = scope.to_json()
|
||||
if language_code is not None:
|
||||
if language_code:
|
||||
payload['language_code'] = language_code
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
|
||||
def set_my_commands(token, commands, scope, language_code):
|
||||
def set_my_commands(token, commands, scope=None, language_code=None):
|
||||
method_url = r'setMyCommands'
|
||||
payload = {'commands': _convert_list_json_serializable(commands)}
|
||||
if scope is not None:
|
||||
if scope:
|
||||
payload['scope'] = scope.to_json()
|
||||
if language_code is not None:
|
||||
if language_code:
|
||||
payload['language_code'] = language_code
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
|
||||
|
||||
def delete_my_commands(token, scope, language_code):
|
||||
def delete_my_commands(token, scope=None, language_code=None):
|
||||
method_url = r'deleteMyCommands'
|
||||
payload = {}
|
||||
if scope is not None:
|
||||
if scope:
|
||||
payload['scope'] = scope.to_json()
|
||||
if language_code is not None:
|
||||
if language_code:
|
||||
payload['language_code'] = language_code
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
|
||||
|
Reference in New Issue
Block a user