mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-09-28 08:19:02 +00:00
iBUTTON: fix comamnds and mycommands processing
This commit is contained in:
parent
08a05242f9
commit
b441384d4a
@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
|
|||||||
# 8 - curl/wget missing
|
# 8 - curl/wget missing
|
||||||
# 10 - not bash!
|
# 10 - not bash!
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.35-dev-13-gbc414ee
|
#### $$VERSION$$ v1.35-dev-14-g08a0524
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
# emmbeded system may claim bash but it is not
|
# emmbeded system may claim bash but it is not
|
||||||
@ -1134,9 +1134,9 @@ bot_init() {
|
|||||||
fi
|
fi
|
||||||
# check if mycommands exist
|
# check if mycommands exist
|
||||||
if [ ! -r "${BASHBOT_ETC:-.}/mycommands.sh" ]; then
|
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
|
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
|
# offer to copy config also
|
||||||
if [ ! -r "${BASHBOT_ETC:-.}/mycommands.conf" ]; then
|
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"
|
printf "Mycommands config file not found, copy ${GREY}mycommands.conf.dist${NC} to mycommands.conf? (y/N) N\b"
|
||||||
|
@ -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-7-g9584068
|
#### $$VERSION$$ v1.35-dev-14-g08a0524
|
||||||
#
|
#
|
||||||
|
|
||||||
# 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
|
||||||
@ -81,11 +81,11 @@ if [ -z "$1" ] || [[ "$1" == *"debug"* ]];then
|
|||||||
# detect inline and callback query
|
# detect inline and callback query
|
||||||
if [ -n "${iQUERY[ID]}" ]; then
|
if [ -n "${iQUERY[ID]}" ]; then
|
||||||
# forward inline query to optional dispatcher
|
# 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
|
elif [ -n "${iBUTTON[ID]}" ]; then
|
||||||
# forward inline query to optional dispatcher
|
# forward inline query to optional dispatcher
|
||||||
[ "${CALLBACK:-0}" != "0" ] || _exec_if_function mycallbacks
|
[ "${CALLBACK:-0}" != "0" ] && _exec_if_function mycallbacks
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# regular command
|
# regular command
|
||||||
|
@ -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-7-g9584068
|
#### $$VERSION$$ v1.35-dev-14-g08a0524
|
||||||
#######################################################
|
#######################################################
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
|
|
||||||
@ -183,22 +183,22 @@ else
|
|||||||
#######################
|
#######################
|
||||||
# callbacks from buttons attached to messages will be processed here
|
# 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
|
# 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
|
'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)" "${iBUTTON[USER_ID]}" "${iBUTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\
|
||||||
>>"${DATADIR}/${iBOTTON[USER_ID]}.log"
|
>>"${DATADIR}/${iBUTTON[USER_ID]}.log"
|
||||||
answer_callback_query "${iBUTTON[ID]}" "Request has been logged in your user log..."
|
answer_callback_query "${iBUTTON[ID]}" "Request has been logged in your user log..."
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
*'+CHATID1') # do something for all callbacks from CHAT
|
*'+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]}"\
|
printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBUTTON[USER_ID]}" "${iBUTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\
|
||||||
>>"${DATADIR}/${iBOTTON[CHAT_ID]}.log"
|
>>"${DATADIR}/${iBUTTON[CHAT_ID]}.log"
|
||||||
answer_callback_query "${iBUTTON[ID]}" "Request has been logged in chat log..."
|
answer_callback_query "${iBUTTON[ID]}" "Request has been logged in chat log..."
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
'USERID2+CHATID2') # do something only for callbacks form USER in CHAT
|
'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]}"\
|
printf "%s: U=%s C=%s D=%s\n" "$(date)" "${iBUTTON[USER_ID]}" "${iBUTTON[CHAT_ID]}" "${iBUTTON[DATA]}"\
|
||||||
>>"${DATADIR}/${iBOTTON[USER_ID]}-${iBOTTON[CHAT_ID]}.log"
|
>>"${DATADIR}/${iBUTTON[USER_ID]}-${iBUTTON[CHAT_ID]}.log"
|
||||||
answer_callback_query "${iBUTTON[ID]}" "Request has been logged in user-chat log..."
|
answer_callback_query "${iBUTTON[ID]}" "Request has been logged in user-chat log..."
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
@ -209,8 +209,6 @@ else
|
|||||||
answer_callback_query "${iBUTTON[ID]}" ""
|
answer_callback_query "${iBUTTON[ID]}" ""
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myinlines() {
|
myinlines() {
|
||||||
|
Loading…
Reference in New Issue
Block a user