From 8a119f8806574503897dd4c0a09b24531dd6c806 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Thu, 14 May 2020 13:04:57 +0200 Subject: [PATCH] some small fixes, start dev3 --- README.html | 2 +- README.md | 2 +- README.txt | 2 +- addons/antiFlood.sh | 2 +- addons/example.sh | 2 +- bashbot.rc | 6 +++- bashbot.sh | 28 +++++++++++++++---- 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 +- .../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 | 3 +- modules/jsonDB.sh | 2 +- modules/sendMessage.sh | 20 ++++++------- mycommands.sh | 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 +- 55 files changed, 90 insertions(+), 69 deletions(-) diff --git a/README.html b/README.html index eab66ba..3bf0ee2 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-dev2-0-g3d636f7

+

$$VERSION$$ v0.94-dev3-0-geef955a

diff --git a/README.md b/README.md index d7194b0..b457ee2 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/README.txt b/README.txt index b5f50df..e1375d2 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/addons/antiFlood.sh b/addons/antiFlood.sh index c46e591..25b09f6 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # used events: # diff --git a/addons/example.sh b/addons/example.sh index 5ba50de..300d53c 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # # If an event occours each registered event function is called. # diff --git a/bashbot.rc b/bashbot.rc index 1e0d907..b4d8d83 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # shellcheck disable=SC2009 # shellcheck disable=SC2181 @@ -76,6 +76,10 @@ case "$1" in 'suspendback'|'resumeback'|'killback') $runcmd "$start $1" RETVAL=$? + # kill inotifywait from runuser + if [ "$1" != "resumeback" ]; then + kill -9 "$(ps -u "$runas" | grep inotifywait | sed 's/ .*//')" >/dev/null 2>&1 + fi ;; *) echo "Usage: $0 { start | stop | restart | reload | restartback | suspendback | resumeback | killback }" diff --git a/bashbot.sh b/bashbot.sh index 0f1306b..488016a 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # # Exit Codes: # - 0 sucess (hopefully) @@ -136,7 +136,7 @@ declare -rx SCRIPT SCRIPTDIR MODULEDIR RUNDIR ADDONDIR TOKENFILE BOTADMIN BOTACL declare -rx BOTTOKEN URL ME_URL UPD_URL GETFILE_URL declare -ax CMD -declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY +declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY SERVICE NEWMEMBER export res CAPTION @@ -239,7 +239,7 @@ if [ "${BASHBOT_WGET}" = "" ] && _exists curl ; then local chat=""; [ "${1}" != "" ] && chat='"chat_id":'"${1}"',' # shellcheck disable=SC2086 - res="$(curl -s ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" -d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \ + res="$(curl -s -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" -d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \ -H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n )" BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")" BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")" @@ -269,7 +269,7 @@ else local chat=""; [ "${1}" != "" ] && chat='"chat_id":'"${1}"',' # shellcheck disable=SC2086 - res="$(wget -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - --post-data='{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' \ + res="$(wget --no-check-certificate -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - --post-data='{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' \ --header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -s -b -n )" BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")" BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")" @@ -596,9 +596,25 @@ process_message() { LOCATION[LONGITUDE]="${UPD["result",${num},"message","location","longitude"]}" LOCATION[LATITUDE]="${UPD["result",${num},"message","location","latitude"]}" + # service messages + SERVICE=( ); NEWMEMBER=( ) + SERVICE[NEWMEMBER]="${UPD["result",${num},"message","new_chat_member","id"]}" + if [ "${SERVICE[NEWMEMBER]}" != "" ]; then + NEWMEMBER[ID]="${SERVICE[NEWMEMBER]}" + NEWMEMBER[FIRSTNAME]="${UPD["result",${num},"message","new_chat_member","first_name"]}" + NEWMEMBER[LASTNAME]="${UPD["result",${num},"message","new_chat_member","last_name"]}" + NEWMEMBER[USERNAME]="${UPD["result",${num},"message","new_chat_member","username"]}" + NEWMEMBER[ISBOT]="${UPD["result",${num},"message","new_chat_member","is_bot"]}" + fi + SERVICE[LEFTMEMBER]="${UPD["result",${num},"message","left_chat_member","id"]}" + SERVICE[NEWTILE]="${UPD["result",${num},"message","new_chat_title"]}" + SERVICE[NEWPHOTO]="${UPD["result",${num},"message","new_chat_photo"]}" + SERVICE[PINNED]="${UPD["result",${num},"message","pinned_message"]}" + + # split message in command and args CMD=( ) - if [[ "${MESSAGE[0]}" = "/"* ]]; then + if [[ "${MESSAGE[0]}" == "/"* ]]; then set -f; unset IFS # shellcheck disable=SC2206 CMD=( ${MESSAGE[0]} ) @@ -626,6 +642,8 @@ start_bot() { # shellcheck source=./modules/aliases.sh [ -r "${addons}" ] && source "${addons}" "startbot" "${DEBUG}" done + # shellcheck source=./commands.sh + source "${COMMANDS}" "startbot" # start timer events if _is_function start_timer ; then # shellcheck disable=SC2064 diff --git a/commands.sh b/commands.sh index f1e1b8b..6d3478a 100644 --- a/commands.sh +++ b/commands.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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # # 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 35cf153..3734e2d 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 f333efd..72a31b2 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 c79c5e0..44d3a68 100755 --- a/dev/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a ############ # 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 61d09a4..382ec29 100755 --- a/dev/hooks/pre-push.sh +++ b/dev/hooks/pre-push.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a ############ # 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 794f03a..efc98f2 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 a7126ff..8184fc3 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 12552b9..5d3f66c 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 57eae4e..dda315e 100644 --- a/dev/shellcheck.files +++ b/dev/shellcheck.files @@ -1,3 +1,3 @@ # list of additional files to check from shellcheck -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a bashbot.rc diff --git a/dev/version.sh b/dev/version.sh index 49802fe..a19b3a3 100755 --- a/dev/version.sh +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # shellcheck disable=SC2016 # # Easy Versioning in git: diff --git a/doc/0_install.md b/doc/0_install.md index 78e831b..1e86154 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 6a8e9d8..bd325b4 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/doc/2_usage.md b/doc/2_usage.md index 2cff694..1e362b5 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -223,5 +223,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/doc/3_advanced.md b/doc/3_advanced.md index d33dd33..522efa8 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/doc/4_expert.md b/doc/4_expert.md index 2059d70..4eccf63 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/doc/5_practice.md b/doc/5_practice.md index 4243ccb..0f93e06 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/doc/6_reference.md b/doc/6_reference.md index 9131b7a..d76483d 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -947,5 +947,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-dev2-1-g4f90215 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/doc/7_develop.md b/doc/7_develop.md index 386a2a1..d6b151c 100644 --- a/doc/7_develop.md +++ b/doc/7_develop.md @@ -321,5 +321,5 @@ fi #### [Prev Function Reference](6_reference.md) -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/examples/README.md b/examples/README.md index 81d31f4..ecca1de 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a diff --git a/examples/background-scripts/run_diskusage.sh b/examples/background-scripts/run_diskusage.sh index 7e71cad..7c90b44 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 bedf5ea..c53e686 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 3626c75..1552e0a 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 5300530..ea97341 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 3a7bfcc..a0f2478 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then echo "Usage: $0 botname command" diff --git a/examples/bashbot.cron b/examples/bashbot.cron index f56f2ff..88fbc26 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a SHELL=/bin/sh diff --git a/examples/calc.sh b/examples/calc.sh index f6d26a3..b54bf75 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 2c8c54f..89d7a74 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 f32ef49..03d4cec 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 d4706c1..c53316e 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # Format: # user:ressource:chat diff --git a/examples/send-system-status/mycommands.sh b/examples/send-system-status/mycommands.sh index 5d8c1b5..f4ec539 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/modules/aliases.sh b/modules/aliases.sh index 074971c..0347c11 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # # source from commands.sh to use the aliases diff --git a/modules/answerInline.sh b/modules/answerInline.sh index 0c1e0d1..578217a 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # source from commands.sh to use the inline functions diff --git a/modules/background.sh b/modules/background.sh index ad21fbc..78eebec 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # source from commands.sh if you want ro use interactive or background jobs diff --git a/modules/chatMember.sh b/modules/chatMember.sh index 4afa196..9f220d1 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # source from commands.sh to use the member functions @@ -48,7 +48,6 @@ user_is_admin() { user_is_botadmin() { local admin; admin="$(head -n 1 "${BOTADMIN}")" [ "${admin}" = "${1}" ] && return 0 - [ "${admin}" = "${2}" ] && return 0 [[ "${admin}" = "@*" ]] && [[ "${admin}" = "${2}" ]] && return 0 if [ "${admin}" = "?" ]; then printf '%s\n' "${1:-?}" >"${BOTADMIN}"; return 0; fi return 1 diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index 7867b7e..35e1e4a 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # # source from commands.sh to use jsonDB functions # diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index e189510..c5762e3 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # source from commands.sh to use the sendMessage functions @@ -22,7 +22,7 @@ ACTION_URL=$URL'/sendChatAction' FORWARD_URL=$URL'/forwardMessage' send_normal_message() { - local text="$(JsonEscape "${2}")" + local text; text="$(JsonEscape "${2}")" until [ -z "${text}" ]; do sendJson "${1}" '"text":"'"${text:0:4096}"'"' "${MSG_URL}" text="${text:4096}" @@ -30,7 +30,7 @@ send_normal_message() { } send_markdown_message() { - local text="$(JsonEscape "${2}")" + local text; text="$(JsonEscape "${2}")" until [ -z "${text}" ]; do sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdown"' "${MSG_URL}" text="${text:4096}" @@ -38,7 +38,7 @@ send_markdown_message() { } send_html_message() { - local text="$(JsonEscape "${2}")" + local text; text="$(JsonEscape "${2}")" until [ -z "${text}" ]; do sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"html"' "${MSG_URL}" text="${text:4096}" @@ -46,7 +46,7 @@ send_html_message() { } old_send_keyboard() { - local text='"text":"'$(JsonEscape "${2}")'"' + local text; text='"text":"'$(JsonEscape "${2}")'"' shift 2 local keyboard="init" OLDIFS="$IFS" @@ -64,24 +64,24 @@ sendEmpty() { } send_keyboard() { if [[ "$3" != *'['* ]]; then old_send_keyboard "${@}"; return; fi - local text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' + local text; text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' local one_time=', "one_time_keyboard":true' && [ "$4" != "" ] && one_time="" sendEmpty "${1}" "${text}"', "reply_markup": {"keyboard": [ '"${3}"' ] '"${one_time}"'}' "$MSG_URL" # '"text":"$2", "reply_markup": {"keyboard": [ ${3} ], "one_time_keyboard": true}' } remove_keyboard() { - local text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' + local text; text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' sendEmpty "${1}" "${text}"', "reply_markup": {"remove_keyboard":true}' "$MSG_URL" #JSON='"text":"$2", "reply_markup": {"remove_keyboard":true}' } send_inline_keyboard() { - local text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' + local text; text='"text":"'$(JsonEscape "${2}")'"'; [ "${2}" = "" ] && text='"text":"'"${ISEMPTY}"'"' sendEmpty "${1}" "${text}"', "reply_markup": {"inline_keyboard": [ '"${3}"' ]}' "$MSG_URL" # JSON='"text":"$2", "reply_markup": {"inline_keyboard": [ $3->[{"text":"text", "url":"url"}]<- ]}' } send_button() { - send_inline_keyboard "${1}" "${2}" '[ {"text":"'$(JsonEscape "${3}")'", "url":"'"${4}"'"}]' + send_inline_keyboard "${1}" "${2}" '[ {"text":"'"$(JsonEscape "${3}")"'", "url":"'"${4}"'"}]' } @@ -114,7 +114,7 @@ upload_file(){ WHAT="audio" STATUS="upload_audio" ;; - png|jpg|jpeg|gif) + png|jpg|jpeg|gif|pic) CUR_URL="$PHO_URL" WHAT="photo" STATUS="upload_photo" diff --git a/mycommands.sh b/mycommands.sh index 6cebf22..539a1dd 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -2,7 +2,7 @@ # files: mycommands.sh.dist # copy to mycommands.sh and add all your commands and functions here ... # -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # # uncomment the following lines to overwrite info and help messages diff --git a/test/ADD-test-new.sh b/test/ADD-test-new.sh index 368f95c..fea7bb4 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 203d590..04672b0 100644 --- a/test/ALL-tests.inc.sh +++ b/test/ALL-tests.inc.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME diff --git a/test/a-commit-test.sh b/test/a-commit-test.sh index 9f4c534..99114a4 100755 --- a/test/a-commit-test.sh +++ b/test/a-commit-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a ../dev/hooks/pre-commit.sh diff --git a/test/b-example-test.sh b/test/b-example-test.sh index a8d602b..540609c 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 9774c30..91cbe6c 100755 --- a/test/c-init-test.sh +++ b/test/c-init-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 174b497..86799da 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 a160841..2840507 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 de20666..bc2ff87 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 40765f5..935c650 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 10481e9..b36e502 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-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # 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 7b75973..8668cfc 100755 --- a/test/e-env-test.sh +++ b/test/e-env-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.94-dev2-0-g3d636f7 +#### $$VERSION$$ v0.94-dev3-0-geef955a # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh