Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string webhookUrl(getenv("WEBHOOK_URL")); #284

Open
Notorious-little opened this issue Jul 18, 2023 · 4 comments
Open

string webhookUrl(getenv("WEBHOOK_URL")); #284

Notorious-little opened this issue Jul 18, 2023 · 4 comments

Comments

@Notorious-little
Copy link

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 !

@EugeneSmile
Copy link
Contributor

EugeneSmile commented Jul 18, 2023

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.

@Notorious-little
Copy link
Author

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 ?

@EugeneSmile
Copy link
Contributor

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.

@Notorious-little
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants