prevented empty messages from ending up in updates or sentmsgs

This commit is contained in:
celso 2023-03-27 00:34:40 -03:00
parent 9c242827a5
commit 703351e14a
1 changed files with 7 additions and 7 deletions

View File

@ -159,8 +159,8 @@ sendmsg() {
|| sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" \ || sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" \
-d "text=${2}" \ -d "text=${2}" \
-d "reply_markup=${3}")" -d "reply_markup=${3}")"
[ ! -z "${sentmsg}" ] && sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g'\ sentmsg="$(sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g' <<< "${sentmsg}")"
<<< "${sentmsg}" >> "${bot_tmpdir}sentmsgs.txt" [ ! -z "${sentmsg}" ] && printf "%s\n" "${sentmsg}" >> "${bot_tmpdir}sentmsgs.txt"
} }
# $1 is target chat_id # $1 is target chat_id
@ -174,8 +174,8 @@ replymsg() {
-d "text=${3}")" || -d "text=${3}")" ||
sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" -d "reply_to_message_id=${2}"\ sentmsg="$(curl -sX GET "${api_url}sendMessage" -d "chat_id=${1}" -d "reply_to_message_id=${2}"\
-d "text=${3}" -d "reply_markup=${4}")" -d "text=${3}" -d "reply_markup=${4}")"
[ ! -z "${sentmsg}" ] && sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g'\ sentmsg="$(sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g' <<< "${sentmsg}")"
<<< "${sentmsg}" >> "${bot_tmpdir}sentmsgs.txt" [ ! -z "${sentmsg}" ] && printf "%s\n" "${sentmsg}" >> "${bot_tmpdir}sentmsgs.txt"
} }
# $1 is target chat_id # $1 is target chat_id
@ -184,11 +184,11 @@ replymsg() {
# $4 is inline keyboard (optional) # $4 is inline keyboard (optional)
editmsg() { editmsg() {
local editmsg local editmsg
[ -z "${3}" ] && editmsg="$(curl -sX GET "${api_url}editMessageText" -d "chat_id=${1}" -d "message_id=${2}" \ [ -z "${4}" ] && editmsg="$(curl -sX GET "${api_url}editMessageText" -d "chat_id=${1}" -d "message_id=${2}" \
-d "text=${3}")" || editmsg="$(curl -sX GET "${api_url}editMessageText" -d "chat_id=${1}" -d "message_id=${2}" \ -d "text=${3}")" || editmsg="$(curl -sX GET "${api_url}editMessageText" -d "chat_id=${1}" -d "message_id=${2}" \
-d "text=${3}" -d "reply_markup=${4}")" -d "text=${3}" -d "reply_markup=${4}")"
[ ! -z "${editmsg}" ] && sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g'\ editmsg="$(sed 's/^{"ok":false.*\|^{"ok":true,"result":{\|}$//g' <<< "${editmsg}")"
<<< "${editmsg}" >> "${bot_tmpdir}sentmsgs.txt" [ ! -z "${editmsg}" ] && printf "%s\n" "${editmsg}" >> "${bot_tmpdir}sentmsgs.txt"
} }
# $1 is target chat_id # $1 is target chat_id