I am trying to set up a webcam bot telegram on heroku. I use: pyTelegramBotAPI Here is my code:

import os import telebot from flask import Flask, request token = os.environ['TELEGRAM_TOKEN'] bot = telebot.TeleBot(token) server = Flask(__name__) @bot.message_handler(commands=['start']) def start(message): bot.reply_to(message, 'Hello, ' + message.from_user.first_name) @bot.message_handler(func=lambda message: True, content_types=['text']) def echo_message(message): bot.reply_to(message, message.text) @server.route("/bot", 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://somename.herokuapp.com/bot") #пробывал и https://somename.herokuapp.com return "!", 200 server.run(host="0.0.0.0", port=int(os.environ.get('PORT', 5000))) server = Flask(__name__) 

In the logs, heroku * Running on http://0.0.0.0:16845/ (Press CTRL+C to quit) but the bot does not respond. My procfile file: web: python bot.py

    1 answer 1

     port=os.environ.get('PORT', 5000) 

    Here dynamic typing played a cruel joke with you. Environment variables are always strings, so a conversion must be made.

     port=int(os.environ.get('PORT', 5000) 
    • Thanks for the response, but unfortunately it did not help. - Andry
    • Do not tell me the link '(url = " git.heroku.com/myappname.git" )' in the correct format? - Andry
    • It seems to me, too, there is no appname.herokuapp.com that should be like this - orlovw
    • Supplemented, could you vzglyag again? - Andry
    • I don’t see anything strange, I just use another lib (py-telegram-bot), so I don’t have to say that the code is correct - orlovw