From b441384d4a664f5a8a476afeab1aca168e91d783 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Tue, 26 Jan 2021 14:34:25 +0100 Subject: [PATCH] iBUTTON: fix comamnds and mycommands processing --- bashbot.sh | 6 +++--- commands.sh | 6 +++--- mycommands.sh | 18 ++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index 6842e4a..215980d 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.35-dev-13-gbc414ee +#### $$VERSION$$ v1.35-dev-14-g08a0524 ################################################################## # emmbeded system may claim bash but it is not @@ -1134,9 +1134,9 @@ bot_init() { fi # check if mycommands exist if [ ! -r "${BASHBOT_ETC:-.}/mycommands.sh" ]; then - printf "Mycommands.sh not found, copy ${GREY}mycommands.sh.dist${NC} to mycommands.sh? (y/N) N\b" + printf "Mycommands.sh not found, copy ${GREY}mycommands.sh.clean${NC} to mycommands.sh? (y/N) N\b" read -r ANSWER - [[ "${ANSWER}" =~ ^[Yy] ]] && cp -f "${BASHBOT_ETC:-.}/mycommands.sh.dist" "${BASHBOT_ETC:-.}/mycommands.sh" + [[ "${ANSWER}" =~ ^[Yy] ]] && cp -f "${BASHBOT_ETC:-.}/mycommands.sh.clean" "${BASHBOT_ETC:-.}/mycommands.sh" # offer to copy config also if [ ! -r "${BASHBOT_ETC:-.}/mycommands.conf" ]; then printf "Mycommands config file not found, copy ${GREY}mycommands.conf.dist${NC} to mycommands.conf? (y/N) N\b" diff --git a/commands.sh b/commands.sh index 3f940fb..f2db8a5 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$$ v1.35-dev-7-g9584068 +#### $$VERSION$$ v1.35-dev-14-g08a0524 # # bashbot locale defaults to c.UTF-8, adjust locale in mycommands.sh if needed @@ -81,11 +81,11 @@ if [ -z "$1" ] || [[ "$1" == *"debug"* ]];then # detect inline and callback query if [ -n "${iQUERY[ID]}" ]; then # forward inline query to optional dispatcher - [ "${INLINE:-0}" != "0" ] || _exec_if_function myinlines + [ "${INLINE:-0}" != "0" ] && _exec_if_function myinlines elif [ -n "${iBUTTON[ID]}" ]; then # forward inline query to optional dispatcher - [ "${CALLBACK:-0}" != "0" ] || _exec_if_function mycallbacks + [ "${CALLBACK:-0}" != "0" ] && _exec_if_function mycallbacks ################# # regular command diff --git a/mycommands.sh b/mycommands.sh index eb2fafd..8538172 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -13,7 +13,7 @@ # License: WTFPLv2 http://www.wtfpl.net/txt/copying/ # Author: KayM (gnadelwartz), kay@rrr.de # -#### $$VERSION$$ v1.35-dev-7-g9584068 +#### $$VERSION$$ v1.35-dev-14-g08a0524 ####################################################### # shellcheck disable=SC1117 @@ -183,22 +183,22 @@ else ####################### # callbacks from buttons attached to messages will be processed here # no standard use case for processing callbacks, let's log them for some users and chats - case "${USER[ID]}+${CHAT[ID]}" in + case "${iBUTTON[USER_ID]}+${iBUTTON[CHAT_ID]}" in 'USERID1+'*) # do something for all callbacks from USER - printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBOTTON[USER_ID]}" "${iBOTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\ - >>"${DATADIR}/${iBOTTON[USER_ID]}.log" + printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBUTTON[USER_ID]}" "${iBUTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\ + >>"${DATADIR}/${iBUTTON[USER_ID]}.log" answer_callback_query "${iBUTTON[ID]}" "Request has been logged in your user log..." return ;; *'+CHATID1') # do something for all callbacks from CHAT - printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBOTTON[USER_ID]}" "${iBOTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\ - >>"${DATADIR}/${iBOTTON[CHAT_ID]}.log" + printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBUTTON[USER_ID]}" "${iBUTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\ + >>"${DATADIR}/${iBUTTON[CHAT_ID]}.log" answer_callback_query "${iBUTTON[ID]}" "Request has been logged in chat log..." return ;; 'USERID2+CHATID2') # do something only for callbacks form USER in CHAT - printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBOTTON[USER_ID]}" "${iBOTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\ - >>"${DATADIR}/${iBOTTON[USER_ID]}-${iBOTTON[CHAT_ID]}.log" + printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBUTTON[USER_ID]}" "${iBUTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\ + >>"${DATADIR}/${iBUTTON[USER_ID]}-${iBUTTON[CHAT_ID]}.log" answer_callback_query "${iBUTTON[ID]}" "Request has been logged in user-chat log..." return ;; @@ -209,8 +209,6 @@ else answer_callback_query "${iBUTTON[ID]}" "" ;; esac - - } myinlines() {