diff --git a/README.html b/README.html index bc5abc2..d14379b 100644 --- a/README.html +++ b/README.html @@ -263,6 +263,6 @@ It features background tasks and interactive chats, and can serve as an interfac

@Gnadelwartz

That's it all guys!

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

-

$$VERSION$$ v1.51-0-g6e66a28

+

$$VERSION$$ v1.52-0-g1a83202

diff --git a/README.md b/README.md index 5052eb8..f228ab3 100644 --- a/README.md +++ b/README.md @@ -242,4 +242,4 @@ See `mycommnds.sh.dist` for an example. If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db diff --git a/README.txt b/README.txt index b05bd68..0bf5858 100644 --- a/README.txt +++ b/README.txt @@ -319,5 +319,5 @@ That's it all guys! If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -$$VERSION$$ v1.51-0-g6e66a28 +$$VERSION$$ v1.52-0-g1a83202 diff --git a/addons/antiFlood.sh b/addons/antiFlood.sh index 0d8fd3b..b2fcfd8 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$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db # used events: # diff --git a/addons/example.sh b/addons/example.sh index e63c27e..4635b9f 100644 --- a/addons/example.sh +++ b/addons/example.sh @@ -4,7 +4,7 @@ # Addons can register to bashbot events at startup # by providing their name and a callback per event # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db # # If an event occurs each registered event function is called. # diff --git a/bashbot.rc b/bashbot.rc index 4c92468..9c9ec71 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,11 +1,11 @@ -#!/bin/sh +#!/bin/bash # description: Start or stop telegram-bash-bot # # example service script to run bashbot in background as specified user # # tested on: ubuntu, opensuse, debian # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db # shellcheck disable=SC2009 # shellcheck disable=SC2181 # shellcheck disable=SC2250 @@ -59,32 +59,32 @@ hooklog="WEBHOOK" # check for bot status +stat="" ps -f -u "${runas}" | grep "${name}" | grep -qF "bashbot.sh startbot" if [ "$?" = "0" ]; then # printf "bashbot (%s) is running in poll mode\n" "${name}" - stat="poll" + stat="${stat} polling" +fi +ps -f -u "${runas}" | grep "${name}" | grep -qF "process_batch.sh --startbot" +if [ "$?" = "0" ]; then + #printf "bashbot (%s) is running in webhook mode\n" "${name}" + stat="${stat} webhook" +elif [ "${name}" != "unknown" ]; then + #printf "bashbot (%s) is stopped\n" "${name}" + stat="stop" else - ps -f -u "${runas}" | grep "${name}" | grep -qF "process_batch.sh --startbot" - if [ "$?" = "0" ]; then - #printf "bashbot (%s) is running in webhook mode\n" "${name}" - stat="hook" - elif [ "${name}" != "unknown" ]; then - #printf "bashbot (%s) is stopped\n" "${name}" - stat="stop" - else - stat="unknown" - fi + stat="unknown" fi case "$1" in 'start') - [ "${stat}" != "stop" ] && printf "Warning, bot is running in mode: %s\n" "${stat}" + [ "${stat}" != "stop" ] && printf "Warning, bot is already running in mode: %s\n" "${stat}" $runcmd "$bashbot start $mode" # >/dev/null 2>&1 >${bashbotdir}/logs/${hooklog}.log &" # >/dev/null 2>&1 /dev/null" + $runcmd "kill ${KILLID} 2>/dev/null; wait ${KILLID} 2>/dev/null" sleep 1 fi RETVAL=$? @@ -109,13 +109,13 @@ case "$1" in ;; 'status') case "${stat}" in - "poll"*) printf "bashbot (%s) is running in poll mode\n" "${name}" + *"poll"*) printf "bashbot (%s) is running in polling mode\n" "${name}" + RETVAL=0 + ;;& + *"hook"*) printf "bashbot (%s) is running in webhook mode\n" "${name}" RETVAL=0 ;; - "hook"*) printf "bashbot (%s) is running in webhook mode\n" "${name}" - RETVAL=0 - ;; - "stop"*) printf "bashbot (%s) is not running\n" "${name}" + *"stop"*) printf "bashbot (%s) is not running\n" "${name}" RETVAL=1 ;; *) printf "bashbot (%s) status is %s\n" "${name}" "${stat}" @@ -137,7 +137,7 @@ case "$1" in ;; 'suspendback'|'resumeback'|'killback') # shellcheck disable=SC2250 - $runcmd "$bashbot $1 $mode" + $runcmd "$bashbot $1" RETVAL=$? # kill inotifywait from runuser if [ "$1" != "resumeback" ]; then diff --git a/bashbot.sh b/bashbot.sh index 2e0dc20..e88c901 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db ################################################################## # are we running in a terminal? @@ -550,14 +550,14 @@ if detect_curl ; then # $1 URL, $2 hack: log getJson if not "" getJson(){ # shellcheck disable=SC2086 - "${BASHBOT_CURL}" -sL -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" "$1" + "${BASHBOT_CURL}" -sL -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" -K - <<<"url=$1" } # curl variant for sendJson # usage: "JSON" "URL" sendJson_do(){ # shellcheck disable=SC2086 "${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}"\ - -d "$1" -X POST "$2" -H "Content-Type: application/json" | "${JSONSHFILE}" -b -n 2>/dev/null + -d "$1" -X POST -K - <<<"url=$2" -H "Content-Type: application/json" | "${JSONSHFILE}" -b -n 2>/dev/null } #$1 Chat, $2 what, $3 file, $4 URL, $5 caption sendUpload() { @@ -566,11 +566,11 @@ if detect_curl ; then [ -n "${BASHBOTDEBUG}" ] &&\ log_update "sendUpload CHAT=$1 WHAT=$2 FILE=$3 CAPT=$5" # shellcheck disable=SC2086 - res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1"\ + res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} -K - <<<"url=$4" -F "chat_id=$1"\ -F "$2=@$3;${3##*/}" -F "caption=$5" | "${JSONSHFILE}" -b -n 2>/dev/null )" else # shellcheck disable=SC2086 - res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} "$4" -F "chat_id=$1"\ + res="$("${BASHBOT_CURL}" -s -k ${BASHBOT_CURL_ARGS} -K - <<<"url=$4" -F "chat_id=$1"\ -F "$2=@$3;${3##*/}" | "${JSONSHFILE}" -b -n 2>/dev/null )" fi sendJsonResult "${res}" "sendUpload (curl)" "$@" @@ -581,14 +581,14 @@ else if _exists wget; then getJson(){ # shellcheck disable=SC2086 - wget --no-check-certificate -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - "$1" + wget --no-check-certificate -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - -i <<<"$1" } # curl variant for sendJson # usage: "JSON" "URL" sendJson_do(){ # shellcheck disable=SC2086 wget --no-check-certificate -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - --post-data="$1" \ - --header='Content-Type:application/json' "$2" | "${JSONSHFILE}" -b -n 2>/dev/null + --header='Content-Type:application/json' -i <<<"$2" | "${JSONSHFILE}" -b -n 2>/dev/null } sendUpload() { log_error "Sorry, wget does not support file upload" diff --git a/bin/any_command.sh b/bin/any_command.sh index 3682aab..dc5ad6f 100755 --- a/bin/any_command.sh +++ b/bin/any_command.sh @@ -21,7 +21,7 @@ USAGE='any_command.sh [-h|--help] [--force|--reference] bot_command args ...' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 30.01.2021 10:24 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== #### diff --git a/bin/bashbot_env.inc.sh b/bin/bashbot_env.inc.sh index 0322909..0eae310 100644 --- a/bin/bashbot_env.inc.sh +++ b/bin/bashbot_env.inc.sh @@ -13,7 +13,7 @@ # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 18.12.2020 12:27 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== ############ diff --git a/bin/bashbot_init.inc.sh b/bin/bashbot_init.inc.sh index 6d0d537..33309b1 100644 --- a/bin/bashbot_init.inc.sh +++ b/bin/bashbot_init.inc.sh @@ -11,7 +11,7 @@ # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 27.01.2021 13:42 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== # shellcheck disable=SC2059 diff --git a/bin/bashbot_stats.sh b/bin/bashbot_stats.sh index 176cd83..9fd6c3a 100755 --- a/bin/bashbot_stats.sh +++ b/bin/bashbot_stats.sh @@ -17,7 +17,7 @@ USAGE='bashbot_stats.sh [-h|--help] [debug]' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 23.12.2020 20:34 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== # set bashbot environment diff --git a/bin/delete_message.sh b/bin/delete_message.sh index 6f54d51..24977b4 100755 --- a/bin/delete_message.sh +++ b/bin/delete_message.sh @@ -20,7 +20,7 @@ USAGE='delete_message.sh [-h|--help] "CHAT[ID]" "MESSAGE[ID]" [debug]' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 03.01.2021 15:37 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== #### diff --git a/bin/edit_buttons.sh b/bin/edit_buttons.sh index 47ce9ee..94bdea8 100755 --- a/bin/edit_buttons.sh +++ b/bin/edit_buttons.sh @@ -26,7 +26,7 @@ USAGE='send_message.sh [-h|--help] "CHAT[ID]" "MESSAGE[ID]" "text|url" ...' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 21.01.2021 08:10 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== #### diff --git a/bin/edit_message.sh b/bin/edit_message.sh index 315dc5d..4ed9cb9 100755 --- a/bin/edit_message.sh +++ b/bin/edit_message.sh @@ -23,7 +23,7 @@ USAGE='send_edit_message.sh [-h|--help] [format|caption] "CHAT[ID]" "MESSAGE[ID] # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 23.12.2020 16:52 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== #### diff --git a/bin/kickban_user.sh b/bin/kickban_user.sh index 81ab29e..2bb19ca 100755 --- a/bin/kickban_user.sh +++ b/bin/kickban_user.sh @@ -20,7 +20,7 @@ USAGE='kickban_user.sh [-h|--help] [-u|--unban] "CHAT[ID]" "USER[ID]" [debug]' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 25.01.2021 20:34 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== #### diff --git a/bin/process_batch.sh b/bin/process_batch.sh index cc9aa79..a1ea95f 100755 --- a/bin/process_batch.sh +++ b/bin/process_batch.sh @@ -21,7 +21,7 @@ USAGE='process_batch.sh [-h|--help] [-s|--startbot] [-w|--watch] [-n|--lines n] # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 27.02.2021 13:14 # -#### $$VERSION$$ v1.51-6-g6490f67 +#### $$VERSION$$ v1.52-1-g0dae2db #=============================================================================== #### diff --git a/bin/process_update.sh b/bin/process_update.sh index 39b1849..005fb8c 100755 --- a/bin/process_update.sh +++ b/bin/process_update.sh @@ -15,7 +15,7 @@ USAGE='process_update.sh [-h|--help] [debug] [