webhook: stay with simple mode

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-02-20 08:34:42 +01:00
parent 8b18f25c88
commit 70724427d9

View File

@ -4,9 +4,12 @@
### Webhooks
Bashbot default mode is to poll Telegram server for updates but Telegram offers also webhook
Bashbot default mode is to poll Telegram server for updates but Telegram offers webhook
as a more efficient method to deliver updates.
If your server is reachable from the Internet you can use the webhook method described here.
If your server is reachable from the Internet you can use the methods described here.
You need a valid SSL certificate or Telegram will refuse to deliever update via webhook.
A self signed certificate will not be sufficient.
#### Setup Apache webhook
@ -31,33 +34,20 @@ will append `{"test":"me"}` to the file `data-bot-bash/webhook-fifo-<botname>`.
Now your Apache is ready to forward data to Bashbot.
#### Simple update processing
#### Enable update processing for Bashbot
To configure `Simple update processing` delete the file `data-bot-bash/webhook-fifo-<botname>` after your webhook is working.
To enable update processing delete the file `data-bot-bash/webhook-fifo-<botname>` after your webhook is working manually.
All webhook calls are now forwarded to `bin/process_update.sh` for processing.
To start `Simple processing ` enable webhook on Telegram (_see below_).
Every incoming Telegram update load Bashbot once for processing one command. Even it seems overkill to load
Bashbot on every incoming update, it's more responsive and create less server load for low traffic bots.
Bashbot on every incoming update, it's more responsive and create less server load than polling Telegram
If your bot uses `addons` or `BASHBOT_EVENTs` you can't use `Simple processing`.
If your bot uses `addons` or `BASHBOT_EVENTs` you can't use webhooks as described here.
*Note:* `Simple processing` works without running `bashbot.sh start`.
*Note:* webhook work without running `bashbot.sh start`.
#### High traffic processing
#### CURRENTLY NOT IMPLEMENTED
High traffic processing writes Telegram updates to the named pipe `data-bot-bash/webhook-fifo`
and Bashbot poll them, this is much more efficient than polling Telegram server.
To switch from `Simple processing` to `High traffic processing` start bashbot as `bashbot.sh start-webhook`.
Stop bashbot with `bashbot.sh stop` to switch back to `Simple processing`
#### Enable webhook on Telegram
#### Enable webhook on Telegram side
To get updates via webhook your server must be reachable from the internet and you must
instruct Telegram where to deliver updates, this is done by calling bashbot function `set_webhook`.
@ -73,8 +63,24 @@ After you enable webhook to deliver Telegram updates it's no more possible to po
To stop delivering of Telegram updates via webhook run `bin/any_command.sh delete_webhook`.
**Important**: Only https connections with a valid certificate chain are allowed as endpoint for webhook.
**Important**: Telegram will refuse to deliver updates if your webhook has no valid SSL certificate chain.
#### $$VERSION$$ v1.45-dev-28-g9958b5b
#### Bash webhook
A pure bash webhook implementaition is not possible without additional software because Telegram deliver
updates only over secure TLS connections and if a valid SSL certificate chain exists.
`socat` looks like a tool we can use to listen for Telegram updates from bash scripts, let's see ...
#### High traffic processing?
Initially I planned to implement a mode for `High traffic update processing` where Bashbot is started once
and read updates from the named pipe `data-bot-bash/webhook-fifo-<botname>`, similar like polling from Telegram.
But the default webhook method is so convincing and responsive that a special high traffic mode is not necessary.
#### $$VERSION$$ v1.45-dev-39-g8b18f25