From 83623ece2e005d52f6ddff27fa0b552b5d83f35e Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 19 May 2019 13:59:36 +0200 Subject: [PATCH] fix interactive and MESSAGE extraction --- bashbot.sh | 10 +++++----- modules/background.sh | 9 ++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 8b151f1..21c3497 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-3-ga3c0d31 +#### $$VERSION$$ v0.80-dev3-4-ge7d2eff # # Exit Codes: # - 0 sucess (hopefully) @@ -253,16 +253,16 @@ process_client() { local num="$1" debug="$2" iQUERY[ID]="$(JsonGetString <<<"${UPDATE}" '"result",'"${num}"',"inline_query","id"')" if [ "${iQUERY[ID]}" = "" ]; then - [[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE$'\\n'" >>"MESSAGE.log" + [[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE" >>"MESSAGE.log" process_message "${num}" "${debug}" else - [[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE$'\\n'" >>"INLINE.log" + [[ "${debug}" = *"debug"* ]] && cat <<< "$UPDATE" >>"INLINE.log" [ "$INLINE" != "0" ] && _is_function process_inline && process_inline "${num}" "${debug}" fi # shellcheck source=./commands.sh source "${COMMANDS}" "${debug}" tmpcount="COUNT${CHAT[ID]}" - grep -q "$tmpcount" <"${COUNTFILE}" >/dev/null 2>&1 || cat <<< "$tmpcount$'\\n'" >>"${COUNTFILE}" + grep -q "$tmpcount" <"${COUNTFILE}" >/dev/null 2>&1 || cat <<< "$tmpcount" >>"${COUNTFILE}" # To get user count execute bash bashbot.sh count } process_inline() { @@ -276,7 +276,7 @@ process_inline() { process_message() { local num="$1" local TMP="${TMPDIR:-.}/$RANDOM$RANDOM-MESSAGE" - cat <<< "$UPDATE$'\\n'" >"$TMP" + cat <<< "$UPDATE" >"$TMP" # Message MESSAGE[0]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","text"' <"$TMP")" | sed 's#\\/#/#g')" MESSAGE[ID]="$(JsonGetValue '"result",'"${num}"',"message","message_id"' <"$TMP" )" diff --git a/modules/background.sh b/modules/background.sh index 08e5814..214edf4 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-3-ga3c0d31 +#### $$VERSION$$ v0.80-dev3-4-ge7d2eff # source from commands.sh if you want ro use interactive or background jobs @@ -48,12 +48,11 @@ start_back() { # $3 prefix start_proc() { [ "$2" = "" ] && return - kill_proc "$1" "$3" local fifo; fifo="${TMPDIR:-.}/$(procname "$1" "$3")" + kill_proc "$1" "$3" mkfifo "${fifo}" - nohup bash -c "{ set -f; exec 3>\"${fifo}\" & - cat \"${fifo}\" | $2 \"\" \"\" \"$fifo\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\" - }" &>>"${fifo}.log" & + nohup bash -c "{ tail -f \"${fifo}\" | $2 \"\" \"\" \"$fifo\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\" + rm \"${fifo}\"; [ -s \"${fifo}.log\" ] || rm -f \"${fifo}.log\"; }" &>>"${fifo}.log" & }