Привет, такой вопросик. Бот телеграмма перестал реагировать на команды, после перезапуска реагирует на последнюю команду, а далее все оп новой, код не менял. Есть варианты? Python.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import config
import json
from sbet import get_prognoze
from time import sleep
from info import info
import telebot
token = config.token
URL='https://api.telegram.org/bot' + token + '/'
global last_update_id
last_update_id = 0
def get_updates():
url = URL + 'getupdates'
r = requests.get(url)
return (r.json())
def get_message():
data = get_updates()
last_object = data['result'][-1]
c_update_id = last_object['update_id']
global last_update_id
if last_update_id != c_update_id:
last_update_id = c_update_id
chat_id = last_object['message']['chat']['id']
mtext = last_object['message']['text']
message = {'chat_id': chat_id, 'text': mtext}
return message
return None
def send_message(chat_id, text):
url = URL + 'sendmessage?chat_id={}&text={}'.format(chat_id, text)
requests.get(url)
def main():
while True:
answer = get_message()
if answer != None:
chat_id = answer['chat_id']
text = answer['text']
if text == '/info':
send_message(chat_id,info())
if text == '/prognoz':
send_message(chat_id, get_prognoze())
else:
continue
sleep(1)
if __name__ == '__main__':
main()