Telegram Bot - Webhook - PullRequest
       24

Telegram Bot - Webhook

0 голосов
/ 09 февраля 2020

Я развернул своего бота-телеграммы через GitHub в Heroku (я использую Webhook), бот работает, но по какой-то причине он не получает сообщения через веб-крючок.

Вот код:

import os
import telebot
from flask import Flask, request

#I deleted an irrelevant code here for the question ...
server = Flask(__name__) 

TOKEN = "..."
bot = telebot.TeleBot(token=TOKEN)

@bot.message_handler(commands=['start']) # welcome message handler
def send_welcome(message):
    #I deleted an irrelevant code here for the question ...


@bot.message_handler(commands=['help']) # help message handler
def send_welcome(message):
    #I deleted an irrelevant code here for the question ...


@bot.message_handler(func=lambda msg: msg.text)
def converter(message):
   #I deleted an irrelevant code here for the question ...


@server.route('/' + TOKEN, methods=['POST'])
def getMessage():
    bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
    return "!", 200


@server.route("/")
def webhook():
    bot.remove_webhook()
    bot.set_webhook(url='https://myherokuapp.herokuapp.com/' + TOKEN)
    return "!", 200


if __name__ == "__main__":
    server.run(host="0.0.0.0", port=int(os.environ.get('PORT', 5000)))

файлы:

enter image description here

1 Ответ

0 голосов
/ 09 февраля 2020

Вы передали Procfile перед тем, как нажать на heroku?

Я также забыл зафиксировать Procfile, и приложение не запустилось.

Если это не поможет, поделитесь полным журналом git pu sh здесь.

...