1

I'm looking to deploy my python-telegram bot on Heroku but the bot seems to be unresponsive. The .py works just fine locally, but when I deploy it the app builds perfectly and is on, but produces no response on telegram when prompted. The code is very basic but I think I am missing something with the webhook maybe? I'm new to web stuff as my background is more in data science. Below is my code and procfile.

"""import telegram
from telegram.ext import Updater
from telegram.ext import CommandHandler
import ftx
client = ftx.FtxClient()

telegram_bot_token = "token"

updater = Updater(token=telegram_bot_token, use_context=True)
dispatcher = updater.dispatcher


def start(update, context):
    chat_id = update.effective_chat.id
    context.bot.send_message(chat_id=chat_id, text= "1 ***=" + "$" + str(client.get_market('***/USD')['last']) + "\n" + "24 Change =" + str(round(client.get_market('***/USD')['change24h'],2)*100) + "%" + "\n" + "24 Hour Volume =" + str(client.get_market('***/USD')['volumeUsd24h']) + "USD"
                             + "\n"*2 + "The information presented by the price tracker is not meant to be taken as financial advice.")

#I think over here I need something else 
dispatcher.add_handler(CommandHandler("***", start))
updater.start_polling()"""

#Proc
"""worker: python bot.py"""

I'm happy to write a if dunder main, but I'm unsure still if I even need a webhook. Thanks!

1 Answer 1

1

AFAIK Heroku doesn't support long polling, so you should use a webhook. python-telegram-bot comes with a built-in webhook. See here and also this skeleton-repo.

Sign up to request clarification or add additional context in comments.

1 Comment

The following code needs to be changed : dispatcher.add_handler(CommandHandler("***", start)) updater.start_polling() to updater.start_webhook(listen="0.0.0.0", port=int(PORT), webhook_url='https://app-name.herokuapp.com/') updater.idle()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.