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

[Suggestion] Switch to webhooks #118

Open
ajhalili2006 opened this issue May 3, 2020 · 4 comments
Open

[Suggestion] Switch to webhooks #118

ajhalili2006 opened this issue May 3, 2020 · 4 comments
Labels
enhancement This issue/pr proposes/adds a feature to the bot

Comments

@ajhalili2006
Copy link

ajhalili2006 commented May 3, 2020

About this suggestion

While long polling is used in the Guard, switching to webhooks can make the bot faster and can even catch up things missed during downtimes. That means, we need to pick a module that we can use for handling requests from Telegram. Express.js maybe a good choice, but others are available.

It should be configurable whenever they want to go back to polling by setting NODE_ENV variable to development. If they want to use webhooks by default, they need to configure config.serverApi.hostUrl and config.serverApi.tgWebhookEndpoint (defaults to /api/telegram/webhookEndpoint).

Why going to webhooks?

  • Fewer CPU cycles = faster response time
  • Bot can catch up things missed during downtimes. 48 hours is good for small networks, but how about large networks having downtimes longer than the time window?
  • More secure because Telegram knows where it sends webhook requests (unless somebody knew the API token or had SSH access). Having SSL stuff on your bot server domain is required to keep hackers from intercepting Telegram secrets.
  • We're now adding API stuff to our bot. So people can fetch global bans and integrate it with their bot, but we should add some layers of authentication and protection against spammers.

Known Issues

FAQs

Should I blame Telegraf for these issues listed above?

Maybe, but the best way is to create an issue in their Issue Tracker so they can fix it.

@wojpawlik
Copy link
Contributor

wojpawlik commented May 3, 2020

That means, we need to pick a module that we can use for handling requests from Telegram. Express.js maybe a good choice

Unnecessary. .launch can start a webhook if configured to do so.
I don't mind adding webhook?: LaunchWebhookOptions to config.

  • More secure

How?

webhookReply needs to be false.

PR welcome.

@SitiSchu
Copy link
Member

SitiSchu commented May 3, 2020

The bot picks up the last 48 Hours with long polling
Speed shouldn't be affected much since the bot wouldn't be in many groups. There's no real point of switching, it would only make the setup of the bot more tedious.

Also not sure how it's supposed to be more secure, long polling should use https

@wojpawlik wojpawlik added the enhancement This issue/pr proposes/adds a feature to the bot label May 3, 2020
@ajhalili2006
Copy link
Author

Updated the issue description to detail some more stuff.

@SitiSchu
Copy link
Member

Actually I just checked and Telegram doesn't store updates longer than 24 Hours regardless of using long polling or Webhooks:

"Incoming updates are stored on the server until the bot receives them either way, but they will not be kept longer than 24 hours."

wojpawlik added a commit that referenced this issue Sep 6, 2020
C0rn3j pushed a commit to C0rn3j/the-guard-bot that referenced this issue Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue/pr proposes/adds a feature to the bot
Projects
None yet
Development

No branches or pull requests

4 participants
@SitiSchu @wojpawlik @ajhalili2006 and others