diff --git a/README.html b/README.html index 3c3f61e..ec70693 100644 --- a/README.html +++ b/README.html @@ -107,6 +107,6 @@

@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.80-dev3-5-g83623ec

+


VERSION
v0.80-pre-0-gdd7c66d

diff --git a/README.md b/README.md index cc2d1f9..6379fc9 100644 --- a/README.md +++ b/README.md @@ -106,4 +106,4 @@ Well, thats a damn good question ... may be because I'm an Unix/Linux admin from If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.80-dev3-5-g83623ec +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/README.txt b/README.txt index d1459ff..42ae383 100644 --- a/README.txt +++ b/README.txt @@ -154,4 +154,4 @@ health status If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.80-dev3-5-g83623ec +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/bashbot.rc b/bashbot.rc index 908f863..56a9647 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 8f6c2cb..43bc6fd 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -12,7 +12,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.80-dev3-6-gbeb77a4 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # # Exit Codes: # - 0 sucess (hopefully) @@ -62,7 +62,7 @@ if [ ! -f "${TOKENFILE}" ]; then echo -e "${RED}TOKEN MISSING.${NC}" echo -e "${ORANGE}PLEASE WRITE YOUR TOKEN HERE OR PRESS CTRL+C TO ABORT${NC}" read -r token - echo "${token}" > "${TOKENFILE}" + printf '%s\n' "${token}" > "${TOKENFILE}" fi fi @@ -70,22 +70,22 @@ BOTADMIN="${BASHBOT_ETC:-.}/botadmin" if [ ! -f "${BOTADMIN}" ]; then if [ "${CLEAR}" = "" ]; then echo "Running headless, set botadmin to AUTO MODE!" - echo '?' > "${BOTADMIN}" + printf '%s\n' '?' > "${BOTADMIN}" else ${CLEAR} echo -e "${RED}BOTADMIN MISSING.${NC}" echo -e "${ORANGE}PLEASE WRITE YOUR TELEGRAM ID HERE OR ENTER '?'${NC}" echo -e "${ORANGE}TO MAKE FIRST USER TYPING '/start' TO BOTADMIN${NC}" - read -r token - echo "${token}" > "${BOTADMIN}" - [ "${token}" = "" ] && echo '?' > "${BOTADMIN}" + read -r admin + printf '%S\n' "${admin}" > "${BOTADMIN}" + [ "${admin}" = "" ] && printf '%s\n' '?' > "${BOTADMIN}" fi fi BOTACL="${BASHBOT_ETC:-.}/botacl" if [ ! -f "${BOTACL}" ]; then echo -e "${ORANGE}Create empty ${BOTACL} file.${NC}" - echo "" >"${BOTACL}" + printf '\n' >"${BOTACL}" fi TMPDIR="${BASHBOT_VAR:-.}/data-bot-bash" @@ -99,7 +99,7 @@ fi COUNTFILE="${BASHBOT_VAR:-.}/count" if [ ! -f "${COUNTFILE}" ]; then - echo "" >"${COUNTFILE}" + printf '\n' >"${COUNTFILE}" elif [ ! -w "${COUNTFILE}" ]; then echo -e "${RED}ERROR: Can't write to ${COUNTFILE}!.${NC}" ls -l "${COUNTFILE}" @@ -135,7 +135,7 @@ fi # $1 postfix, e.g. chatid # $2 prefix, back- or startbot- procname(){ - echo "$2${ME}_$1" + printf '%s\n' "$2${ME}_$1" } # $1 proc name @@ -262,7 +262,7 @@ process_client() { # shellcheck source=./commands.sh source "${COMMANDS}" "${debug}" tmpcount="COUNT${CHAT[ID]}" - grep -q "$tmpcount" <"${COUNTFILE}" >/dev/null 2>&1 || cat <<< "$tmpcount" >>"${COUNTFILE}" + grep -q "$tmpcount" <"${COUNTFILE}" &>/dev/null || cat <<< "$tmpcount" >>"${COUNTFILE}" # To get user count execute bash bashbot.sh count } process_inline() { @@ -329,8 +329,8 @@ process_message() { URLS[VOICE]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","voice","file_id"' <"$TMP")")" # Contact - CONTACT[USER_ID]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","user_id"' <"$TMP")")" CONTACT[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","first_name"' <"$TMP")")" + CONTACT[USER_ID]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","user_id"' <"$TMP")")" CONTACT[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","last_name"' <"$TMP")")" CONTACT[NUMBER]="$(JsonGetString '"result",'"${num}"',"message","contact","phone_number"' <"$TMP")" CONTACT[VCARD]="$(JsonGetString '"result",'"${num}"',"message","contact","vcard"' <"$TMP")" @@ -393,13 +393,13 @@ bot_init() { [ -f "modules/inline.sh" ] && rm -f "modules/inline.sh" # shellcheck disable=SC2009 oldbot="$(ps -ef | grep startbot | grep -v -e 'grep' -e '\-startbot' )" - [ "${oldbot}" != "" ] && echo -e "${ORANGE}Warning: Old TMUX bot is running! You must kill it manually first:${NC}\\n$${oldbot}" && exit 5 + [ "${oldbot}" != "" ] && echo -e "${ORANGE}Warning: Old TMUX bot is running! You must kill it manually first:${NC}\\n${oldbot}" #setup bashbot [[ "${UID}" -eq "0" ]] && RUNUSER="nobody" echo -n "Enter User to run basbot [$RUNUSER]: " read -r TOUSER [ "$TOUSER" = "" ] && TOUSER="$RUNUSER" - if ! id "$TOUSER" >/dev/null 2>&1; then + if ! id "$TOUSER" &>/dev/null; then echo -e "${RED}User \"$TOUSER\" not found!${NC}" exit 3 else diff --git a/commands.sh b/commands.sh index 129c378..e619a42 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # # adjust your language setting here, e.g.when run from other user or cron. @@ -107,7 +107,7 @@ if [ "${1}" != "source" ];then if [ "$res" -eq 0 ] ; then killproc && _message "Command canceled.";else _message "No command is currently running.";fi ;; *) # forward messages to optional dispatcher - _is_function forward_interactive && forward_interactive "${CHAT[ID]}" "${MESSAGE}" # interactive running + _is_function send_interactive && send_interactive "${CHAT[ID]}" "${MESSAGE}" _is_function mycommands && mycommands ;; esac diff --git a/dev/all-tests.sh b/dev/all-tests.sh index 7739b76..c3ccaf7 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 249bd60..33a5926 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 38f5729..8fa8eff 100755 --- a/dev/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d ############ # 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 b50de77..7853247 100755 --- a/dev/hooks/pre-push.sh +++ b/dev/hooks/pre-push.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d ############ # 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 7c58fe0..ff24815 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 7f1253a..fc65af3 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 7d49f07..99b92ed 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 5bf5b1e..672df7f 100644 --- a/dev/shellcheck.files +++ b/dev/shellcheck.files @@ -1,3 +1,3 @@ # list of additional files to check from shellcheck -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d bashbot.rc diff --git a/dev/version.sh b/dev/version.sh index c4851f6..b5bee19 100755 --- a/dev/version.sh +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # shellcheck disable=SC2016 # # Easy Versioning in git: diff --git a/doc/0_install.md b/doc/0_install.md index 47b1f7b..a8740d9 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -35,19 +35,34 @@ As an alternative to download the zip files, you can clone the github repository 3. Extract all files to your existing bashbot dir **Note: all files execpt 'mycommands.sh' and 'commands.sh' may overwritten!** 4. Save your your current 'commands.sh' and run ```cp commands.sh.dist commands.sh``` -5. Run ```sudo ./bashbot.sh init``` to setup your environment after the update +5. Stop all running instances of bashbot at this point latest +6. Run ```sudo ./bashbot.sh init``` to setup your environment after the update If you modified 'commands.sh' re apply all changes to the new 'commands.sh'. To avoid this all your modifications must be done in 'mycommands.sh' only. +Now you can restart your bashbot instances. + ### Notes on Updates -#### Location of tmp / data dir -From version 0.70 on the tmp dir is renamed to 'data-bot-bash' to reflect the fact that not only temporary files are stored. an existing 'tmp-bot-bash' will be automatically renamed after update. +#### removal of TMUX +From version 0.80 on TMUX is no longer needed and the bachsbot command 'attach' is deleted. Old function 'inproc' +is replaced by 'send_interactive'. send_interactive does checks if an interactive job is running internaly. +Pls check if you make use of inproc and remove it including the old checks, e.g. +```bash +if tmux ls | grep -v send | grep -q "$copname"; then inproc; fi +# or +[ checkprog ] && inproc +``` +must be replaced by ```send_interactive "${CHATD[ID]}" "${MESSAGE}"``` +### Do not edit commands.sh From version 0.60 on your commands must be placed in 'mycommands.sh'. If you update from a version with your commands in 'commands.sh' move all your commands and functions to 'mycommands.sh'. +#### Location of var / tmp / data dirs +From version 0.70 on the tmp dir is renamed to 'data-bot-bash' to reflect the fact that not only temporary files are stored. an existing 'tmp-bot-bash' will be automatically renamed after update. + From version 0.50 on the temporary files are no more placed in '/tmp'. instead a dedicated tmp dir is used. #### Changes to send_keyboard in v0.6 @@ -70,5 +85,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index deb4785..48aef6c 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/doc/2_usage.md b/doc/2_usage.md index 3f9d780..e5d2ff0 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -182,5 +182,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 0ae7851..2b7e085 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/doc/4_expert.md b/doc/4_expert.md index 6f7f6c0..bfdbddf 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```. #### [Prev Expert Use](4_expert.md) #### [Next Best Practice](5_practice.md) -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/doc/5_practice.md b/doc/5_practice.md index fc69778..bc02fd0 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -153,5 +153,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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/doc/6_reference.md b/doc/6_reference.md index a5be7f1..636f56c 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -84,6 +84,17 @@ See also [deleteMessage limitations](https://core.telegram.org/bots/api#deleteme ---- +##### send_message +```send_message``` sends any type of message to the given chat. Type of output is steered by keywords within the message. + +The main use case for send_message is to process the output of interactive chats and background jobs. **For regular Bot commands I recommend using of the dedicated send_xxx_message() functions from above.** + +*usage:* send_message "${CHAT[ID]}" "message" + +*example:* - see [Usage](2_usage.md#send_message) and [Advanced Usage](3_advanced.md#Interactive-Chats) + +---- + ### File, Location, Venue, Keyboard @@ -335,13 +346,14 @@ You must include ```source modules/background.sh``` in 'commands.sh' to have th *usage:* start_proc "${CHAT[ID]}" "script" -*alias:* startproc "${CHAT[ID]}" "script" +*alias:* startproc "script" *example:* ```bash startproc 'examples/calc.sh' ``` + ##### check_proc Return true (0) if an interactive script is running in the chat. @@ -351,8 +363,7 @@ Return true (0) if an interactive script is running in the chat. *example:* ```bash -checkproc -if [ "$res" -gt 0 ] ; then +if ! check_proc "${CHAT[ID]}" ; then startproc "examples/calc.sh" else send_normal_message "${CHAT[ID]}" "Calc already running ..." @@ -368,8 +379,7 @@ Kill the interactive script running in the chat *example:* ```bash -checkprog -if [ "$res" -eq 0 ]; then +if check_proc "${CHAT[ID]}" ; then killproc && send_message "${CHAT[ID]}" "Command canceled." else send_message "${CHAT[ID]}" "Command is not running." @@ -401,8 +411,7 @@ Return true (0) if an background job is active in the given chat. *example:* ```bash -checkback "notify" -if [ "$res" -gt 0 ] ; then +if ! checkback "notify" ; then send_normal_message "${CHAT[ID]}" "Start notify" background "examples/notify.sh" "notify" else @@ -429,16 +438,13 @@ fi ---- -##### send_message -```send_message``` sends any type of message to the given chat. Type of output is steered by keywords within the message. +##### send_interactive +Form version 0.80 on forward_message is used to forward messages to interactive job. It replaces the old 'inproc' commands used for TMUX. +Usually message is automatically forwarded in 'commands.sh', but you can forward messages wihle processing also or send your own messages. -The main use case for send_message is to process the output of interactive chats and background jobs. **For regular Bot commands I recommend using of the dedicated send_xxx_message() functions from above.** +*usage:* send_interactive "${CHAT[ID]}" "message" -*usage:* send_message "${CHAT[ID]}" "message" - -*example:* - see [Usage](2_usage.md#send_message) and [Advanced Usage](3_advanced.md#Interactive-Chats) - ----- +*replaces:*' incproc ### Aliases - shortcuts for often used funtions You must include ```source modules/aliases.sh``` in 'commands.sh' to have the following functions availible. @@ -565,7 +571,7 @@ _is_function "background" && _message "you can run background jobs!" These functions are for internal use only and must not used in your bot commands. ##### procname -Returns PrefixBotname-Postfix +Returns PrefixBotname_Postfix *usage:* procname postfix prefix @@ -620,11 +626,8 @@ The name of your bot is availible as bash variable "$ME", there is no need to ca *usage:* ME="$(getBotNiname)" -##### inproc -Send Input from Telegram to waiting Interactive Chat. - #### [Prev Best Practice](5_practice.md) #### [Next Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.80-dev3-7-g7190c6e +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/doc/7_develop.md b/doc/7_develop.md index 81eed8e..785b3b8 100644 --- a/doc/7_develop.md +++ b/doc/7_develop.md @@ -188,5 +188,5 @@ fi #### [Prev Function Reference](6_reference.md) #### [Next Bashbot Environment](8_custom.md) -#### $$VERSION$$ v0.80-dev3-5-g83623ec +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/doc/8_custom.md b/doc/8_custom.md index ebb2f3b..35b87dc 100644 --- a/doc/8_custom.md +++ b/doc/8_custom.md @@ -131,5 +131,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms. #### [Prev Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/examples/README.md b/examples/README.md index 11426f6..b2863d5 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d diff --git a/examples/background-scripts/run_diskusage.sh b/examples/background-scripts/run_diskusage.sh index 043ae6c..0fb31ac 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 826c33c..39f39e7 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 86911fa..a9692eb 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 1f81f75..13d0e6d 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 293eb78..9dd7231 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then echo "Usage: $0 botname command" diff --git a/examples/bashbot.cron b/examples/bashbot.cron index d727ca6..dd5c21d 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d SHELL=/bin/sh diff --git a/examples/calc.sh b/examples/calc.sh index 2c79621..f8eadf5 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 45e2d14..1f02cfc 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 2ebf99c..25d20e2 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.80-dev3-2-ga1a823b +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 2c20ed9..80d4335 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # Format: # user:ressource:chat diff --git a/examples/send-system-status/mycommands.sh b/examples/send-system-status/mycommands.sh index 7c9b946..755aadc 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/modules/aliases.sh b/modules/aliases.sh index 5781952..859a447 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # # source from commands.sh to use the aliases diff --git a/modules/answerInline.sh b/modules/answerInline.sh index fcdae5f..69774d7 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # source from commands.sh to use the inline functions @@ -97,6 +97,6 @@ inline_query_compose(){ ;; esac - echo "${JSON}" + printf '%s\n' "${JSON}" } diff --git a/modules/background.sh b/modules/background.sh index 4cb7fd5..917ab31 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.80-dev3-6-gbeb77a4 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # source from commands.sh if you want ro use interactive or background jobs @@ -38,7 +38,7 @@ killproc() { # $3 jobname start_back() { local fifo; fifo="${TMPDIR:-.}/$(procname "$1")" - echo "$1:$3:$2" >"${fifo}$3-back.cmd" + printf '%s\n' "$1:$3:$2" >"${fifo}$3-back.cmd" start_proc "$1" "$2" "back-$3-" } @@ -95,7 +95,12 @@ kill_proc() { # $1 chat # $2 message -forward_interactive() { +send_interactive() { local fifo; fifo="${TMPDIR:-.}/$(procname "$1")" - [ -p "${fifo}" ] && echo "$2" >"${fifo}" + [ -p "${fifo}" ] && printf '%s\n' "$2" >"${fifo}" & # not blocking! +} + +# old style but may not work because of local checks +inproc() { + send_interactive "${CHAT[ID]}" "${MESSAGE}" } diff --git a/modules/chatMember.sh b/modules/chatMember.sh index d2ed8d9..e0d4d69 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # source from commands.sh to use the member functions @@ -48,7 +48,7 @@ user_is_botadmin() { local admin; admin="$(head -n 1 "${BOTADMIN}")" [ "${admin}" = "${1}" ] && return 0 [[ "${admin}" = "@*" ]] && [[ "${admin}" = "${2}" ]] && return 0 - if [ "${admin}" = "?" ]; then echo "${1:-?}" >"${BOTADMIN}"; return 0; fi + if [ "${admin}" = "?" ]; then printf '%s\n' "${1:-?}" >"${BOTADMIN}"; return 0; fi return 1 } diff --git a/modules/sendMessage.sh b/modules/sendMessage.sh index cb9999f..d34a5e5 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # source from commands.sh to use the sendMessage functions @@ -48,12 +48,12 @@ send_html_message() { old_send_keyboard() { local text='"text":"'"${2}"'"' shift 2 - local keyboard=init - OLDIFS=$IFS - IFS=$(echo -en "\"") + local keyboard="init" + OLDIFS="$IFS" + IFS="\"" for f in "$@" ;do [ "$f" != " " ] && keyboard="$keyboard, [\"$f\"]";done - IFS=$OLDIFS - keyboard=${keyboard/init, /} + IFS="$OLDIFS" + keyboard="${keyboard/init, /}" sendJson "${1}" "${text}"', "reply_markup": {"keyboard": [ '"${keyboard}"' ],"one_time_keyboard": true}' "$MSG_URL" } diff --git a/mycommands.sh b/mycommands.sh index 33d8edf..e1adfed 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # # 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 d097145..fcf48c6 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 8208922..8829e25 100644 --- a/test/ALL-tests.inc.sh +++ b/test/ALL-tests.inc.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # common variables export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME diff --git a/test/a-commit-test.sh b/test/a-commit-test.sh index c0a19e5..385517f 100755 --- a/test/a-commit-test.sh +++ b/test/a-commit-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d ../dev/hooks/pre-commit.sh diff --git a/test/b-example-test.sh b/test/b-example-test.sh index d50cc87..416a247 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 b440572..1b6b181 100755 --- a/test/c-init-test.sh +++ b/test/c-init-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 9a45a95..e4b4e35 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 46a6e30..7325efd 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 5efc4ed..58f339d 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 750be37..f4938b8 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 901ccbd..5a92104 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.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # 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 d9aefdd..9b73472 100755 --- a/test/e-env-test.sh +++ b/test/e-env-test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#### $$VERSION$$ v0.80-dev3-0-g31a5d00 +#### $$VERSION$$ v0.80-pre-0-gdd7c66d # include common functions and definitions # shellcheck source=test/ALL-tests.inc.sh