From 24158142f97647b29db95aa565b83e9e4776097f Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Mon, 1 Mar 2021 19:40:53 +0100 Subject: [PATCH] init: bashbot.rc: bashbotdir --- bashbot.rc | 5 +++-- bin/bashbot_init.inc.sh | 4 ++-- examples/webhook/README.md | 13 +++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bashbot.rc b/bashbot.rc index 0ff801d..f0f1ad4 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -5,7 +5,7 @@ # # tested on: ubuntu, opensuse, debian # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-59-ga9ac7ea # shellcheck disable=SC2009 # shellcheck disable=SC2181 @@ -35,7 +35,8 @@ runas="nobody" # edit the values of the following lines to fit your config: # your bot installation dir -bashbot="cd /usr/local/telegram-bot-bash; /usr/local/telegram-bot-bash/bashbot.sh" +bashbotdir="/usr/local/telegram-bot-bash" +bashbot="cd ${bashbotdir}; ${bashbotdir}/bashbot.sh" # your bot name as given to botfather, e.g. mysomething_bot name="" # set additionl parameter, e.g. debug diff --git a/bin/bashbot_init.inc.sh b/bin/bashbot_init.inc.sh index d5ece74..e12fc5a 100644 --- a/bin/bashbot_init.inc.sh +++ b/bin/bashbot_init.inc.sh @@ -11,7 +11,7 @@ # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 27.01.2021 13:42 # -#### $$VERSION$$ v1.45-dev-3-g429c230 +#### $$VERSION$$ v1.45-dev-59-ga9ac7ea #=============================================================================== # shellcheck disable=SC2059 @@ -116,7 +116,7 @@ bot_init() { if [ -w "bashbot.rc" ]; then printf "Adjust user and botname in bashbot.rc ...\n" sed -i '/^[# ]*runas=/ s|runas=.*$|runas="'"${touser}"'"|' "bashbot.rc" - sed -i '/^[# ]*bashbot=/ s|bashbot=.*$|bashbot="cd '"${PWD}"'; '"${PWD}"'/'"${0##*/}"'"|' "bashbot.rc" + sed -i '/^[# ]*bashbotdir=/ s|bashbotdir=.*$|bashbotdir="'"${PWD}"'"|' "bashbot.rc" botname="$(getConfigKey "botname")" [ -n "${botname}" ] && sed -i '/^[# ]*name=/ s|name=.*$|name="'"${botname}"'"|' "bashbot.rc" printf "Done.\n" diff --git a/examples/webhook/README.md b/examples/webhook/README.md index b09072b..e92e70b 100644 --- a/examples/webhook/README.md +++ b/examples/webhook/README.md @@ -7,7 +7,7 @@ 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 its possible to use the method described here. -Prerequisite for receiving Telegram unpdates with webhook is a valid SSL certificate, a self signed certificate will not be sufficient. +Prerequisite for receiving Telegram updates with webhook is a valid SSL certificate, a self signed certificate will not be sufficient. *Note:* You need at least sudo rights to setup webhook. @@ -22,7 +22,7 @@ Setup webhook with Apache: - install bashbot as described in [Bashbot Installation](../../doc/0_install.md) - create file `data-bot-bash/webhook-fifo-` (_\ as in `botconfig.jssh`_) - run `sudo bashbot.sh init` to setup bashbot to run as same user as Apache (_e.g. www_) -- go to apache web root and create the directory `telegram/` (_ as `botconfig.jssh`_) +- create a directory in web root: `telegram/` (_ as `botconfig.jssh`_) - go into the new directory and copy all files from `examples/webhook` to it - edit file `BASHBOT_HOME` to contain ithe Bashbot installation directory as first line (_other lines are ignored_) - execute `php index.php` to test if script has write access to `data-bot-bash/webhook-fifo- @@ -36,12 +36,12 @@ Now your Server is ready to receive updates from Telegram. #### Default webhook processing -This is the testet and supported default method for receiving and processing Telegram updates over webhook. +This is the testet and supported default method for processing Telegram updates over webhook. -To enable update processing delete the file `data-bot-bash/webhook-fifo-` after your webhook is working as described above. +To enable update processing delete the file `data-bot-bash/webhook-fifo-` if webhook is working as described above. Incoming Telegram updates are now forwarded to the script `bin/process_update.sh` for processing. -On every incoming Telegram update the script is executed, source bashbot.sh and forward the update to Bashbot processing.i +On incoming Telegram updates the script is executed, it sources bashbot.sh and forward the update to Bashbot for processing. Even it seems overhead to source Bashbot for every update, it's more responsive and create less load than Bashbot polling mode. Nevertheles there are some limitations compared to polling mode: @@ -64,6 +64,7 @@ There is no support for running the script in background, as a service or an oth The script read updates from given file line by line and forward updates to Bashbot update processing. `--startbot` will run the startup actions (_e.g. load addons, start TIMER, trigger first run_) and `--watch` will wait for new updates instead of exit on end of file. +Short form: 'bin/process-batch.sh -s -w' To switch back to default processing delete fifo `data-bot-bash/webhook-fifo-` and kill `bin/process-batch.sh`. @@ -94,5 +95,5 @@ webhook updates only over secure TLS connections with a valid SSL certificate ch `socat` looks like a tool to listen for Telegram updates from bash scripts, let's see ... -#### $$VERSION$$ v1.45-dev-58-ga473e25 +#### $$VERSION$$ v1.45-dev-59-ga9ac7ea