mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
- Implemented an optional "offset" argument in apihelper.py.
- TeleBot#get_update now makes use of this argument, which improves the efficiency of the method. - Removed useless req.status_code statement in apihelper.py#send_data
This commit is contained in:
parent
7bffd4331b
commit
64811a3960
@ -42,6 +42,9 @@ class TeleBot:
|
||||
self.__stop_polling = False
|
||||
self.interval = 3
|
||||
|
||||
def get_last_update_id(self):
|
||||
return self.update_id_list[-1] if len(self.update_id_list) > 0 else None
|
||||
|
||||
def get_update(self):
|
||||
result = apihelper.get_updates(self.token)
|
||||
if result['ok'] is not True:
|
||||
|
@ -37,9 +37,12 @@ def send_message(token, chat_id, text, disable_web_page_preview=None, reply_to_m
|
||||
return check_result(method_url, req)
|
||||
|
||||
|
||||
def get_updates(token):
|
||||
def get_updates(token, offset=None):
|
||||
api_url = telebot.API_URL
|
||||
method_url = r'getUpdates'
|
||||
if offset is not None:
|
||||
request_url = api_url + 'bot' + token + '/' + method_url + '?offset=' + str(offset)
|
||||
else:
|
||||
request_url = api_url + 'bot' + token + '/' + method_url
|
||||
req = requests.get(request_url)
|
||||
return check_result(method_url, req)
|
||||
@ -101,7 +104,6 @@ def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_m
|
||||
if reply_markup:
|
||||
payload['reply_markup'] = reply_markup
|
||||
req = requests.post(request_url, params=payload, files=files)
|
||||
req.status_code
|
||||
return check_result(method_url, req)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user