fixed issue with whitespace in inline keyboard text field

This commit is contained in:
celso 2023-03-26 09:00:42 -03:00
parent 6483a070b0
commit dc0cf65d2c
1 changed files with 3 additions and 3 deletions

View File

@ -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"