mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-21 23:25:08 +00:00
modules: button url not starting with hhttp is sent as data
This commit is contained in:
parent
9023b21791
commit
1fe22a0345
17
bashbot.sh
17
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.32-dev-13-gf995eee
|
||||
#### $$VERSION$$ v1.35-dev-1-g9023b21
|
||||
##################################################################
|
||||
|
||||
# emmbeded system may claim bash but it is not
|
||||
@ -689,8 +689,8 @@ process_client() {
|
||||
"${iQUERY[USERNAME]:0:20} (${iQUERY[USER_ID]})" "${iQUERY[0]}" >>"${UPDATELOG}"
|
||||
elif [ -n "${iBUTTON[ID]}" ]; then
|
||||
process_inline_button "${num}" "${debug}"
|
||||
printf "%(%c)T: Inline Button update received FROM=%s iBUTTON=%s\n" -1\
|
||||
"${iBUTTON[USERNAME]:0:20} (${iBUTTON[USER_ID]})" "${iBUTTON[0]}" >>"${UPDATELOG}"
|
||||
printf "%(%c)T: Inline Button update received FROM=%s CHAT=%s ID=%s DATA:%s \n" -1\
|
||||
"${iBUTTON[USERNAME]:0:20} (${iBUTTON[USER_ID]})" "${iBUTTON[CHAT_ID]}" "{iBUTTON[ID]" "{iBUTTON[DATA]" >>"${UPDATELOG}"
|
||||
else
|
||||
if grep -qs -e '\["result",'"${num}"',"edited_message"' <<<"${UPDATE}"; then
|
||||
# edited message
|
||||
@ -866,17 +866,20 @@ process_inline_query() {
|
||||
return 0
|
||||
}
|
||||
process_inline_button() {
|
||||
# debugging for impelemetation
|
||||
log_message "${res}"
|
||||
set -x
|
||||
local num="$1"
|
||||
iBUTTON[0]="$(JsonDecode "${UPD["result,${num},inline_callback,query"]}")"
|
||||
iBUTTON[DATA]="${UPD["result,${num},inline_callback,data"]}"
|
||||
iBUTTON[CHAT_ID]="${UPD["result,${num},inline_callback,chat_instance"]}"
|
||||
iBUTTON[MESSAGE_ID]="${UPD["result,${num},inline_callback,inline_message_id"]}"
|
||||
iBUTTON[MESSAGE_TEXT]="${UPD["result,${num},inline_callback,message,text"]}"
|
||||
# XXX should we give back pressed button or all buttons?
|
||||
iBUTTON[MESSAGE_BUTTONS]="${UPD["result,${num},inline_callback,message,reply_markup"]}"
|
||||
iBUTTON[MEESSAGE]="$(JsonDecode "${UPD["result,${num},inline_callback,message,text"]}")"
|
||||
# XXX should we give back pressed button, all buttons or nothing?
|
||||
iBUTTON[USER_ID]="${UPD["result,${num},inline_callback,from,id"]}"
|
||||
iBUTTON[FIRST_NAME]="$(JsonDecode "${UPD["result,${num},inline_callback,from,first_name"]}")"
|
||||
iBUTTON[LAST_NAME]="$(JsonDecode "${UPD["result,${num},inline_callback,from,last_name"]}")"
|
||||
iBUTTON[USERNAME]="$(JsonDecode "${UPD["result,${num},inline_callback,from,username"]}")"
|
||||
set +x
|
||||
# always true
|
||||
return 0
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#
|
||||
# Description: run all tests, exit after failed test
|
||||
#
|
||||
#### $$VERSION$$ v1.30-0-g3266427
|
||||
#### $$VERSION$$ v1.35-dev-0-gd9b3342
|
||||
#############################################################
|
||||
|
||||
#shellcheck disable=SC1090
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
# shellcheck disable=SC1117
|
||||
#### $$VERSION$$ v1.32-dev-1-g662c6f4
|
||||
#### $$VERSION$$ v1.35-dev-1-g9023b21
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
@ -159,13 +159,16 @@ send_button() {
|
||||
|
||||
# helper function to create json for a button row
|
||||
# buttons will specified as "text|url" ... "text|url" empty arg starts new row
|
||||
# url not starting with http:// or https:// will be send as callback_data
|
||||
_button_row() {
|
||||
[ -z "$1" ] && return 1
|
||||
local arg json sep
|
||||
local arg type json sep
|
||||
for arg in "$@"
|
||||
do
|
||||
[ -z "${arg}" ] && sep="],[" && continue
|
||||
json+="${sep}"'{"text":"'"$(JsonEscape "${arg%|*}")"'", "url":"'"${arg##*|}"'"}'
|
||||
type="callback_data"
|
||||
[[ "${arg##*|}" =~ ^https*:// ]] && type="url"
|
||||
json+="${sep}"'{"text":"'"$(JsonEscape "${arg%|*}")"'", "'"${type}"'":"'"${arg##*|}"'"}'
|
||||
sep=","
|
||||
done
|
||||
printf "[%s]" "${json}"
|
||||
|
Loading…
Reference in New Issue
Block a user