Я использую webhook Это мой код
from flask import Flask, request
import telebot
import os
server = Flask(__name__)
TOKEN = 'mytoken'
bot = telebot.TeleBot(TOKEN)
port = int(os.environ.get("PORT", 5000))
@server.route('/')
def webhook():
bot.remove_webhook()
bot.set_webhook(url="https://myapp.herokuapp.com/bot")
return "!", 200
@server.route("/bot", methods=['POST'])
def getMessage():
bot.process_new_messages([telebot.types.Update.de_json(request.stream.read().decode("utf-8")).message])
return "!", 200
@bot.message_handler()
def start(message):
bot.send_message(message.chat.id, 'Hi')
server.run(host='0.0.0.0', port=port)
После запуска я ожидаю, что бот ответит мне привет, но я не получаю ответ.
Вот мои логи:
2019-11-02T08:04:58.053161+00:00 heroku[web.1]: Process exited with status 143
2019-11-02T08:04:59.706946+00:00 heroku[web.1]: Starting process with command `python app.py`
2019-11-02T08:05:02.375606+00:00 app[web.1]: * Serving Flask app "app" (lazy loading)
2019-11-02T08:05:02.375635+00:00 app[web.1]: * Environment: production
2019-11-02T08:05:02.375637+00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2019-11-02T08:05:02.375663+00:00 app[web.1]: Use a production WSGI server instead.
2019-11-02T08:05:02.375687+00:00 app[web.1]: * Debug mode: off
2019-11-02T08:05:02.376499+00:00 app[web.1]: * Running on http://0.0.0.0:4625/ (Press CTRL+C to quit)
2019-11-02T08:05:03.346455+00:00 heroku[web.1]: State changed from starting to up
2019-11-02T08:05:03+00:00 app[api]: Build succeeded
Бот Telegram
С чем это может быть связано