From 4b36432d0982dace46270b8c2da8e16ad061741d Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 19 May 2020 17:48:18 +0200 Subject: [PATCH 1/9] Start 0.96-dev, use MarkdownV2 --- modules/sendMessage.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index 654d039..aa0c9d1 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.941-0-ga055b77 +#### $$VERSION$$ v0.96-dev-0-ga72d56a # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" @@ -35,7 +35,7 @@ send_normal_message() { send_markdown_message() { local text; text="$(JsonEscape "${2}")" until [ -z "${text}" ]; do - sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdown"' "${MSG_URL}" + sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdownv2"' "${MSG_URL}" text="${text:4096}" done } From b6f36c6e7afe852a16641474bf6120ed7901c489 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 19 May 2020 18:21:56 +0200 Subject: [PATCH 2/9] add jssh_countKeyDB function --- modules/jsonDB.sh | 36 +++++++++++++++++++++++++++++++++++- modules/sendMessage.sh | 2 +- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index 4cdaf64..b29442b 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-1-g4b36432 # # source from commands.sh to use jsonDB functions # @@ -119,6 +119,24 @@ if _exists flock; then } + # add a value to key, used for conters + # $1 key name, can onyl contain -a-zA-Z0-9,._ + # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..' + # $3 optional count, value added to count3r, add 1 if empty + jssh_countKeyDB() { + [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 + local DB COUNT="1"; DB="$(jssh_checkDB "$2")" + declare -A oldARR + # start atomic delete here, exclusive max wait 10s + { flock -e -w 10 200 + Json2Array "oldARR" <"${DB}" + (( oldARR["$1"]+=COUNT )); + # it's append, but last one counts, its a simple DB ... + printf '["%s"]\t"%s"\n' "${1//,/\",\"}" "${oldARR["$1"]//\"/\\\"}" >>"${DB}" + } 200>"${DB}${BASHBOT_LOCKNAME}" + } + + else ######### # we have no flock, use "old" not atomic functions @@ -142,6 +160,10 @@ else jssh_deleteKeyDB() { jssh_deleteKeyDB_async "$@" } + + jssh_countKeyDB() { + jssh_countKeyDB "$@" + } fi ############## @@ -244,3 +266,15 @@ jssh_deleteKeyDB_async() { jssh_writeDB_async "oldARR" "$2" } +jssh_countKeyDB_async() { + [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 + local DB COUNT="1"; DB="$(jssh_checkDB "$2")" + declare -A oldARR + # start atomic delete here, exclusive max wait 10s + Json2Array "oldARR" <"${DB}" + (( oldARR["$1"]+=COUNT )); + # it's append, but last one counts, its a simple DB ... + #printf '["%s"]\t"%s"\n' "${1//,/\",\"}" "${oldARR["$1"]//\"/\\\"}" >>"${DB}" + Array2Json "oldARR" >"${DB}" +} + diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index aa0c9d1..9f9639c 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.96-dev-0-ga72d56a +#### $$VERSION$$ v0.96-dev-1-g4b36432 # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" From a4636668a7d50247b2a3feb93321930c2e5d4f2a Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 19 May 2020 19:26:10 +0200 Subject: [PATCH 3/9] optimized version of countKeyDB --- bashbot.sh | 4 +--- modules/jsonDB.sh | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index f7b5d04..51b00f9 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-7-g3d92bf3 +#### $$VERSION$$ v0.96-dev-2-gb6f36c6 # # Exit Codes: # - 0 sucess (hopefully) @@ -168,8 +168,6 @@ if [[ ! "${BOTTOKEN}" =~ ^[0-9]{8,10}:[a-zA-Z0-9_-]{35}$ ]]; then echo -e "${ORANGE}Posilbe problem in the charatcers part, len is $(($(wc -c <<<"${BOTTOKEN#*:}")-1))${NC}" fi -exit - ################## # here we start with the real stuff URL="${BASHBOT_URL:-https://api.telegram.org/bot}${BOTTOKEN}" diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index b29442b..33b72d3 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.96-dev-1-g4b36432 +#### $$VERSION$$ v0.96-dev-2-gb6f36c6 # # source from commands.sh to use jsonDB functions # @@ -123,16 +123,22 @@ if _exists flock; then # $1 key name, can onyl contain -a-zA-Z0-9,._ # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..' # $3 optional count, value added to count3r, add 1 if empty + # side effect: if $3 is not given, we add to end of file to be as fast as possible jssh_countKeyDB() { [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 - local DB COUNT="1"; DB="$(jssh_checkDB "$2")" + 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}" - (( oldARR["$1"]+=COUNT )); - # it's append, but last one counts, its a simple DB ... - printf '["%s"]\t"%s"\n' "${1//,/\",\"}" "${oldARR["$1"]//\"/\\\"}" >>"${DB}" + if [ "$3" != "" ]; then + (( oldARR["$1"]+="$3" )); + Array2Json "oldARR" >"${DB}" + else + # it's append, but last one counts, its a simple DB ... + (( oldARR["$1"]++ )); + printf '["%s"]\t"%s"\n' "${1//,/\",\"}" "${oldARR["$1"]//\"/\\\"}" >>"${DB}" + fi } 200>"${DB}${BASHBOT_LOCKNAME}" } @@ -269,12 +275,11 @@ jssh_deleteKeyDB_async() { jssh_countKeyDB_async() { [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 local DB COUNT="1"; DB="$(jssh_checkDB "$2")" + [ "$3" != "" ] && COUNT="$3" declare -A oldARR # start atomic delete here, exclusive max wait 10s Json2Array "oldARR" <"${DB}" (( oldARR["$1"]+=COUNT )); - # it's append, but last one counts, its a simple DB ... - #printf '["%s"]\t"%s"\n' "${1//,/\",\"}" "${oldARR["$1"]//\"/\\\"}" >>"${DB}" Array2Json "oldARR" >"${DB}" } From ab863af08b97326613afb7278ed1e4433a3fd8dd Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 19 May 2020 19:41:54 +0200 Subject: [PATCH 4/9] add doc for jssh_countKeyDB --- doc/6_reference.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/6_reference.md b/doc/6_reference.md index 9fbacf2..dffb8c6 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -685,6 +685,22 @@ Deleted a key=value pair froma jsshDB file, key name is only allowed to contain jssh_deleteKeyDB "delkey"" "${DATADIR:-.}/myvalues" ``` +##### jssh_countKeyDB +Increase a key=value pair from a jsshDB file by 1, key name is only allowed to contain '-a-zA-Z0-9,._' +If value is given key is increased by value. + +Ssde effect: if value is given key is updated "in place" (slower) and file is cleand up, if no value is given fast path is used +and new count is added at the end of file. + +*usage:* jssh_countKeyDB "key" "filename" ["value"] + +*usage:* jssh_countKeyDB "key" "filename" ["value"] + +*example:* +```bash +jssh_countKeyDB "usercount"" "${DATADIR:-.}/myvalues" +``` + https://linuxhint.com/associative_array_bash/ https://linuxconfig.org/how-to-use-arrays-in-bash-script @@ -973,5 +989,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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-3-ga463666 From 037b1ea326911111a570ab6de037e679cfebb52a Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 19 May 2020 19:48:38 +0200 Subject: [PATCH 5/9] fix doc typos --- doc/6_reference.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/6_reference.md b/doc/6_reference.md index dffb8c6..62a6971 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -689,12 +689,12 @@ jssh_deleteKeyDB "delkey"" "${DATADIR:-.}/myvalues" Increase a key=value pair from a jsshDB file by 1, key name is only allowed to contain '-a-zA-Z0-9,._' If value is given key is increased by value. -Ssde effect: if value is given key is updated "in place" (slower) and file is cleand up, if no value is given fast path is used -and new count is added at the end of file. +Side effect: if value is given key is updated "in place" (slower) and file is cleand up, if no value is given fast path is used +and new count is added to the end of file. *usage:* jssh_countKeyDB "key" "filename" ["value"] -*usage:* jssh_countKeyDB "key" "filename" ["value"] +*usage:* jssh_countKeyDB_async "key" "filename" ["value"] *example:* ```bash @@ -989,5 +989,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.96-dev-3-ga463666 +#### $$VERSION$$ v0.96-dev-4-gab863af From 7e83e5dd1c65b02c529aea58ab57481edecd2d81 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Wed, 20 May 2020 15:18:23 +0200 Subject: [PATCH 6/9] markdownv2 is not ccompatible, jssh_getKey --- commands.sh | 18 ++++++++---------- modules/jsonDB.sh | 35 ++++++++++++++++++++++++++++++----- modules/sendMessage.sh | 12 +++++++++++- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/commands.sh b/commands.sh index 7bd5be1..25b2c01 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-5-g037b1ea # # adjust your language setting here, e.g.when run from other user or cron. @@ -51,14 +51,12 @@ Get the code in my [GitHub](http://github.com/topkecleon/telegram-bot-bash) ' # load modues on startup and always on on debug -if [ -n "${1}" ]; then - # load all readable modules - for modules in "${MODULEDIR:-.}"/*.sh ; do - if [[ "${1}" == *"debug"* ]] || ! _is_function "$(basename "${modules}")"; then +if [ "${1}" = "startbot" ] || [[ "${1}" = *"debug"* ]] ; then + # load all readable modules + for modules in "${MODULEDIR:-.}"/*.sh ; do # shellcheck source=./modules/aliases.sh [ -r "${modules}" ] && source "${modules}" "${1}" - fi - done + done fi # @@ -66,7 +64,7 @@ fi # copy "mycommands.sh.dist" to "mycommnds.sh" and change the values there # defaults to no inline and nonsense home dir export INLINE="0" -export FILE_REGEX="${BASHBOT_ETC}/.*" +export FILE_REGEX='/home/user/allowed/.*' # load mycommands @@ -74,10 +72,10 @@ export FILE_REGEX="${BASHBOT_ETC}/.*" [ -r "${BASHBOT_ETC:-.}/mycommands.sh" ] && source "${BASHBOT_ETC:-.}/mycommands.sh" "${1}" -if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then +if [ "${1}" = "" ] || [[ "${1}" == *"debug"* ]];then # detect inline commands.... # no default commands, all processing is done in myinlines() - if [ "$INLINE" != "0" ] && [ -n "${iQUERY[ID]}" ]; then + if [ "$INLINE" != "0" ] && [ "${iQUERY[ID]}" != "" ]; then # forward iinline query to optional dispatcher _exec_if_function myinlines diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index 33b72d3..3799542 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.96-dev-2-gb6f36c6 +#### $$VERSION$$ v0.96-dev-5-g037b1ea # # source from commands.sh to use jsonDB functions # @@ -36,7 +36,7 @@ if _exists flock; then local DB; DB="$(jssh_checkDB "$2")" [ -z "${DB}" ] && return 1 [ ! -f "${DB}" ] && return 2 - # shared lock, many processes can read, maximum wait 1s + # shared lock, many processes can read, max wait 1s { flock -s -w 1 200; Json2Array "$1" <"${DB}"; } 200>"${DB}${BASHBOT_LOCKNAME}" } @@ -95,7 +95,7 @@ if _exists flock; then local DB; DB="$(jssh_checkDB "$3")" [ -z "${DB}" ] && return 1 [ ! -f "${DB}" ] && return 2 - # start atomic update here, exclusive max wait 2si, it's append, not overwrite + # start atomic update here, exclusive max wait 2, it's append, not overwrite { flock -e -w 2 200 # it's append, but last one counts, its a simple DB ... printf '["%s"]\t"%s"\n' "${key//,/\",\"}" "${value//\"/\\\"}" >>"${DB}" @@ -118,6 +118,20 @@ if _exists flock; then } 200>"${DB}${BASHBOT_LOCKNAME}" } + # delete key/value from jsshDB + # $1 key name, can onyl contain -a-zA-Z0-9,._ + # $2 filename (must exist!), must be relative to BASHBOT_ETC, and not contain '..' + jssh_getKeyDB() { + [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 + local DB; DB="$(jssh_checkDB "$2")" + declare -A oldARR + # start atomic delete here, exclusive max wait 1s + { flock -e -w 1 200 + Json2Array "oldARR" <"${DB}" + } 200>"${DB}${BASHBOT_LOCKNAME}" + echo "${oldARR["$1"]}" + } + # add a value to key, used for conters # $1 key name, can onyl contain -a-zA-Z0-9,._ @@ -128,8 +142,8 @@ if _exists flock; then [[ "$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 + # start atomic delete here, exclusive max wait 5 + { flock -e -w 5 200 Json2Array "oldARR" <"${DB}" if [ "$3" != "" ]; then (( oldARR["$1"]+="$3" )); @@ -167,6 +181,9 @@ else jssh_deleteKeyDB_async "$@" } + jssh_getKeyDB() { + jssh_getKeyDB_async "$@" + } jssh_countKeyDB() { jssh_countKeyDB "$@" } @@ -272,6 +289,14 @@ jssh_deleteKeyDB_async() { jssh_writeDB_async "oldARR" "$2" } +jssh_getKeyDB_async() { + [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 + local DB; DB="$(jssh_checkDB "$2")" + declare -A oldARR + Json2Array "oldARR" <"${DB}" + echo "${oldARR["$1"]}" +} + jssh_countKeyDB_async() { [[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3 local DB COUNT="1"; DB="$(jssh_checkDB "$2")" diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index 9f9639c..fb78f76 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.96-dev-1-g4b36432 +#### $$VERSION$$ v0.96-dev-5-g037b1ea # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" @@ -34,6 +34,16 @@ send_normal_message() { send_markdown_message() { local text; text="$(JsonEscape "${2}")" + until [ -z "${text}" ]; do + sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdown"' "${MSG_URL}" + text="${text:4096}" + done +} + +send_markdownv2_message() { + local text; text="$(JsonEscape "${2}")" + # markdown v2 needs additional double escaping! + text="$(sed -E -e 's|([#{}()!.-])|\\\1|g' <<< "$text")" until [ -z "${text}" ]; do sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdownv2"' "${MSG_URL}" text="${text:4096}" From 01539286d162e6e309e3dfca638f37b59c3ff13a Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Wed, 20 May 2020 16:35:22 +0200 Subject: [PATCH 7/9] revert old commands.sh --- 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 | 18 ++++++++++-------- 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/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, 66 insertions(+), 64 deletions(-) diff --git a/README.html b/README.html index a0e272d..d3bd543 100644 --- a/README.html +++ b/README.html @@ -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-9-g46af634

+

$$VERSION$$ v0.96-dev-6-g7e83e5d

diff --git a/README.md b/README.md index 682ab9e..dee12a4 100644 --- a/README.md +++ b/README.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-9-g46af634 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/README.txt b/README.txt index 38f057c..e1a7652 100644 --- a/README.txt +++ b/README.txt @@ -270,4 +270,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-9-g46af634 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/addons/antiFlood.sh b/addons/antiFlood.sh index 3ffc72e..dd2c9e1 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # used events: # diff --git a/addons/example.sh b/addons/example.sh index e719e92..3bb2a77 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # # If an event occours each registered event function is called. # diff --git a/bashbot.rc b/bashbot.rc index 556e437..1a563c4 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ V0.94-0-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 51b00f9..8edad02 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.96-dev-2-gb6f36c6 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # # Exit Codes: # - 0 sucess (hopefully) diff --git a/commands.sh b/commands.sh index 25b2c01..4fe0fd7 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.96-dev-5-g037b1ea +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # # adjust your language setting here, e.g.when run from other user or cron. @@ -51,12 +51,14 @@ Get the code in my [GitHub](http://github.com/topkecleon/telegram-bot-bash) ' # load modues on startup and always on on debug -if [ "${1}" = "startbot" ] || [[ "${1}" = *"debug"* ]] ; then - # load all readable modules - for modules in "${MODULEDIR:-.}"/*.sh ; do +if [ -n "${1}" ]; then + # load all readable modules + for modules in "${MODULEDIR:-.}"/*.sh ; do + if [[ "${1}" == *"debug"* ]] || ! _is_function "$(basename "${modules}")"; then # shellcheck source=./modules/aliases.sh [ -r "${modules}" ] && source "${modules}" "${1}" - done + fi + done fi # @@ -64,7 +66,7 @@ fi # copy "mycommands.sh.dist" to "mycommnds.sh" and change the values there # defaults to no inline and nonsense home dir export INLINE="0" -export FILE_REGEX='/home/user/allowed/.*' +export FILE_REGEX="${BASHBOT_ETC}/.*" # load mycommands @@ -72,10 +74,10 @@ export FILE_REGEX='/home/user/allowed/.*' [ -r "${BASHBOT_ETC:-.}/mycommands.sh" ] && source "${BASHBOT_ETC:-.}/mycommands.sh" "${1}" -if [ "${1}" = "" ] || [[ "${1}" == *"debug"* ]];then +if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then # detect inline commands.... # no default commands, all processing is done in myinlines() - if [ "$INLINE" != "0" ] && [ "${iQUERY[ID]}" != "" ]; then + if [ "$INLINE" != "0" ] && [ -n "${iQUERY[ID]}" ]; then # forward iinline query to optional dispatcher _exec_if_function myinlines diff --git a/dev/all-tests.sh b/dev/all-tests.sh index b4b8eed..73953de 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 02ffd22..ce53acf 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 1bd3686..ada4a1d 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d ############ # 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 afb75f6..5af014b 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d ############ # 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 231e0d9..26594e5 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 8d0bc0b..c6df48c 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 2152929..037bea5 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 daf2243..8d2d324 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d bashbot.rc mycommands.sh.clean diff --git a/dev/version.sh b/dev/version.sh index 54a5284..a3b5608 100755 --- a/dev/version.sh +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ V0.94-0-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # shellcheck disable=SC2016 # # Easy Versioning in git: diff --git a/doc/0_install.md b/doc/0_install.md index a16c4b0..4c26dfe 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -101,5 +101,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ V0.94-8-g876361f +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 180c2a1..33675cb 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/doc/2_usage.md b/doc/2_usage.md index e2d6747..529dd0d 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -241,5 +241,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ V0.94-2-gced78d3 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/doc/3_advanced.md b/doc/3_advanced.md index aebd317..f792644 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/doc/4_expert.md b/doc/4_expert.md index a0a0c04..b852883 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/doc/5_practice.md b/doc/5_practice.md index dbb4ee5..77f279c 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/doc/6_reference.md b/doc/6_reference.md index 62a6971..a2263de 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -989,5 +989,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.96-dev-4-gab863af +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/doc/7_develop.md b/doc/7_develop.md index 312de72..2de3f93 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/examples/README.md b/examples/README.md index 363162c..f8e058d 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d diff --git a/examples/background-scripts/run_diskusage.sh b/examples/background-scripts/run_diskusage.sh index 7eb1a7e..7ba1062 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 3f2a157..347af7f 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 391b02a..c0935b3 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 9e9a3cf..eb552f3 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 15a81cf..c0dfea4 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-7-g3d92bf3 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 6a09f59..ebaa9d6 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then echo "Usage: $0 botname command" diff --git a/examples/bashbot.cron b/examples/bashbot.cron index d72147c..1302745 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d SHELL=/bin/sh diff --git a/examples/calc.sh b/examples/calc.sh index ea08c46..4701cbc 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 1ce76ca..e50786c 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 c220667..7d5988c 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 8bfeaed..6a98dd8 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # Format: # user:ressource:chat diff --git a/examples/send-system-status/mycommands.sh b/examples/send-system-status/mycommands.sh index 4fe1fe3..70d37a0 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/modules/aliases.sh b/modules/aliases.sh index 6404491..2005499 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # # source from commands.sh to use the aliases diff --git a/modules/answerInline.sh b/modules/answerInline.sh index 7757d97..5d9f02f 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # source from commands.sh to use the inline functions diff --git a/modules/background.sh b/modules/background.sh index 12e9d4d..7c91813 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # source from commands.sh if you want ro use interactive or background jobs diff --git a/modules/chatMember.sh b/modules/chatMember.sh index a308aab..b572ee8 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index 3799542..d295f73 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.96-dev-5-g037b1ea +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # # source from commands.sh to use jsonDB functions # diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index fb78f76..2984c4a 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.96-dev-5-g037b1ea +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" diff --git a/mycommands.sh b/mycommands.sh index 94992a7..c37a30e 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # # uncomment the following lines to overwrite info and help messages diff --git a/mycommands.sh.clean b/mycommands.sh.clean index 66b031f..1354dbf 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # ########## diff --git a/test/ADD-test-new.sh b/test/ADD-test-new.sh index cc32650..898d13a 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 038e856..2e2a45a 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME diff --git a/test/a-commit-test.sh b/test/a-commit-test.sh index deab289..cc0c146 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d ../dev/hooks/pre-commit.sh diff --git a/test/b-example-test.sh b/test/b-example-test.sh index 5e9ac32..2df51f4 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 de076a5..8f11232 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 a1c99ec..cae5a1f 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 7faf598..496868a 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 1e9c9c9..773add3 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 74895a3..d842917 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 af6da46..4004883 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # 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 f2041d5..982047b 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-gbdb50c8 +#### $$VERSION$$ v0.96-dev-6-g7e83e5d # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh From e63590b9b4c5966b0a2c2e26e7f413ad24edbac9 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Wed, 20 May 2020 16:38:56 +0200 Subject: [PATCH 8/9] extended JsonEscape for V2 --- README.html | 2 +- README.md | 2 +- README.txt | 2 +- addons/antiFlood.sh | 2 +- addons/example.sh | 2 +- bashbot.rc | 2 +- bashbot.sh | 5 +++-- 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/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, 59 insertions(+), 58 deletions(-) diff --git a/README.html b/README.html index d3bd543..857543f 100644 --- a/README.html +++ b/README.html @@ -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.96-dev-6-g7e83e5d

+

$$VERSION$$ v0.96-dev-7-g0153928

diff --git a/README.md b/README.md index dee12a4..fd1c59e 100644 --- a/README.md +++ b/README.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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/README.txt b/README.txt index e1a7652..ec7f8c1 100644 --- a/README.txt +++ b/README.txt @@ -270,4 +270,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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/addons/antiFlood.sh b/addons/antiFlood.sh index dd2c9e1..e4a8a3f 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # used events: # diff --git a/addons/example.sh b/addons/example.sh index 3bb2a77..bb08160 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # # If an event occours each registered event function is called. # diff --git a/bashbot.rc b/bashbot.rc index 1a563c4..565ad94 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 8edad02..b0bfd6f 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # # Exit Codes: # - 0 sucess (hopefully) @@ -168,6 +168,7 @@ if [[ ! "${BOTTOKEN}" =~ ^[0-9]{8,10}:[a-zA-Z0-9_-]{35}$ ]]; then echo -e "${ORANGE}Posilbe problem in the charatcers part, len is $(($(wc -c <<<"${BOTTOKEN#*:}")-1))${NC}" fi + ################## # here we start with the real stuff URL="${BASHBOT_URL:-https://api.telegram.org/bot}${BOTTOKEN}" @@ -317,7 +318,7 @@ fi # $1 string # output escaped string JsonEscape() { - sed 's/\([-"`´,§$%&ß/(){}#@?*]\)/\\\1/g' <<< "$1" + sed 's/\([-"`´,§$%&/(){}#@!?*.]\)/\\\1/g' <<< "$1" } # convert common telegram entities to JSON diff --git a/commands.sh b/commands.sh index 4fe0fd7..9b2e61c 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # # 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 73953de..84488b0 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 ce53acf..b3a0a59 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 ada4a1d..3b23e11 100755 --- a/dev/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 ############ # 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 5af014b..c3b3489 100755 --- a/dev/hooks/pre-push.sh +++ b/dev/hooks/pre-push.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 ############ # 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 26594e5..6c62a23 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 c6df48c..5f2743a 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 037bea5..c5584f1 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 8d2d324..167d5c2 100644 --- a/dev/shellcheck.files +++ b/dev/shellcheck.files @@ -1,4 +1,4 @@ # list of additional files to check from shellcheck -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 bashbot.rc mycommands.sh.clean diff --git a/dev/version.sh b/dev/version.sh index a3b5608..892b220 100755 --- a/dev/version.sh +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # shellcheck disable=SC2016 # # Easy Versioning in git: diff --git a/doc/0_install.md b/doc/0_install.md index 4c26dfe..d391955 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -101,5 +101,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 33675cb..26e6a30 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/doc/2_usage.md b/doc/2_usage.md index 529dd0d..124078f 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -241,5 +241,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index f792644..5de1535 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/doc/4_expert.md b/doc/4_expert.md index b852883..f40e45d 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/doc/5_practice.md b/doc/5_practice.md index 77f279c..468f886 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/doc/6_reference.md b/doc/6_reference.md index a2263de..15bc332 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -989,5 +989,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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/doc/7_develop.md b/doc/7_develop.md index 2de3f93..1be455b 100644 --- a/doc/7_develop.md +++ b/doc/7_develop.md @@ -328,5 +328,5 @@ fi #### [Prev Function Reference](6_reference.md) -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/examples/README.md b/examples/README.md index f8e058d..d9b2870 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 diff --git a/examples/background-scripts/run_diskusage.sh b/examples/background-scripts/run_diskusage.sh index 7ba1062..a5dec8e 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 347af7f..5964805 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 c0935b3..34bfb50 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 eb552f3..9da4cfa 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 c0dfea4..d770aed 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 ebaa9d6..43f3a2a 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then echo "Usage: $0 botname command" diff --git a/examples/bashbot.cron b/examples/bashbot.cron index 1302745..6a28210 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 SHELL=/bin/sh diff --git a/examples/calc.sh b/examples/calc.sh index 4701cbc..d2bd29b 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 e50786c..1fc2d54 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 7d5988c..8e850ad 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 6a98dd8..392b5d5 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # Format: # user:ressource:chat diff --git a/examples/send-system-status/mycommands.sh b/examples/send-system-status/mycommands.sh index 70d37a0..6616f8c 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/modules/aliases.sh b/modules/aliases.sh index 2005499..6c87266 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # # source from commands.sh to use the aliases diff --git a/modules/answerInline.sh b/modules/answerInline.sh index 5d9f02f..976dc08 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # source from commands.sh to use the inline functions diff --git a/modules/background.sh b/modules/background.sh index 7c91813..90ca9e1 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # source from commands.sh if you want ro use interactive or background jobs diff --git a/modules/chatMember.sh b/modules/chatMember.sh index b572ee8..12e3cd3 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index d295f73..c098fbb 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # # source from commands.sh to use jsonDB functions # diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index 2984c4a..389c918 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # source once magic, function named like file eval "$(basename "${BASH_SOURCE[0]}")(){ :; }" diff --git a/mycommands.sh b/mycommands.sh index c37a30e..c8e6b67 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # # uncomment the following lines to overwrite info and help messages diff --git a/mycommands.sh.clean b/mycommands.sh.clean index 1354dbf..7c8c1c4 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # ########## diff --git a/test/ADD-test-new.sh b/test/ADD-test-new.sh index 898d13a..0e6b0dd 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 2e2a45a..e62023d 100644 --- a/test/ALL-tests.inc.sh +++ b/test/ALL-tests.inc.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME diff --git a/test/a-commit-test.sh b/test/a-commit-test.sh index cc0c146..4742d8d 100755 --- a/test/a-commit-test.sh +++ b/test/a-commit-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 ../dev/hooks/pre-commit.sh diff --git a/test/b-example-test.sh b/test/b-example-test.sh index 2df51f4..ed39d3f 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 8f11232..a0f79bc 100755 --- a/test/c-init-test.sh +++ b/test/c-init-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 cae5a1f..638b788 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 496868a..71ebc24 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 773add3..2c58c4c 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 d842917..9d9d481 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 4004883..2558a07 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.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # 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 982047b..0eec21a 100755 --- a/test/e-env-test.sh +++ b/test/e-env-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.96-dev-6-g7e83e5d +#### $$VERSION$$ v0.96-dev-7-g0153928 # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh From 8f29907442ccf35553f42a4553e4cb8996e26cb3 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 22 May 2020 08:29:49 +0200 Subject: [PATCH 9/9] fix shell expansion --- README.html | 4 ++-- README.md | 4 ++-- README.txt | 6 +++--- bashbot.sh | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.html b/README.html index 857543f..ac3842f 100644 --- a/README.html +++ b/README.html @@ -224,10 +224,10 @@ It features background tasks and interactive chats, and can serve as an interfac 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. -

This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a tor proxy on your server you may uncomment the BASHBOT_CURL_ARGS line in 'mycommands.sh'

+

This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a socks or tor proxy on your server look for the BASHBOT_CURL_ARGS lines in 'mycommands.sh' as example.

@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.96-dev-7-g0153928

+

$$VERSION$$ v0.96-dev-8-ge63590b

diff --git a/README.md b/README.md index fd1c59e..e7912c0 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ curl -m 10 https://api.telegram.org/bot 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. ``` -This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in 'mycommands.sh' +This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a socks or tor proxy on your server look for the ```BASHBOT_CURL_ARGS``` lines in 'mycommands.sh' as example. @Gnadelwartz @@ -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.96-dev-7-g0153928 +#### $$VERSION$$ v0.96-dev-8-ge63590b diff --git a/README.txt b/README.txt index ec7f8c1..07f8a71 100644 --- a/README.txt +++ b/README.txt @@ -259,8 +259,8 @@ failed: Connection timed out. This may happen if to many wrong requests are sent to api.telegram.org, e.g. using a wrong token or not existing API calls. If you have a fixed IP you can ask telegram service to unblock your ip or change your IP. If you are running a -tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in -'mycommands.sh' +socks or tor proxy on your server look for the ```BASHBOT_CURL_ARGS``` lines +in 'mycommands.sh' as example. @Gnadelwartz @@ -270,4 +270,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.96-dev-7-g0153928 +#### $$VERSION$$ v0.96-dev-8-ge63590b diff --git a/bashbot.sh b/bashbot.sh index b0bfd6f..9a34b88 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.96-dev-7-g0153928 +#### $$VERSION$$ v0.96-dev-8-ge63590b # # Exit Codes: # - 0 sucess (hopefully) @@ -688,6 +688,7 @@ start_bot() { fi while true; do UPDATE="$(getJson "$UPD_URL$OFFSET" | "${JSONSHFILE}" -s -b -n | iconv -f utf-8 -t utf-8 -c)" + UPDATE="${UPDATE//$/\\$}" # Offset OFFSET="$(grep <<< "${UPDATE}" '\["result",[0-9]*,"update_id"\]' | tail -1 | cut -f 2)"