From dc0cf65d2c3e5efd8e5d117118e41e9768116d41 Mon Sep 17 00:00:00 2001 From: celso Date: Sun, 26 Mar 2023 09:00:42 -0300 Subject: [PATCH] fixed issue with whitespace in inline keyboard text field --- bashbot-lib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bashbot-lib.sh b/bashbot-lib.sh index 098cf38..65ff6cd 100755 --- a/bashbot-lib.sh +++ b/bashbot-lib.sh @@ -114,7 +114,7 @@ mkinline_kbd(){ local -n rows="${1}" local -n text="${2}" local -n data="${3}" - local kbd="reply_markup={\"inline_keyboard\":[]}" + local kbd="{\"inline_keyboard\":[]}" local unit="\"text\":\"\",\"callback_data\":\"\"" local rowformat="[]" local colformat="{}" @@ -143,7 +143,7 @@ mkinline_kbd(){ for i in "${data[@]}"; do kbd="$(sed "s/\"callback_data\":\"\"/\"callback_data\":\"${i}\"/" <<< "${kbd}")" done - sed "s/^\|$/\"/g" <<< "${kbd}" + sed "s/ /+/g;:a;N;$!ba;s/\n/%0A/g" <<< "${kbd}" } # $1 is target chat_id @@ -154,7 +154,7 @@ sendmsg() { -d "text=${2}")" \ || sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" \ -d "text=${2}" \ - -d "${3}")" + -d "reply_markup=${3}")" [ ! -z "${sentmsg}" ] && printf "%s\n" "${sentmsg}"\ | sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g'\ >> "${bot_tmpdir}sentmsgs.txt"