-1

I was stuck for a day The bot isn't response back my command /start after setup web hook.

I swear it working fine on local with polling method. But not working after setup web hook . I'm using flask + heroku

This is my full code:

https://pastebin.com/zBesJBjb

Info : Window 10 Pro x64, Python 3.8, PythonTelegram Bot = 13.4.1

My WebhookInfo response:

{
  "ok": true,
  "result": {
    "url": "https://hello-world.herokuapp.com/xxxx",
    "has_custom_certificate": false,
    "pending_update_count": 0,
    "max_connections": 40,
    "ip_address": "54.165.0.49"
  }
}

My log after deploy to heroku: https://pastebin.com/sFD403LU

isherwood
  • 58,414
  • 16
  • 114
  • 157

1 Answers1

0

IISC, you don't process the incoming updates anywhere in webhook_handler. You'll have to either call dispatcher.process_update(update) or put the update in the dispatchers update_queue if you use dispatcher.start() in order to have the update processed. Also two more notes:

  • telegram.Update.de_json(request.get_json(force=True), updater) should be changed to telegram.Update.de_json(request.get_json(force=True), updater.bot)
  • if you don't use the updater for fetching updates, you don't need it at all, you just need a Dispatcher

I recommend to have a look at PTBs wiki page about webhooks. There even is a dedicated section on Heroku. Admittedly, it uses updater.start_webhook, but I didn't really see anything in your code that explains why you're using flask instead of the built-in solution.

CallMeStag
  • 5,467
  • 1
  • 7
  • 22