go-telegram-bot-api / telegram-bot-api

Golang bindings for the Telegram Bot API
https://go-telegram-bot-api.dev
MIT License
5.62k stars 868 forks source link

WebHooks not working 😠 #605

Open hardskulls opened 1 year ago

hardskulls commented 1 year ago

When I use

webhook, err := tgbotapi.NewWebhook(host + ":" + port + "/" + bot.Token)
updates := bot.ListenForWebhook("/" + bot.Token)

(took it from docs) it doesn't work at all, (tested locally with ngrok and localtunnel, ngrok doesn't even get anything) , but when I use this (currently on heroku):

webhook, err := tgbotapi.NewWebhook(host + bot.Token)
updates := bot.ListenForWebhook("/" + bot.Token)

it works just fine.

Is it a bug, or did I miss something in the docs?

k2589 commented 1 year ago

Hey @hardskulls !

If you use ngrok, for example it gives you https://ee84-20-20-20.eu.ngrok.io, just use

webhook, err := tgbotapi.NewWebhook("https://ee84-20-20-20.eu.ngrok.io/" + bot.Token)
fardeadok commented 4 weeks ago

When I use

webhook, err := tgbotapi.NewWebhook(host + ":" + port + "/" + bot.Token)
updates := bot.ListenForWebhook("/" + bot.Token)

(took it from docs) it doesn't work at all, (tested locally with ngrok and localtunnel, ngrok doesn't even get anything) , but when I use this (currently on heroku):

webhook, err := tgbotapi.NewWebhook(host + bot.Token)
updates := bot.ListenForWebhook("/" + bot.Token)

it works just fine.

Is it a bug, or did I miss something in the docs?

after updates := bot.ListenForWebhook("/" + bot.Token) need to go http.ListenAndServe("0.0.0.0:8443", nil) yes?