diff --git a/README.html b/README.html index 4d91e68..9a235df 100644 --- a/README.html +++ b/README.html @@ -5,78 +5,82 @@
Uses JSON.sh and the magic of sed.
Even bashbot is written in bash, it depends on commands typically available in a Unix/Linux Environment. More concrete on the common commands provided by recent versions of coreutils, busybox or toybox, see Developer Notes
Note for MacOS and BSD Users: As bashbot heavily uses modern bash and (gnu) grep/sed features, bashbot will not run without installing additional software, see Install Bashbot
-Note for embedded systems: busybox or toybox ONLY is not sufficient, you need a to install a "real" bash, see also Install Bashbot
+Note for embedded systems: busybox or toybox ONLY is not sufficient, you need a to install a "real" bash, see also Install Bashbot
Bashbot Documentation and Downloads are available on www.github.com
Now open a terminal and check if bash is installed:
which bash && echo "bash seems available..."
-Create a new directory, change to it: mkdir tbb; cd tbb
and download the latest '*.tar.gz' file from https://github.com/topkecleon/telegram-bot-bash/releases. This can be done with the commands:
Create a new directory, change to it: mkdir tbb; cd tbb
and download the latest '*.tar.gz' file from https://github.com/topkecleon/telegram-bot-bash/releases. This can be done with the commands:
wget -q https://github.com/$(wget -q https://github.com/topkecleon/telegram-bot-bash/releases/latest -O - | egrep '/.*/.*/.*tar.gz' -o)
Extract the '*.tar.gz' file and change to bashbot directory: tar -xzf *.tar.gz; cd telegram-bot-bash
, install bashbot: ./bashbot.sh init
and enter your bot token when asked. All other questions can be answered by hitting the <Return> key.
That's all, now you can start your bot with ./bashbot.sh start
and send him messages:
/start
@@ -196,18 +200,18 @@ It features background tasks and interactive chats, and can serve as an interfac
A powerful tool to improve your scripts is shellcheck
. You can use it online or install shellcheck locally. Shellcheck is used extensively in bashbot development to ensure a high code quality, e.g. it's not allowed to push changes without passing all shellcheck tests. In addition bashbot has a test suite to check if important functionality is working as expected.
Use printf whenever possible
If you're writing a script and it is taking external input (from the user as arguments or file system...), you shouldn't use echo to display it. Use printf whenever possible
- # very simple
- echo "text with variables. PWD=$PWD"
- printf '%s\n' "text with variables. PWD=$PWD"
- -> text with variables. PWD=/home/xxx
-
- # more advanced
- FLOAT="1.2346777892864" INTEGER="12345.123"
- echo "text with variabeles. float=$FLOAT, integer=$INTEGER, PWD=$PWD"
- ->text with variables. float=1.2346777892864, integer=12345.123, PWD=/home/xxx
-
- printf "text with variables. float=%.2f, integer=%d, PWD=%s\n" "" "$INTEGER" "$PWD"
- ->text with variables. float=1.23, integer=12345, PWD=/home/xxx
+ # very simple
+ echo "text with variables. PWD=$PWD"
+ printf '%s\n' "text with variables. PWD=$PWD"
+ -> text with variables. PWD=/home/xxx
+
+ # more advanced
+ FLOAT="1.2346777892864" INTEGER="12345.123"
+ echo "text with variabeles. float=$FLOAT, integer=$INTEGER, PWD=$PWD"
+ ->text with variables. float=1.2346777892864, integer=12345.123, PWD=/home/xxx
+
+ printf "text with variables. float=%.2f, integer=%d, PWD=%s\n" "" "$INTEGER" "$PWD"
+ ->text with variables. float=1.23, integer=12345, PWD=/home/xxx
Do not use #!/usr/bin/env bash
We stay with /bin/bash shebang, because it's more save from security perspective.
Use of a fixed path to the system provided bash makes it harder for attackers or users to place alternative versions of bash and avoids using a possibly broken, mangled or compromised bash executable.
@@ -237,38 +241,38 @@ It features background tasks and interactive chats, and can serve as an interfac
Can I send messages from CLI and scripts?
Of course, you can send messages from CLI and scripts, simply install bashbot as described here, send the message '/start' to set yourself as botadmin and stop the bot with ./bashbot.sh stop
.
Run the following commands in your bash shell or script while you are in the installation directory:
-# prepare bash / script to send commands
-export BASHBOT_HOME="$(pwd)"
-source ./bashbot.sh source
-
-# send me a test message
-send_message "$(getConfigKey "botadmin")" "test"
-
-# send me output of a system command
-send_message "$(getConfigKey "botadmin")" "$(df -h)"
+# prepare bash / script to send commands
+export BASHBOT_HOME="$(pwd)"
+source ./bashbot.sh source
+
+# send me a test message
+send_message "$(getConfigKey "botadmin")" "test"
+
+# send me output of a system command
+send_message "$(getConfigKey "botadmin")" "$(df -h)"
For more information see Expert Use
Blocked by telegram?
This may happen if to many or wrong requests are sent to api.telegram.org, e.g. using a invalid token or not existing API calls. If the block stay for longer time you can ask telegram service to unblock your IP-Adress.
You can check with curl or wget if you are blocked by Telegram:
-curl -m 10 https://api.telegram.org/bot
-#curl: (28) Connection timed out after 10001 milliseconds
-
-wget -t 1 -T 10 https://api.telegram.org/bot
-#Connecting to api.telegram.org (api.telegram.org)|46.38.243.234|:443... failed: Connection timed out.
+curl -m 10 https://api.telegram.org/bot
+#curl: (28) Connection timed out after 10001 milliseconds
+
+wget -t 1 -T 10 https://api.telegram.org/bot
+#Connecting to api.telegram.org (api.telegram.org)|46.38.243.234|:443... failed: Connection timed out.
Since Version 0.96 bashbot offers the option to recover from broken connections (aka blocked). Therefore you can provide a function named bashbotBlockRecover()
in mycommands.sh
. If the function exists it is called every time when a broken connection is detected.
Possible actions are: Check if network is working, change IP-Adress or simply wait some time.
If everything seems OK return 0 for retry or any non 0 value to give up.
-# called when bashbot sedn command failed because we can not connect to telegram
-# return 0 to retry, return non 0 to give up
-bashbotBlockRecover() {
- # place your commands to unblock here, e.g. change IP-Adess or simply wait
- sleep 60 && return 0 # may be temporary
- return 1
- }
-
+# called when bashbot sedn command failed because we can not connect to telegram
+# return 0 to retry, return non 0 to give up
+bashbotBlockRecover() {
+ # place your commands to unblock here, e.g. change IP-Adess or simply wait
+ sleep 60 && return 0 # may be temporary
+ return 1
+ }
+
@Gnadelwartz
That's it all guys!
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
-$$VERSION$$ v1.1-29-ga1773cc
+$$VERSION$$ v1.2-pre2-0-g2824487