thedevs-network / the-guard-bot

The Guard, a Telegram bot to moderate groups.
https://t.me/thedevs_bot
GNU Affero General Public License v3.0
491 stars 162 forks source link

[Suggestion] Switch to webhooks #118

Open ajhalili2006 opened 4 years ago

ajhalili2006 commented 4 years ago

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?

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 commented 4 years ago

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 commented 4 years ago

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

ajhalili2006 commented 4 years ago

Updated the issue description to detail some more stuff.

SitiSchu commented 4 years ago

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."