From aaa71c80d68971127909d7c790698e77a3b22ed9 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 15 May 2020 18:49:38 +0200 Subject: [PATCH 01/10] fix deleteKeyDB --- modules/jsonDB.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index d737147..39fabe3 100644 --- a/modules/jsonDB.sh +++ b/modules/jsonDB.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-13-g52bde30 +#### $$VERSION$$ v0.94-pre-14-gc02327f # # source from commands.sh to use jsonDB functions # @@ -108,14 +108,13 @@ if _exists flock; then # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..' jssh_deleteKeyDB() { [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 + local DB; DB="$(jssh_checkDB "$2")" declare -A oldARR # start atomic delete here, exclusive max wait 10s { flock -e -w 10 200 Json2Array "oldARR" <"${DB}" - if [[ -v "oldAR[$1]" ]] ; then - unset oldARR["$1"] - Array2Json "oldARR" >"${DB}" - fi + unset oldARR["$1"] + Array2Json "oldARR" >"${DB}" } 200>"${DB}${BASHBOT_LOCKNAME}" } @@ -238,11 +237,10 @@ jssh_insertDB_async() { jssh_deleteKeyDB_async() { [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 + local DB; DB="$(jssh_checkDB "$2")" declare -A oldARR jssh_readDB_async "oldARR" "$2" || return "$?" - if [[ -v "oldAR[$1]" ]] ; then - unset oldARR["$1"] - jssh_writeDB_async "oldARR" "$2" - fi + unset oldARR["$1"] + jssh_writeDB_async "oldARR" "$2" } From f13a2d05cc64259be59e33391fd5051b57e7aaf8 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 15 May 2020 18:52:12 +0200 Subject: [PATCH 02/10] almost finished for 0.94 --- README.html | 2 +- README.md | 2 +- README.txt | 2 +- addons/antiFlood.sh | 2 +- addons/example.sh | 2 +- bashbot.rc | 2 +- bashbot.sh | 2 +- commands.sh | 2 +- dev/all-tests.sh | 2 +- dev/git-add.sh | 2 +- dev/hooks/pre-commit.sh | 2 +- dev/hooks/pre-push.sh | 2 +- dev/install-hooks.sh | 2 +- dev/make-distribution.sh | 2 +- dev/make-standalone.sh | 2 +- dev/shellcheck.files | 2 +- dev/version.sh | 2 +- doc/0_install.md | 2 +- doc/1_firstbot.md | 2 +- doc/2_usage.md | 2 +- doc/3_advanced.md | 2 +- doc/4_expert.md | 2 +- doc/5_practice.md | 2 +- doc/6_reference.md | 2 +- doc/7_develop.md | 2 +- examples/README.md | 2 +- examples/background-scripts/run_diskusage.sh | 2 +- examples/background-scripts/run_filecontent.sh | 2 +- examples/background-scripts/run_filename.sh | 2 +- examples/background-scripts/run_notify.sh | 2 +- examples/bashbot-multi.sh | 2 +- examples/bashbot.cron | 2 +- examples/calc.sh | 2 +- examples/notify.sh | 2 +- examples/question.sh | 2 +- examples/send-system-status/botacl | 2 +- examples/send-system-status/mycommands.sh | 2 +- modules/aliases.sh | 2 +- modules/answerInline.sh | 2 +- modules/background.sh | 2 +- modules/chatMember.sh | 2 +- modules/jsonDB.sh | 2 +- modules/sendMessage.sh | 2 +- mycommands.sh | 2 +- mycommands.sh.clean | 2 +- test/ADD-test-new.sh | 2 +- test/ALL-tests.inc.sh | 2 +- test/a-commit-test.sh | 2 +- test/b-example-test.sh | 2 +- test/c-init-test.sh | 2 +- test/d-JSON.sh-test.sh | 2 +- test/d-process_inline-test.sh | 2 +- test/d-process_message-test.sh | 2 +- test/d-send_message-test.sh | 2 +- test/d-user_is-test.sh | 2 +- test/e-env-test.sh | 2 +- 56 files changed, 56 insertions(+), 56 deletions(-) diff --git a/README.html b/README.html index deae2ec..de17863 100644 --- a/README.html +++ b/README.html @@ -223,6 +223,6 @@ It features background tasks and interactive chats, and can serve as an interfac

@Gnadelwartz

That's it!

If you feel that there's something missing or if you found a bug, feel free to submit a pull request!

-

$$VERSION$$ v0.94-pre-0-gac2ec02

+

$$VERSION$$ v0.94-0-gaaa71c8

diff --git a/README.md b/README.md index 8125661..a44951e 100644 --- a/README.md +++ b/README.md @@ -180,4 +180,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/README.txt b/README.txt index e6e3e74..6af6ed9 100644 --- a/README.txt +++ b/README.txt @@ -253,4 +253,4 @@ tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/addons/antiFlood.sh b/addons/antiFlood.sh index 6b0439d..0d9a21f 100644 --- a/addons/antiFlood.sh +++ b/addons/antiFlood.sh @@ -4,7 +4,7 @@ # this addon counts how many files, e.g. stickers, are sent to # a chat and takes actions if threshold is reached # -#### $$VERSION$$ v0.94-pre-4-gd28f975 +#### $$VERSION$$ v0.94-0-gaaa71c8 # used events: # diff --git a/addons/example.sh b/addons/example.sh index 300d53c..3bd8cbe 100644 --- a/addons/example.sh +++ b/addons/example.sh @@ -4,7 +4,7 @@ # Addons can register to bashbot events at statup # by providing their name and a callback per event # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # # If an event occours each registered event function is called. # diff --git a/bashbot.rc b/bashbot.rc index 135a39b..e76753c 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.94-pre-11-gac9ca60 +#### $$VERSION$$ v0.94-0-gaaa71c8 # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 2d03083..68cc3a8 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -11,7 +11,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-4-gd28f975 +#### $$VERSION$$ v0.94-0-gaaa71c8 # # Exit Codes: # - 0 sucess (hopefully) diff --git a/commands.sh b/commands.sh index d6aab2b..b732f5a 100644 --- a/commands.sh +++ b/commands.sh @@ -15,7 +15,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-7-g64efe96 +#### $$VERSION$$ v0.94-0-gaaa71c8 # # adjust your language setting here, e.g.when run from other user or cron. diff --git a/dev/all-tests.sh b/dev/all-tests.sh index 3734e2d..abd3247 100755 --- a/dev/all-tests.sh +++ b/dev/all-tests.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # this has to run once atfer git clone # and every time we create new hooks -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/git-add.sh b/dev/git-add.sh index 72a31b2..457836c 100755 --- a/dev/git-add.sh +++ b/dev/git-add.sh @@ -3,7 +3,7 @@ # # works together with git pre-push.sh and ADD all changed files since last push -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/hooks/pre-commit.sh b/dev/hooks/pre-commit.sh index 44d3a68..0a2e6df 100755 --- a/dev/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 ############ # NOTE: you MUST run install-hooks.sh again when updating this file! diff --git a/dev/hooks/pre-push.sh b/dev/hooks/pre-push.sh index 382ec29..c1dba63 100755 --- a/dev/hooks/pre-push.sh +++ b/dev/hooks/pre-push.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 ############ # NOTE: you MUST run install-hooks.sh again when updating this file! diff --git a/dev/install-hooks.sh b/dev/install-hooks.sh index efc98f2..7fd70fc 100755 --- a/dev/install-hooks.sh +++ b/dev/install-hooks.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # this has to run once atfer git clone # and every time we create new hooks -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/make-distribution.sh b/dev/make-distribution.sh index c839db8..62f9c7c 100755 --- a/dev/make-distribution.sh +++ b/dev/make-distribution.sh @@ -2,7 +2,7 @@ # file: make-distribution.sh # creates files and arcchives to dirtribute bashbot # -#### $$VERSION$$ v0.94-pre-12-gb1d569a +#### $$VERSION$$ v0.94-0-gaaa71c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/make-standalone.sh b/dev/make-standalone.sh index 5d3f66c..27dbcbf 100755 --- a/dev/make-standalone.sh +++ b/dev/make-standalone.sh @@ -5,7 +5,7 @@ # If you your bot is finished you can use make-standalone.sh to create the # the old all-in-one bashbot: bashbot.sh and commands.sh only! # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/shellcheck.files b/dev/shellcheck.files index c3728dd..4d49180 100644 --- a/dev/shellcheck.files +++ b/dev/shellcheck.files @@ -1,4 +1,4 @@ # list of additional files to check from shellcheck -#### $$VERSION$$ v0.94-pre-7-g64efe96 +#### $$VERSION$$ v0.94-0-gaaa71c8 bashbot.rc mycommands.sh.clean diff --git a/dev/version.sh b/dev/version.sh index a19b3a3..eca2043 100755 --- a/dev/version.sh +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # shellcheck disable=SC2016 # # Easy Versioning in git: diff --git a/doc/0_install.md b/doc/0_install.md index e105298..0ab87a8 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -87,5 +87,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index f407229..8a6486b 100644 --- a/doc/1_firstbot.md +++ b/doc/1_firstbot.md @@ -65,5 +65,5 @@ group. This step is up to you actually. #### [Prev Installation](0_install.md) #### [Next Getting started](2_usage.md) -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/doc/2_usage.md b/doc/2_usage.md index 267a78b..5589b73 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -240,5 +240,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 8fbb841..21e4dc6 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -180,5 +180,5 @@ See also [answer_inline_multi, answer_inline_compose](6_reference.md#answer_inli #### [Prev Getting started](2_usage.md) #### [Next Expert Use](4_expert.md) -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/doc/4_expert.md b/doc/4_expert.md index db099f1..5ba3b11 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -348,5 +348,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms. #### [Prev Advanced Use](3_advanced.md) #### [Next Best Practice](5_practice.md) -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/doc/5_practice.md b/doc/5_practice.md index 4355995..ccce2ce 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -152,5 +152,5 @@ The second warning is about an unused variable, this is true because in our exam #### [Prev Best Practice](5_practice.md) #### [Next Functions Reference](6_reference.md) -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/doc/6_reference.md b/doc/6_reference.md index 44a67ac..76dcda4 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -973,5 +973,5 @@ The name of your bot is availible as bash variable "$ME", there is no need to ca #### [Prev Best Practice](5_practice.md) #### [Next Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.94-pre-13-g52bde30 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/doc/7_develop.md b/doc/7_develop.md index 283c0fc..96840f9 100644 --- a/doc/7_develop.md +++ b/doc/7_develop.md @@ -328,5 +328,5 @@ fi #### [Prev Function Reference](6_reference.md) -#### $$VERSION$$ v0.94-pre-0-gac2ec02 +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/examples/README.md b/examples/README.md index ecca1de..3af1451 100644 --- a/examples/README.md +++ b/examples/README.md @@ -55,6 +55,6 @@ convert existing bots. **external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users. -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 diff --git a/examples/background-scripts/run_diskusage.sh b/examples/background-scripts/run_diskusage.sh index 7c90b44..0cbb92a 100755 --- a/examples/background-scripts/run_diskusage.sh +++ b/examples/background-scripts/run_diskusage.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_filecontent.sh b/examples/background-scripts/run_filecontent.sh index c53e686..d160cf4 100755 --- a/examples/background-scripts/run_filecontent.sh +++ b/examples/background-scripts/run_filecontent.sh @@ -2,7 +2,7 @@ # file: run_filename # background job to display content of all new files in WATCHDIR # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_filename.sh b/examples/background-scripts/run_filename.sh index 1552e0a..1d4ba25 100755 --- a/examples/background-scripts/run_filename.sh +++ b/examples/background-scripts/run_filename.sh @@ -2,7 +2,7 @@ # file: run_filename # background job to display all new files in WATCHDIR # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_notify.sh b/examples/background-scripts/run_notify.sh index ea97341..348795e 100755 --- a/examples/background-scripts/run_notify.sh +++ b/examples/background-scripts/run_notify.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/bashbot-multi.sh b/examples/bashbot-multi.sh index a0f2478..22f757b 100755 --- a/examples/bashbot-multi.sh +++ b/examples/bashbot-multi.sh @@ -2,7 +2,7 @@ # file. multibot.sh # description: run multiple telegram bots from one installation # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then echo "Usage: $0 botname command" diff --git a/examples/bashbot.cron b/examples/bashbot.cron index 88fbc26..4b26da4 100644 --- a/examples/bashbot.cron +++ b/examples/bashbot.cron @@ -7,7 +7,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 SHELL=/bin/sh diff --git a/examples/calc.sh b/examples/calc.sh index b54bf75..4ffe6e8 100755 --- a/examples/calc.sh +++ b/examples/calc.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/notify.sh b/examples/notify.sh index 89d7a74..da713f6 100755 --- a/examples/notify.sh +++ b/examples/notify.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/question.sh b/examples/question.sh index 03d4cec..98e5ef8 100755 --- a/examples/question.sh +++ b/examples/question.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/send-system-status/botacl b/examples/send-system-status/botacl index c53316e..c6fa66a 100644 --- a/examples/send-system-status/botacl +++ b/examples/send-system-status/botacl @@ -1,7 +1,7 @@ # file: botacl # a user not listed here, will return false from 'user_is_allowed' # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # Format: # user:ressource:chat diff --git a/examples/send-system-status/mycommands.sh b/examples/send-system-status/mycommands.sh index f4ec539..615e30e 100644 --- a/examples/send-system-status/mycommands.sh +++ b/examples/send-system-status/mycommands.sh @@ -5,7 +5,7 @@ # to show how you can customize bashbot by only editing mycommands.sh # NOTE: this is not tested, simply copied from original source and reworked! # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/modules/aliases.sh b/modules/aliases.sh index 4997383..5af7dfa 100644 --- a/modules/aliases.sh +++ b/modules/aliases.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-2-gc0a633f +#### $$VERSION$$ v0.94-0-gaaa71c8 # # source from commands.sh to use the aliases diff --git a/modules/answerInline.sh b/modules/answerInline.sh index 7f529ee..46e7540 100644 --- a/modules/answerInline.sh +++ b/modules/answerInline.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-2-gc0a633f +#### $$VERSION$$ v0.94-0-gaaa71c8 # source from commands.sh to use the inline functions diff --git a/modules/background.sh b/modules/background.sh index 8ef64ba..9d6d7a2 100644 --- a/modules/background.sh +++ b/modules/background.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-2-gc0a633f +#### $$VERSION$$ v0.94-0-gaaa71c8 # source from commands.sh if you want ro use interactive or background jobs diff --git a/modules/chatMember.sh b/modules/chatMember.sh index 56668ca..34f2853 100644 --- a/modules/chatMember.sh +++ b/modules/chatMember.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-5-g6c6b312 +#### $$VERSION$$ v0.94-0-gaaa71c8 # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index 39fabe3..f74c02d 100644 --- a/modules/jsonDB.sh +++ b/modules/jsonDB.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-14-gc02327f +#### $$VERSION$$ v0.94-0-gaaa71c8 # # source from commands.sh to use jsonDB functions # diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index 90b6c80..de67a72 100644 --- a/modules/sendMessage.sh +++ b/modules/sendMessage.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-pre-8-g284172f +#### $$VERSION$$ v0.94-0-gaaa71c8 # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" diff --git a/mycommands.sh b/mycommands.sh index 54021cb..ff64eec 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -8,7 +8,7 @@ # #### if you start to develop your own bot, use the clean version of this file: # #### mycommands.clean # -#### $$VERSION$$ v0.94-pre-7-g64efe96 +#### $$VERSION$$ v0.94-0-gaaa71c8 # # uncomment the following lines to overwrite info and help messages diff --git a/mycommands.sh.clean b/mycommands.sh.clean index e231a48..8def1bb 100644 --- a/mycommands.sh.clean +++ b/mycommands.sh.clean @@ -4,7 +4,7 @@ # files: mycommands.sh.clean # copy to mycommands.sh and add all your commands and functions here ... # -#### $$VERSION$$ v0.94-pre-7-g64efe96 +#### $$VERSION$$ v0.94-0-gaaa71c8 # ########## diff --git a/test/ADD-test-new.sh b/test/ADD-test-new.sh index fea7bb4..054a990 100755 --- a/test/ADD-test-new.sh +++ b/test/ADD-test-new.sh @@ -2,7 +2,7 @@ # # ADD a new test skeleton to test dir, but does not activate test # -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/test/ALL-tests.inc.sh b/test/ALL-tests.inc.sh index e275631..c3480d8 100644 --- a/test/ALL-tests.inc.sh +++ b/test/ALL-tests.inc.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-pre-4-gd28f975 +#### $$VERSION$$ v0.94-0-gaaa71c8 # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME diff --git a/test/a-commit-test.sh b/test/a-commit-test.sh index 99114a4..0c9304c 100755 --- a/test/a-commit-test.sh +++ b/test/a-commit-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 ../dev/hooks/pre-commit.sh diff --git a/test/b-example-test.sh b/test/b-example-test.sh index 540609c..7db05ba 100644 --- a/test/b-example-test.sh +++ b/test/b-example-test.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # file: b-example-test.sh -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/c-init-test.sh b/test/c-init-test.sh index dcd1f86..1e43821 100755 --- a/test/c-init-test.sh +++ b/test/c-init-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-pre-4-gd28f975 +#### $$VERSION$$ v0.94-0-gaaa71c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-JSON.sh-test.sh b/test/d-JSON.sh-test.sh index 86799da..55e14bd 100755 --- a/test/d-JSON.sh-test.sh +++ b/test/d-JSON.sh-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-process_inline-test.sh b/test/d-process_inline-test.sh index 2840507..babcca2 100755 --- a/test/d-process_inline-test.sh +++ b/test/d-process_inline-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-process_message-test.sh b/test/d-process_message-test.sh index e2ed36f..dda0fe0 100755 --- a/test/d-process_message-test.sh +++ b/test/d-process_message-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-pre-10-g23a3d4b +#### $$VERSION$$ v0.94-0-gaaa71c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-send_message-test.sh b/test/d-send_message-test.sh index b602cfc..d7d1843 100755 --- a/test/d-send_message-test.sh +++ b/test/d-send_message-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-pre-10-g23a3d4b +#### $$VERSION$$ v0.94-0-gaaa71c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-user_is-test.sh b/test/d-user_is-test.sh index b36e502..bb109d4 100755 --- a/test/d-user_is-test.sh +++ b/test/d-user_is-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/e-env-test.sh b/test/e-env-test.sh index 8668cfc..56dacf8 100755 --- a/test/e-env-test.sh +++ b/test/e-env-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev3-0-geef955a +#### $$VERSION$$ v0.94-0-gaaa71c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh From 93f49665aa69d9342f78c33830e151e4961a1830 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sat, 16 May 2020 08:49:36 +0200 Subject: [PATCH 03/10] botadmin is also an admin, better default for /start command --- commands.sh | 8 ++++---- modules/chatMember.sh | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/commands.sh b/commands.sh index b732f5a..61935c7 100644 --- a/commands.sh +++ b/commands.sh @@ -15,7 +15,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ v0.94-1-gf13a2d0 # # adjust your language setting here, e.g.when run from other user or cron. @@ -104,7 +104,7 @@ if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then '/start'*) send_action "${CHAT[ID]}" "typing" user_is_botadmin "${USER[ID]}" && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*." - if _is_botadmin || _is_allowed "start" ; then + if user_is_admin "${CHAT[ID]}" "${USER[ID]}" || user_is_allowed "${USER[ID]}" "start" ; then send_markdown_message "${CHAT[ID]}" "${bashbot_help}" else send_normal_message "${CHAT[ID]}" "You are not allowed to start Bot." @@ -115,9 +115,9 @@ if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then send_markdown_message "${CHAT[ID]}" "${bashbot_help}" ;; '/leavechat'*) # bot leave chat if user is admin in chat - if user_is_botadmin "${USER[ID]}" ; then + if user_is_admin "${CHAT[ID]}" "${USER[ID]}" || user_is_allowed "${USER[ID]}" "leave" ; then send_markdown_message "${CHAT[ID]}" "*LEAVING CHAT...*" - leave_chat "${CHAT[ID]}" + leave_chat "${CHAT[ID]}" fi ;; diff --git a/modules/chatMember.sh b/modules/chatMember.sh index 34f2853..ad9559d 100644 --- a/modules/chatMember.sh +++ b/modules/chatMember.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ v0.94-1-gf13a2d0 # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" @@ -45,6 +45,7 @@ user_is_admin() { [ "$1" = "$2" ] && return 0 local me; me="$(get_chat_member_status "$1" "$2")" if [ "${me}" = "creator" ] || [ "${me}" = "administrator" ]; then return 0; fi + user_is_botadmin "$2" && return 0 return 1 } From 96fda449b53108bf002cb2a234a8525d5158485c Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sat, 16 May 2020 22:10:12 +0200 Subject: [PATCH 04/10] add admin checks to mycommands --- mycommands.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mycommands.sh b/mycommands.sh index ff64eec..5c486ce 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -8,7 +8,7 @@ # #### if you start to develop your own bot, use the clean version of this file: # #### mycommands.clean # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ v0.94-2-g93f4966 # # uncomment the following lines to overwrite info and help messages @@ -32,6 +32,9 @@ export FILE_REGEX="${BASHBOT_ETC}/.*" # set to "yes" and give your bot admin privilegs to remove service messaes from groups export SILENCER="no" +# messages for admin only commands +NOTADMIN="Sorry, this command is allowed for admin or owner only" +NOTBOTADMIN="Sorry, this command is allowed for bot owner only" if [ "$1" = "startbot" ];then ################### @@ -63,6 +66,25 @@ else fi fi + # pre-check admin only commands + case "${MESSAGE}" in + # must be private, group admin, or botadmin + '/run_'*|'stop_'*) + send_action "${CHAT[ID]}" "typing" + if ! user_is_admin "${CHAT[ID]}" "${USER[ID]}" ; then + send_normal_message "${CHAT[ID]}" "${NOTADMIN}"; return 1 + fi + # ok, now lets process the real command + ;; + # must be botadmin + '/echo'*) + send_action "${CHAT[ID]}" "typing" + if ! user_is_botadmin "${USER[ID]}" ; then + send_markdown_message "${CHAT[ID]}" "*${NOTBOTADMIN}*"; return 1 + fi + ;; + esac + case "${MESSAGE}" in ################## # example commands, replace thm by your own From cbce60a3b032a46b7ea7cd55d52c588404b1c470 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 17 May 2020 12:44:16 +0200 Subject: [PATCH 05/10] support script to convert /bin/bash to /usr/bin/env --- examples/bash2env.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 examples/bash2env.sh diff --git a/examples/bash2env.sh b/examples/bash2env.sh new file mode 100755 index 0000000..a448195 --- /dev/null +++ b/examples/bash2env.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# file: bash2env.sh +# simole helper script to convert bash shebang from +# ! /bin/bash TO ! /usr/bin/env bash + +# This file is public domain in the USA and all free countries. +# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) + +#### $$VERSION$$ v0.94-3-g96fda44 + +# adjust your language setting here +# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment +export 'LC_ALL=C.UTF-8' +export 'LANG=C.UTF-8' +export 'LANGUAGE=C.UTF-8' + +unset IFS + +################ +# uncomment thenfollowing line to make the conversion +# DOIT="yes" + +if [ "$1" = "" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "$0: convert bash shebang to /usr/bin/env bash" + echo "usage: $0 script [script ...]" + exit +fi + +# loop tomprocess files +if [ "${DOIT}" = "yes" ]; then + echo "Warning, changes will be done!" +else + echo "Dry run, output changes only!" + echo "Uncomment DOIT=\"yes\" in script to make the changes permanent." + +fi + +echo "Press enter to continue ..." +#shellcheck disable=SC2034 +read -r CONTINUE + + +for file in "$@" +do + file "${file}" + if [[ "$(file -b "${file}")" =~ Bourne.*script.*text ]]; then + echo "Processing ${file} ..." + if head -n 1 "${file}" | grep -q '^#!/bin/bash'; then + if [ "${DOIT}" = "yes" ]; then + sed -i -e '1 s|^#!/bin/bash|#!/usr/bin/env bash|' "${file}" + head -n 1 "${file}" + else + sed -n -e '1 s|^#!/bin/bash|#!/usr/bin/env bash (dry run)|p' "${file}" + fi + else + echo "No #!/bin/bash shebang, nothing to convert." + fi + echo -e "... done.\n" + else + echo -e "Not a bash script, skipping ${file} ...\n" + fi +done From 6531fecfedefd5a7d2987e44e21472f77437f0fa Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 17 May 2020 13:16:01 +0200 Subject: [PATCH 06/10] update doc for MacOS --- README.html | 3 ++- README.md | 5 ++++- README.txt | 6 +++++- doc/0_install.md | 13 ++++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.html b/README.html index de17863..d5c84f2 100644 --- a/README.html +++ b/README.html @@ -150,6 +150,7 @@ Written by Drew (@topkecleon), Daniil Gentili (@danogentili), and Kay M (@gnadel
  • Examples Dir
  • Your really first bashbot in a nutshell

    +

    Note for MacOS: you must install install a more current bash, see Install Bashbot

    To install and run bashbot you need acess to a linux/unix/bsd command line. If you don't know how to get accces to a linux/unix/bsd like command line you should stop reading here :-(

    In addition you need a Telegram client and a mobile phone to register an account. If you don't want to register for Telegram you should stop reading here ;-)

    After you're registered to Telegram send a message to @botfather, create a new Telegram Bot token and write it down. You need the token to install the bot.

    @@ -223,6 +224,6 @@ It features background tasks and interactive chats, and can serve as an interfac

    @Gnadelwartz

    That's it!

    If you feel that there's something missing or if you found a bug, feel free to submit a pull request!

    -

    $$VERSION$$ v0.94-0-gaaa71c8

    +

    $$VERSION$$ v0.94-4-gcbce60a

    diff --git a/README.md b/README.md index a44951e..4a4ef2c 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,9 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do * [Examples Dir](examples/README.md) ### Your really first bashbot in a nutshell + +Note for MacOS: you must install install a more current bash, see [Install Bashbot](doc/0_install.md) + To install and run bashbot you need acess to a linux/unix/bsd command line. If you don't know how to get accces to a linux/unix/bsd like command line you should stop reading here :-( In addition you need a [Telegram client](https://telegram.org) and a mobile phone to [register an account](https://telegramguide.com/create-a-telegram-account/). @@ -180,4 +183,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ v0.94-4-gcbce60a diff --git a/README.txt b/README.txt index 6af6ed9..25f09a9 100644 --- a/README.txt +++ b/README.txt @@ -70,6 +70,10 @@ availible on www.github.com * [Examples Dir](examples/README.md) ### Your really first bashbot in a nutshell + +Note for MacOS: you must install install a more current bash, see [Install +Bashbot](doc/0_install.md) + To install and run bashbot you need acess to a linux/unix/bsd command line. If you don't know how to get accces to a linux/unix/bsd like command line you should stop reading here :-( @@ -253,4 +257,4 @@ tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ v0.94-4-gcbce60a diff --git a/doc/0_install.md b/doc/0_install.md index 0ab87a8..c83c5c3 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -1,5 +1,16 @@ #### [Home](../README.md) +## Note for Users of MacOS + +You must install a more current version of bash, as the default bash is way to old, +see e.g. [Install Bash on Mac](http://macappstore.org/bash/) + +After installation / update of bashbot you must change the shebang line to point to your bash location +e.g. with the provided script ˋexamples/bash2env.shˋ + +We stay with /bin/bash shebang, because using the system bash is more save. It makes it harder +for attackers or users to place broken, mangled or compromised bash executables. + ## Install bashbot 1. Go to the directory you want to install bashbot, e.g. @@ -87,5 +98,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ v0.94-4-gcbce60a From bdb50c87167499aaf08467f770cb4e9c7669cfe1 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 17 May 2020 13:19:21 +0200 Subject: [PATCH 07/10] allow += for jsshDB, this allows adding to keys without overwrite --- README.html | 2 +- README.md | 2 +- README.txt | 2 +- bashbot.sh | 4 ++-- doc/0_install.md | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.html b/README.html index d5c84f2..76d5471 100644 --- a/README.html +++ b/README.html @@ -224,6 +224,6 @@ It features background tasks and interactive chats, and can serve as an interfac

    @Gnadelwartz

    That's it!

    If you feel that there's something missing or if you found a bug, feel free to submit a pull request!

    -

    $$VERSION$$ v0.94-4-gcbce60a

    +

    $$VERSION$$ v0.94-5-g6531fec

    diff --git a/README.md b/README.md index 4a4ef2c..535e6f0 100644 --- a/README.md +++ b/README.md @@ -183,4 +183,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.94-4-gcbce60a +#### $$VERSION$$ v0.94-5-g6531fec diff --git a/README.txt b/README.txt index 25f09a9..5efe3f1 100644 --- a/README.txt +++ b/README.txt @@ -257,4 +257,4 @@ tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.94-4-gcbce60a +#### $$VERSION$$ v0.94-5-g6531fec diff --git a/bashbot.sh b/bashbot.sh index 68cc3a8..7d8af2c 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -11,7 +11,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ v0.94-5-g6531fec # # Exit Codes: # - 0 sucess (hopefully) @@ -344,7 +344,7 @@ JsonGetValue() { # $1 ARRAY name, must be declared with "declare -A ARRAY" before calling Json2Array() { # shellcheck source=./commands.sh - [ -z "$1" ] || source <( printf "$1"'=( %s )' "$(sed -E -n -e '/\["[-0-9a-zA-Z_,."]+"\]\t/ s/\t/=/gp' -e 's/=(true|false)/="\1"/')" ) + [ -z "$1" ] || source <( printf "$1"'=( %s )' "$(sed -E -n -e '/\["[-0-9a-zA-Z_,."]+"\]\+*\t/ s/\t/=/gp' -e 's/=(true|false)/="\1"/')" ) } # output ARRAY as JSON.sh style data # $1 ARRAY name, must be declared with "declare -A ARRAY" before calling diff --git a/doc/0_install.md b/doc/0_install.md index c83c5c3..b4dd56c 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -98,5 +98,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ v0.94-4-gcbce60a +#### $$VERSION$$ v0.94-5-g6531fec From 7aa409fbc8863b940c39d64ada79474ac97e019c Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 17 May 2020 13:51:32 +0200 Subject: [PATCH 08/10] Version 0.94 --- README.html | 6 ++++- README.md | 11 ++++++++- README.txt | 14 ++++++++++- addons/antiFlood.sh | 2 +- addons/example.sh | 2 +- bashbot.rc | 2 +- bashbot.sh | 2 +- commands.sh | 2 +- dev/all-tests.sh | 2 +- dev/git-add.sh | 2 +- dev/hooks/pre-commit.sh | 2 +- dev/hooks/pre-push.sh | 2 +- dev/install-hooks.sh | 2 +- dev/make-distribution.sh | 2 +- dev/make-standalone.sh | 2 +- dev/shellcheck.files | 2 +- dev/version.sh | 2 +- doc/0_install.md | 23 +++++++++---------- doc/1_firstbot.md | 2 +- doc/2_usage.md | 2 +- doc/3_advanced.md | 2 +- doc/4_expert.md | 2 +- doc/5_practice.md | 2 +- doc/6_reference.md | 2 +- doc/7_develop.md | 2 +- examples/README.md | 2 +- examples/background-scripts/run_diskusage.sh | 2 +- .../background-scripts/run_filecontent.sh | 2 +- examples/background-scripts/run_filename.sh | 2 +- examples/background-scripts/run_notify.sh | 2 +- examples/bash2env.sh | 2 +- examples/bashbot-multi.sh | 2 +- examples/bashbot.cron | 2 +- examples/calc.sh | 2 +- examples/notify.sh | 2 +- examples/question.sh | 2 +- examples/send-system-status/botacl | 2 +- examples/send-system-status/mycommands.sh | 2 +- modules/aliases.sh | 2 +- modules/answerInline.sh | 2 +- modules/background.sh | 2 +- modules/chatMember.sh | 2 +- modules/jsonDB.sh | 2 +- modules/sendMessage.sh | 2 +- mycommands.sh | 2 +- mycommands.sh.clean | 2 +- test/ADD-test-new.sh | 2 +- test/ALL-tests.inc.sh | 2 +- test/a-commit-test.sh | 2 +- test/b-example-test.sh | 2 +- test/c-init-test.sh | 2 +- test/d-JSON.sh-test.sh | 2 +- test/d-process_inline-test.sh | 2 +- test/d-process_message-test.sh | 2 +- test/d-send_message-test.sh | 2 +- test/d-user_is-test.sh | 2 +- test/e-env-test.sh | 2 +- 57 files changed, 92 insertions(+), 68 deletions(-) diff --git a/README.html b/README.html index 76d5471..fd03b66 100644 --- a/README.html +++ b/README.html @@ -179,6 +179,10 @@ It features background tasks and interactive chats, and can serve as an interfac

    Bash scripts in general are not designed to be bullet proof, so consider this Bot as a proof of concept. Bash programmers often struggle with 'quoting hell' and globbing, see Implications of wrong quoting

    Whenever you are processing input from from untrusted sources (messages, files, network) you must be as carefull as possible, e.g. set IFS appropriate, disable globbing (set -f) and quote everthing. In addition delete unused scripts and examples from your Bot, e.g. scripts 'notify', 'calc', 'question', and disable all not used commands.

    A powerful tool to improve your scripts is shellcheck. You can use it online or install shellcheck locally. Shellcheck is used extensive in bashbot development to enshure 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.

    +

    Do not use #!/usr/bin/env bash

    +

    We stay with /bin/bash shebang, because using the system bash is more save from security perspective.

    +

    It makes it harder for attackers and users to place alternative versions of bash and avoids using possibly broken, mangled or compromised bash executables.

    +

    If you are a MacOS user or forced to use an alternative bash, see Install Bashbot

    Run your Bot as a restricted user

    I recommend to run your bot as a user, with almost no access rights. All files your Bot have write access to are in danger to be overwritten/deleted if your bot is hacked. For the same reason ervery file your Bot can read is in danger to be disclosed. Restict your Bots access rigths to the absolute minimum.

    Never run your Bot as root, this is the most dangerous you can do! Usually the user 'nobody' has almost no rights on Unix/Linux systems. See Expert use on how to run your Bot as an other user.

    @@ -224,6 +228,6 @@ It features background tasks and interactive chats, and can serve as an interfac

    @Gnadelwartz

    That's it!

    If you feel that there's something missing or if you found a bug, feel free to submit a pull request!

    -

    $$VERSION$$ v0.94-5-g6531fec

    +

    $$VERSION$$ V0.94-0-gbdb50c8

    diff --git a/README.md b/README.md index 535e6f0..23d6cd8 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,15 @@ Whenever you are processing input from from untrusted sources (messages, files, A powerful tool to improve your scripts is ```shellcheck```. You can [use it online](https://www.shellcheck.net/) or [install shellcheck locally](https://github.com/koalaman/shellcheck#installing). Shellcheck is used extensive in bashbot development to enshure 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](doc/7_develop.md) to check if important functionality is working as expected. +### Do not use #!/usr/bin/env bash + +We stay with /bin/bash shebang, because using the system bash is more save from security perspective. + +It makes it harder for attackers and users to place alternative versions of bash and avoids using +possibly broken, mangled or compromised bash executables. + +If you are a MacOS user or forced to use an alternative bash, see [Install Bashbot](doc/0_install.md) + ### Run your Bot as a restricted user **I recommend to run your bot as a user, with almost no access rights.** All files your Bot have write access to are in danger to be overwritten/deleted if your bot is hacked. @@ -183,4 +192,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.94-5-g6531fec +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/README.txt b/README.txt index 5efe3f1..53500a3 100644 --- a/README.txt +++ b/README.txt @@ -154,6 +154,18 @@ allowed to push changes without passing all shellcheck tests. In addition bashbot has a [test suite](doc/7_develop.md) to check if important functionality is working as expected. +### Do not use #!/usr/bin/env bash + +We stay with /bin/bash shebang, because using the system bash is more save from +security perspective. + +It makes it harder for attackers and users to place alternative versions of +bash and avoids using +possibly broken, mangled or compromised bash executables. + +If you are a MacOS user or forced to use an alternative bash, see [Install +Bashbot](doc/0_install.md) + ### Run your Bot as a restricted user **I recommend to run your bot as a user, with almost no access rights.** All files your Bot have write access to are in danger to be overwritten/deleted @@ -257,4 +269,4 @@ tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.94-5-g6531fec +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/addons/antiFlood.sh b/addons/antiFlood.sh index 0d9a21f..3ffc72e 100644 --- a/addons/antiFlood.sh +++ b/addons/antiFlood.sh @@ -4,7 +4,7 @@ # this addon counts how many files, e.g. stickers, are sent to # a chat and takes actions if threshold is reached # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # used events: # diff --git a/addons/example.sh b/addons/example.sh index 3bd8cbe..e719e92 100644 --- a/addons/example.sh +++ b/addons/example.sh @@ -4,7 +4,7 @@ # Addons can register to bashbot events at statup # by providing their name and a callback per event # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # # If an event occours each registered event function is called. # diff --git a/bashbot.rc b/bashbot.rc index e76753c..556e437 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 7d8af2c..c297399 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -11,7 +11,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-5-g6531fec +#### $$VERSION$$ V0.94-0-gbdb50c8 # # Exit Codes: # - 0 sucess (hopefully) diff --git a/commands.sh b/commands.sh index 61935c7..7bd5be1 100644 --- a/commands.sh +++ b/commands.sh @@ -15,7 +15,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-1-gf13a2d0 +#### $$VERSION$$ V0.94-0-gbdb50c8 # # adjust your language setting here, e.g.when run from other user or cron. diff --git a/dev/all-tests.sh b/dev/all-tests.sh index abd3247..b4b8eed 100755 --- a/dev/all-tests.sh +++ b/dev/all-tests.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # this has to run once atfer git clone # and every time we create new hooks -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/git-add.sh b/dev/git-add.sh index 457836c..02ffd22 100755 --- a/dev/git-add.sh +++ b/dev/git-add.sh @@ -3,7 +3,7 @@ # # works together with git pre-push.sh and ADD all changed files since last push -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/hooks/pre-commit.sh b/dev/hooks/pre-commit.sh index 0a2e6df..1bd3686 100755 --- a/dev/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 ############ # NOTE: you MUST run install-hooks.sh again when updating this file! diff --git a/dev/hooks/pre-push.sh b/dev/hooks/pre-push.sh index c1dba63..afb75f6 100755 --- a/dev/hooks/pre-push.sh +++ b/dev/hooks/pre-push.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 ############ # NOTE: you MUST run install-hooks.sh again when updating this file! diff --git a/dev/install-hooks.sh b/dev/install-hooks.sh index 7fd70fc..231e0d9 100755 --- a/dev/install-hooks.sh +++ b/dev/install-hooks.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # this has to run once atfer git clone # and every time we create new hooks -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/make-distribution.sh b/dev/make-distribution.sh index 62f9c7c..8d0bc0b 100755 --- a/dev/make-distribution.sh +++ b/dev/make-distribution.sh @@ -2,7 +2,7 @@ # file: make-distribution.sh # creates files and arcchives to dirtribute bashbot # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/make-standalone.sh b/dev/make-standalone.sh index 27dbcbf..2152929 100755 --- a/dev/make-standalone.sh +++ b/dev/make-standalone.sh @@ -5,7 +5,7 @@ # If you your bot is finished you can use make-standalone.sh to create the # the old all-in-one bashbot: bashbot.sh and commands.sh only! # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/dev/shellcheck.files b/dev/shellcheck.files index 4d49180..daf2243 100644 --- a/dev/shellcheck.files +++ b/dev/shellcheck.files @@ -1,4 +1,4 @@ # list of additional files to check from shellcheck -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 bashbot.rc mycommands.sh.clean diff --git a/dev/version.sh b/dev/version.sh index eca2043..54a5284 100755 --- a/dev/version.sh +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # shellcheck disable=SC2016 # # Easy Versioning in git: diff --git a/doc/0_install.md b/doc/0_install.md index b4dd56c..0693d8b 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -1,16 +1,5 @@ #### [Home](../README.md) -## Note for Users of MacOS - -You must install a more current version of bash, as the default bash is way to old, -see e.g. [Install Bash on Mac](http://macappstore.org/bash/) - -After installation / update of bashbot you must change the shebang line to point to your bash location -e.g. with the provided script ˋexamples/bash2env.shˋ - -We stay with /bin/bash shebang, because using the system bash is more save. It makes it harder -for attackers or users to place broken, mangled or compromised bash executables. - ## Install bashbot 1. Go to the directory you want to install bashbot, e.g. @@ -54,6 +43,16 @@ If you modified 'commands.sh' move your changes to 'mycommands.sh', this avoids Now you can restart your bashbot instances. +### Note for MacOS Users + +You must install a more current version of bash, as the default bash is way to old, +see e.g. [Install Bash on Mac](http://macappstore.org/bash/) + +After installation / update of bashbot you must change the shebang line to point to your bash location +e.g. with the provided script ˋexamples/bash2env.shˋ + +We stay with /bin/bash shebang, because using the system bash is more save, see [Security Considerations](../README.md#Security Considerations) + ### Notes on Updates #### removal of TMUX @@ -98,5 +97,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ v0.94-5-g6531fec +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 8a6486b..180c2a1 100644 --- a/doc/1_firstbot.md +++ b/doc/1_firstbot.md @@ -65,5 +65,5 @@ group. This step is up to you actually. #### [Prev Installation](0_install.md) #### [Next Getting started](2_usage.md) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/doc/2_usage.md b/doc/2_usage.md index 5589b73..a8c26c3 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -240,5 +240,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 21e4dc6..aebd317 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -180,5 +180,5 @@ See also [answer_inline_multi, answer_inline_compose](6_reference.md#answer_inli #### [Prev Getting started](2_usage.md) #### [Next Expert Use](4_expert.md) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/doc/4_expert.md b/doc/4_expert.md index 5ba3b11..a0a0c04 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -348,5 +348,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms. #### [Prev Advanced Use](3_advanced.md) #### [Next Best Practice](5_practice.md) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/doc/5_practice.md b/doc/5_practice.md index ccce2ce..dbb4ee5 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -152,5 +152,5 @@ The second warning is about an unused variable, this is true because in our exam #### [Prev Best Practice](5_practice.md) #### [Next Functions Reference](6_reference.md) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/doc/6_reference.md b/doc/6_reference.md index 76dcda4..9fbacf2 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -973,5 +973,5 @@ The name of your bot is availible as bash variable "$ME", there is no need to ca #### [Prev Best Practice](5_practice.md) #### [Next Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/doc/7_develop.md b/doc/7_develop.md index 96840f9..312de72 100644 --- a/doc/7_develop.md +++ b/doc/7_develop.md @@ -328,5 +328,5 @@ fi #### [Prev Function Reference](6_reference.md) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/examples/README.md b/examples/README.md index 3af1451..363162c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -55,6 +55,6 @@ convert existing bots. **external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users. -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 diff --git a/examples/background-scripts/run_diskusage.sh b/examples/background-scripts/run_diskusage.sh index 0cbb92a..7eb1a7e 100755 --- a/examples/background-scripts/run_diskusage.sh +++ b/examples/background-scripts/run_diskusage.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_filecontent.sh b/examples/background-scripts/run_filecontent.sh index d160cf4..3f2a157 100755 --- a/examples/background-scripts/run_filecontent.sh +++ b/examples/background-scripts/run_filecontent.sh @@ -2,7 +2,7 @@ # file: run_filename # background job to display content of all new files in WATCHDIR # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_filename.sh b/examples/background-scripts/run_filename.sh index 1d4ba25..391b02a 100755 --- a/examples/background-scripts/run_filename.sh +++ b/examples/background-scripts/run_filename.sh @@ -2,7 +2,7 @@ # file: run_filename # background job to display all new files in WATCHDIR # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/background-scripts/run_notify.sh b/examples/background-scripts/run_notify.sh index 348795e..9e9a3cf 100755 --- a/examples/background-scripts/run_notify.sh +++ b/examples/background-scripts/run_notify.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/bash2env.sh b/examples/bash2env.sh index a448195..c0ee605 100755 --- a/examples/bash2env.sh +++ b/examples/bash2env.sh @@ -6,7 +6,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-3-g96fda44 +#### $$VERSION$$ V0.94-0-gbdb50c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/bashbot-multi.sh b/examples/bashbot-multi.sh index 22f757b..6a09f59 100755 --- a/examples/bashbot-multi.sh +++ b/examples/bashbot-multi.sh @@ -2,7 +2,7 @@ # file. multibot.sh # description: run multiple telegram bots from one installation # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then echo "Usage: $0 botname command" diff --git a/examples/bashbot.cron b/examples/bashbot.cron index 4b26da4..d72147c 100644 --- a/examples/bashbot.cron +++ b/examples/bashbot.cron @@ -7,7 +7,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 SHELL=/bin/sh diff --git a/examples/calc.sh b/examples/calc.sh index 4ffe6e8..ea08c46 100755 --- a/examples/calc.sh +++ b/examples/calc.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/notify.sh b/examples/notify.sh index da713f6..1ce76ca 100755 --- a/examples/notify.sh +++ b/examples/notify.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/question.sh b/examples/question.sh index 98e5ef8..c220667 100755 --- a/examples/question.sh +++ b/examples/question.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/examples/send-system-status/botacl b/examples/send-system-status/botacl index c6fa66a..8bfeaed 100644 --- a/examples/send-system-status/botacl +++ b/examples/send-system-status/botacl @@ -1,7 +1,7 @@ # file: botacl # a user not listed here, will return false from 'user_is_allowed' # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # Format: # user:ressource:chat diff --git a/examples/send-system-status/mycommands.sh b/examples/send-system-status/mycommands.sh index 615e30e..4fe1fe3 100644 --- a/examples/send-system-status/mycommands.sh +++ b/examples/send-system-status/mycommands.sh @@ -5,7 +5,7 @@ # to show how you can customize bashbot by only editing mycommands.sh # NOTE: this is not tested, simply copied from original source and reworked! # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/modules/aliases.sh b/modules/aliases.sh index 5af7dfa..6404491 100644 --- a/modules/aliases.sh +++ b/modules/aliases.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # # source from commands.sh to use the aliases diff --git a/modules/answerInline.sh b/modules/answerInline.sh index 46e7540..7757d97 100644 --- a/modules/answerInline.sh +++ b/modules/answerInline.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # source from commands.sh to use the inline functions diff --git a/modules/background.sh b/modules/background.sh index 9d6d7a2..12e9d4d 100644 --- a/modules/background.sh +++ b/modules/background.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # source from commands.sh if you want ro use interactive or background jobs diff --git a/modules/chatMember.sh b/modules/chatMember.sh index ad9559d..a308aab 100644 --- a/modules/chatMember.sh +++ b/modules/chatMember.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-1-gf13a2d0 +#### $$VERSION$$ V0.94-0-gbdb50c8 # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index f74c02d..4cdaf64 100644 --- a/modules/jsonDB.sh +++ b/modules/jsonDB.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # # source from commands.sh to use jsonDB functions # diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index de67a72..1df7f87 100644 --- a/modules/sendMessage.sh +++ b/modules/sendMessage.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" diff --git a/mycommands.sh b/mycommands.sh index 5c486ce..94992a7 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -8,7 +8,7 @@ # #### if you start to develop your own bot, use the clean version of this file: # #### mycommands.clean # -#### $$VERSION$$ v0.94-2-g93f4966 +#### $$VERSION$$ V0.94-0-gbdb50c8 # # uncomment the following lines to overwrite info and help messages diff --git a/mycommands.sh.clean b/mycommands.sh.clean index 8def1bb..66b031f 100644 --- a/mycommands.sh.clean +++ b/mycommands.sh.clean @@ -4,7 +4,7 @@ # files: mycommands.sh.clean # copy to mycommands.sh and add all your commands and functions here ... # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # ########## diff --git a/test/ADD-test-new.sh b/test/ADD-test-new.sh index 054a990..cc32650 100755 --- a/test/ADD-test-new.sh +++ b/test/ADD-test-new.sh @@ -2,7 +2,7 @@ # # ADD a new test skeleton to test dir, but does not activate test # -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script diff --git a/test/ALL-tests.inc.sh b/test/ALL-tests.inc.sh index c3480d8..038e856 100644 --- a/test/ALL-tests.inc.sh +++ b/test/ALL-tests.inc.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME diff --git a/test/a-commit-test.sh b/test/a-commit-test.sh index 0c9304c..deab289 100755 --- a/test/a-commit-test.sh +++ b/test/a-commit-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 ../dev/hooks/pre-commit.sh diff --git a/test/b-example-test.sh b/test/b-example-test.sh index 7db05ba..5e9ac32 100644 --- a/test/b-example-test.sh +++ b/test/b-example-test.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # file: b-example-test.sh -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/c-init-test.sh b/test/c-init-test.sh index 1e43821..de076a5 100755 --- a/test/c-init-test.sh +++ b/test/c-init-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-JSON.sh-test.sh b/test/d-JSON.sh-test.sh index 55e14bd..a1c99ec 100755 --- a/test/d-JSON.sh-test.sh +++ b/test/d-JSON.sh-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-process_inline-test.sh b/test/d-process_inline-test.sh index babcca2..7faf598 100755 --- a/test/d-process_inline-test.sh +++ b/test/d-process_inline-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-process_message-test.sh b/test/d-process_message-test.sh index dda0fe0..1e9c9c9 100755 --- a/test/d-process_message-test.sh +++ b/test/d-process_message-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-send_message-test.sh b/test/d-send_message-test.sh index d7d1843..74895a3 100755 --- a/test/d-send_message-test.sh +++ b/test/d-send_message-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/d-user_is-test.sh b/test/d-user_is-test.sh index bb109d4..af6da46 100755 --- a/test/d-user_is-test.sh +++ b/test/d-user_is-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh diff --git a/test/e-env-test.sh b/test/e-env-test.sh index 56dacf8..f2041d5 100755 --- a/test/e-env-test.sh +++ b/test/e-env-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-0-gaaa71c8 +#### $$VERSION$$ V0.94-0-gbdb50c8 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh From ced78d3656ae9627ff233586cc6a3626f49e8809 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 17 May 2020 14:02:03 +0200 Subject: [PATCH 09/10] fix broken link --- README.html | 6 +++--- README.md | 6 +++--- README.txt | 10 +++++----- doc/0_install.md | 7 ++++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/README.html b/README.html index fd03b66..f974dc8 100644 --- a/README.html +++ b/README.html @@ -180,8 +180,8 @@ It features background tasks and interactive chats, and can serve as an interfac

    Whenever you are processing input from from untrusted sources (messages, files, network) you must be as carefull as possible, e.g. set IFS appropriate, disable globbing (set -f) and quote everthing. In addition delete unused scripts and examples from your Bot, e.g. scripts 'notify', 'calc', 'question', and disable all not used commands.

    A powerful tool to improve your scripts is shellcheck. You can use it online or install shellcheck locally. Shellcheck is used extensive in bashbot development to enshure 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.

    Do not use #!/usr/bin/env bash

    -

    We stay with /bin/bash shebang, because using the system bash is more save from security perspective.

    -

    It makes it harder for attackers and users to place alternative versions of bash and avoids using possibly broken, mangled or compromised bash executables.

    +

    We stay with /bin/bash shebang, because it's more save from security perspective.

    +

    Using the system provided bash makes it harder for attackers or users to place alternative versions of bash and avoids using possibly broken, mangled or compromised bash executables.

    If you are a MacOS user or forced to use an alternative bash, see Install Bashbot

    Run your Bot as a restricted user

    I recommend to run your bot as a user, with almost no access rights. All files your Bot have write access to are in danger to be overwritten/deleted if your bot is hacked. For the same reason ervery file your Bot can read is in danger to be disclosed. Restict your Bots access rigths to the absolute minimum.

    @@ -228,6 +228,6 @@ It features background tasks and interactive chats, and can serve as an interfac

    @Gnadelwartz

    That's it!

    If you feel that there's something missing or if you found a bug, feel free to submit a pull request!

    -

    $$VERSION$$ V0.94-0-gbdb50c8

    +

    $$VERSION$$ V0.94-1-g7aa409f

    diff --git a/README.md b/README.md index 23d6cd8..9664250 100644 --- a/README.md +++ b/README.md @@ -114,9 +114,9 @@ In addition bashbot has a [test suite](doc/7_develop.md) to check if important f ### Do not use #!/usr/bin/env bash -We stay with /bin/bash shebang, because using the system bash is more save from security perspective. +**We stay with /bin/bash shebang, because it's more save from security perspective.** -It makes it harder for attackers and users to place alternative versions of bash and avoids using +Using the system provided bash makes it harder for attackers or users to place alternative versions of bash and avoids using possibly broken, mangled or compromised bash executables. If you are a MacOS user or forced to use an alternative bash, see [Install Bashbot](doc/0_install.md) @@ -192,4 +192,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ V0.94-0-gbdb50c8 +#### $$VERSION$$ V0.94-1-g7aa409f diff --git a/README.txt b/README.txt index 53500a3..58d3af2 100644 --- a/README.txt +++ b/README.txt @@ -156,11 +156,11 @@ functionality is working as expected. ### Do not use #!/usr/bin/env bash -We stay with /bin/bash shebang, because using the system bash is more save from -security perspective. +**We stay with /bin/bash shebang, because it's more save from security +perspective.** -It makes it harder for attackers and users to place alternative versions of -bash and avoids using +Using the system provided bash makes it harder for attackers or users to place +alternative versions of bash and avoids using possibly broken, mangled or compromised bash executables. If you are a MacOS user or forced to use an alternative bash, see [Install @@ -269,4 +269,4 @@ tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ V0.94-0-gbdb50c8 +#### $$VERSION$$ V0.94-1-g7aa409f diff --git a/doc/0_install.md b/doc/0_install.md index 0693d8b..a14937f 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -49,9 +49,10 @@ You must install a more current version of bash, as the default bash is way to o see e.g. [Install Bash on Mac](http://macappstore.org/bash/) After installation / update of bashbot you must change the shebang line to point to your bash location -e.g. with the provided script ˋexamples/bash2env.shˋ +e.g. with the provided script 'examples/bash2env.sh' -We stay with /bin/bash shebang, because using the system bash is more save, see [Security Considerations](../README.md#Security Considerations) +We stay with /bin/bash shebang, because using the system bash is more save, see +[Security Considerations](../README.md#Security-Considerations) ### Notes on Updates @@ -97,5 +98,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ V0.94-0-gbdb50c8 +#### $$VERSION$$ V0.94-1-g7aa409f From ca803c0a47699a6f0e4a43b5c1abeb035290e065 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 17 May 2020 14:13:12 +0200 Subject: [PATCH 10/10] Version 0.94 --- README.md | 2 +- doc/0_install.md | 4 ++-- doc/2_usage.md | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9664250..4b633c4 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ In addition bashbot has a [test suite](doc/7_develop.md) to check if important f **We stay with /bin/bash shebang, because it's more save from security perspective.** Using the system provided bash makes it harder for attackers or users to place alternative versions of bash and avoids using -possibly broken, mangled or compromised bash executables. +possibly broken, mangled or compromised bash executables. If you are a MacOS user or forced to use an alternative bash, see [Install Bashbot](doc/0_install.md) diff --git a/doc/0_install.md b/doc/0_install.md index a14937f..eb69328 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -39,7 +39,7 @@ As an alternative to download the zip files, you can clone the github repository 4. Extract all files to your existing bashbot dir 5. Run ```sudo ./bashbot.sh init``` to setup your environment after the update -If you modified 'commands.sh' move your changes to 'mycommands.sh', this avoids overwrrite of you changes on updates. +If you modified ```commands.sh``` move your changes to ```mycommands.sh```, this avoids overwrrite of you changes on updates. Now you can restart your bashbot instances. @@ -49,7 +49,7 @@ You must install a more current version of bash, as the default bash is way to o see e.g. [Install Bash on Mac](http://macappstore.org/bash/) After installation / update of bashbot you must change the shebang line to point to your bash location -e.g. with the provided script 'examples/bash2env.sh' +e.g. with the provided script ```examples/bash2env.sh``` We stay with /bin/bash shebang, because using the system bash is more save, see [Security Considerations](../README.md#Security-Considerations) diff --git a/doc/2_usage.md b/doc/2_usage.md index a8c26c3..3a997af 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -43,6 +43,7 @@ Have FUN! │ ├── examples # example scripts and configs for bashbot │   ├── README.md # description of files and examples +│   ├── bash2env.shh # script to convert /bin/bash shebang to /usr/bin/env, see [Security Considerations](../README.md#Security-Considerations) │   └── bashbot.cron # example crontab │ ├── doc # Documentation and License