-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Fixed webhook setup for work with revers proxy #197
Conversation
Hi, thanks for the contribution :) I get an idea of why there is an issue for setup the Bot to be used through a reverse proxy, but please is a good practice to give an explanation on the Pull Request decription for current issue and your proposed solution to allow better understand of it. Also, some change requests:
Something like: Regards. |
According to the documentation of the python-telegram-bot library, there is a parameter Based on what was described above, I decided to simply duplicate the library parameters, because it's concise and logical. |
Well the problem is that your changes modifies and breaks how the user setup the Bot for Webhook when no proxy is used, this is why I prefer to just check with an if statement if the PROXY_URL variable is set, so in that case we apply your suggestion of single setting for the full URL, otherwise (for no proxy usage) we kept the same procedure and settings variables. Also forgot to question: did you test your solution, and were you able to receive Telegram events using an intermidiate proxy? |
mmm, I think I get a bit more of your point, taking a look into intenal PTB (python-telegram-bot) library implementation it seems that there is 2 ways for setting up the webhook: A. Only using "listen", "port" and "url_path" arguments (that will intenally create the "web_url" in the way "https://listen:port/url_path"). B. Using "web_url", "listen", "port" and "url_path" arguments (web_url won't be created by python-telegram-bot; and this allow to setup the proxy address here). So your proposal is to use option B, so "web_url" will be the Proxy URL were Telegram Server will talk with it, then "listen" and "port" values are from the system that runs the Bot and not the Proxy, is that right? |
Yes, this code is working for me right now. Public bot @kvazimoda24_capcha_bot |
I want to point out that it is not safe to use a bot token in an address. We definitely need to get rid of this. And this change will already break compatibility. And since we are breaking compatibility, then it’s normal to do it, and not these half measures. Launching a bot is not something simple, like copying a file from a flash drive to a computer. And this requires a certain competence from a person. We have a saying in Russia: “Make a product that any idiot can use, and only an idiot will use it.” Sometimes I think you think the people who use this bot are fools who can't understand the purpose of a couple of options. :) |
My logic in this matter is simple: we set a link that we will transfer to the Telegram server ( |
And I'll add more. I use a lot of different software. These are JetBrains YouTrack, and NextCloud, and Passwork... And everywhere there is an analogue of the |
So your proposal is to use option B, so "web_url" will be the Proxy URL were Telegram Server will talk with it, then "listen" and "port" values are from the system that runs the Bot and not the Proxy, is that right? In that case the best solution will be to keep all the next settings and setup the webhook as follow: app.run_webhook(
listen=CONST["WEBHOOK_HOST"],
port=CONST["WEBHOOK_PORT"],
url_path=CONST["WEBHOOK_PATH"],
webhook_url=CONST["WEBHOOK_URL"],
key=CONST["WEBHOOK_CERT_PRIV_KEY"],
cert=CONST["WEBHOOK_CERT"],
secret_token=CONST["WEBHOOK_SECRET_TOKEN"],
drop_pending_updates=True,
allowed_updates=Update.ALL_TYPES
) |
Using the |
In this context "Host" doesn't mean "Hostname", it is expected for the Host address, but I agree that can be renamed to "WEBHOOK_IP" or "WEBHOOK_ADDRESS" for a better understanding. It could be set to fixed "0.0.0.0" in the settings.py by default. |
Anything that can be misunderstood will be misunderstood. Therefore, it is better to actually use either "ADDRESS" or "IP". In the end, it looks like we have reached a consensus. |
I don't have much experience with Github. Tell me, should I make changes to my pull request? |
Sure, feel free to add new commits according to this whenever you want ;) |
You can just add new changes and commits to your fork branch, then when you push, that changes should automatically update and appear in this Merge Request. Of course, if you have any issue you can open a new Pull Request, but feel free to use current one as test scenario for you to test and check how Github work in this regards ;) |
I did as agreed. The descriptions seem to have been corrected everywhere too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, all good!
Thanks a lot, I'm going to merge now.
Best regards.
No description provided.