better callback processing

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-01-25 16:49:15 +01:00
parent 9584068ea3
commit cc4ac1a816
2 changed files with 10 additions and 10 deletions

View File

@ -15,7 +15,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v1.35-dev-6-gc90b565 #### $$VERSION$$ v1.35-dev-7-g9584068
# #
# bashbot locale defaults to c.UTF-8, adjust locale in mycommands.sh if needed # bashbot locale defaults to c.UTF-8, adjust locale in mycommands.sh if needed
@ -79,13 +79,13 @@ export FILE_REGEX="${BASHBOT_ETC}/.*"
if [ -z "$1" ] || [[ "$1" == *"debug"* ]];then if [ -z "$1" ] || [[ "$1" == *"debug"* ]];then
################# #################
# detect inline and callback query # detect inline and callback query
if [[ -n "${iQUERY[ID]}" && "${INLINE:-0}" != "0" ]]; then if [ -n "${iQUERY[ID]}" ]; then
# forward iinline query to optional dispatcher # forward inline query to optional dispatcher
_exec_if_function myinlines [ "${INLINE:-0}" != "0" ] || _exec_if_function myinlines
elif [[ -n "${iBUTTON[ID]}" && "${CALLBACK:-0}" != "0" ]]; then elif [ -n "${iBUTTON[ID]}" ]; then
# forward iinline query to optional dispatcher # forward inline query to optional dispatcher
_exec_if_function mycallbacks [ "${CALLBACK:-0}" != "0" ] || _exec_if_function mycallbacks
################# #################
# regular command # regular command

View File

@ -13,7 +13,7 @@
# License: WTFPLv2 http://www.wtfpl.net/txt/copying/ # License: WTFPLv2 http://www.wtfpl.net/txt/copying/
# Author: KayM (gnadelwartz), kay@rrr.de # Author: KayM (gnadelwartz), kay@rrr.de
# #
#### $$VERSION$$ v1.35-dev-6-gc90b565 #### $$VERSION$$ v1.35-dev-7-g9584068
####################################################### #######################################################
# shellcheck disable=SC1117 # shellcheck disable=SC1117
@ -181,8 +181,8 @@ else
mycallbacks() { mycallbacks() {
####################### #######################
# callbacks from buttons bot has attached to messages can processed here # callbacks from buttons attached to messages will be processed here
# we have no standard use case for processing callbacks, we log them based on user and chat # no standard use case for processing callbacks, let's log them for some users and chats
case "${USER[ID]}+${CHAT[ID]}" in case "${USER[ID]}+${CHAT[ID]}" in
'USERID1+'*) # do something for all callbacks from USER '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]}"\ printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBOTTON[USER_ID]}" "${iBOTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\