Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_updates(offset=None):
- while True:
- try:
- URL = url + 'getUpdates'
- if offset:
- URL += '?offset={}'.format(offset)
- res = requests.get(URL)
- while (res.status_code != 200 or len(res.json()['result']) == 0):
- sleep(1)
- res = requests.get(URL)
- print(res.url)
- return res.json()
- except:
- pass
- def get_last(data):
- results = data['result']
- count = len(results)
- last = count - 1
- last_update = results[last]
- return last_update
- def get_last_id_text(updates):
- last_update = get_last(updates)
- chat_id = last_update['message']['chat']['id']
- update_id = last_update['update_id']
- try:
- text = last_update['message']['text']
- except:
- text = ''
- return chat_id, text, update_id
- def main():
- chat_id, text, update_id = get_last_id_text(get_updates())
- chat_id, text, update_id = start(chat_id)
- while text.lower() != 'y':
- sleep(1)
- text = 'начать!'
- menu(chat_id, text, update_id)
- chat_id, text, update_id = get_last_id_text(get_updates())
- text = end(chat_id, text, update_id)
Advertisement
Add Comment
Please, Sign In to add comment