1

I deployed my telegram bot via GitHub to Heroku (I use Webhook), the bot is running, but for some reason it does not receive messages through the webhook.

Here's the code:

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)))

the files:

enter image description here

Erik Van Moon
  • 47
  • 1
  • 1
  • 7

1 Answers1

0

Did you commit the Procfile before pushing to heroku?

I also forgot to commit the Procfile and so the app didn't run.

If this doesn't help then please share the complete git push log here.

abprime
  • 76
  • 1
  • 8