reo7sp/tgbot-cpp

string webhookUrl(getenv("WEBHOOK_URL"));

Notorious-little opened this issue · 4 comments

Hi! please help me to use this method: what may i insert unstead of WEBHOOK_URL?
i tried "https://api.telegram.org/", "https://api.telegram.org" - that does not works :( my bot just keeps silence. Thanks !

This have to be an address of your server:
In case of webhook scheme, it is not you who request updates from Telegram server, but Telegram sends updates to you as soon as it has some. To do so, Telegram has no know where to send updates. And this is what webhook url is.
There is really good instruction about webhook available on the Telegram website.

Thank you! So, i did not fully understand everything that is written on the telegram website, but tired to do
string webhookUrl("https://92.46.255.210:8443");
printf("Webhook url: %s\n", webhookUrl.c_str());
and it did not worked :(

As far as I understand, we should not make certificates when we use this tgbot-cpp library, and
the goal is just to specify the correct string webhookUrl, isn't it ?

No, providing correct details to Telegram (your certificate in this case) is responsibility on your side, library cannot do this instead of you. In this case you have two options:

  • If you have proper certificate issued by trusted source, you probably would like to use some kind of proxy prior to bot dealing with all necessary TLS things for you (e.g. nginx). In this case you can provide only domain name as webhook url.
  • If you have self-signed certificate, you have to provide your root certificate to Telegram. This is what library can help you with: second parameter in setWebhook. There is a possibility to use an ip address as webhook url in this case as in your example above, but keep in mind that you still have to deal with all necessary TLS procedures since Telegram expects to have proper secured connection with you.

Thanks for answer! Actually it seems that webhooks will not add much to the speed of the server, polling works well. Please tell me, how can i make the url-requests in an asynchronous way? So that my server is not blocked while waiting for a response and can process requests from several users at the same time