Код бота:
import cherrypy
import telebot
BOT_TOKEN = "bot:token"
bot = telebot.TeleBot(BOT_TOKEN)
@bot.message_handler(commands=["start"])
def command_start(message):
bot.send_message(message.chat.id, "Привет! Я бот номер 1")
class WebhookServer(object):
@cherrypy.expose
def index(self):
length = int(cherrypy.request.headers['content-length'])
json_string = cherrypy.request.body.read(length).decode("utf-8")
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return ''
if __name__ == '__main__':
bot.remove_webhook()
bot.set_webhook(url='https://myserver.tk/bot')
cherrypy.config.update({
'server.socket_host': '127.0.0.1',
'server.socket_port': 7771,
'engine.autoreload.on': False
})
cherrypy.quickstart(WebhookServer(), '/', {'/': {}})
nginx:
location /bot {
proxy_pass http://127.0.0.1:7771/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
И ничего, на /start не реагирует
Через какое-то время валится с ошибкой:
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 504 Gateway Time-out. Response body:
[b'{"ok":false,"error_code":504,"description":"Gateway Timeout"}']