mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-29 18:53:52 +00:00
remove non UTF-8 characters on get and send strings
This commit is contained in:
parent
b84ab57f6f
commit
e3ba1a053c
@ -239,7 +239,7 @@ if [ "${BASHBOT_WGET}" = "" ] && _exists curl ; then
|
|||||||
local chat="";
|
local chat="";
|
||||||
[ "${1}" != "" ] && chat='"chat_id":'"${1}"','
|
[ "${1}" != "" ] && chat='"chat_id":'"${1}"','
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
res="$(curl -s -k ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" -d '{'"${chat} $2"'}' -X POST "${3}" \
|
res="$(curl -s ${BASHBOT_CURL_ARGS} -m "${TIMEOUT}" -d '{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' -X POST "${3}" \
|
||||||
-H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n )"
|
-H "Content-Type: application/json" | "${JSONSHFILE}" -s -b -n )"
|
||||||
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
|
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
|
||||||
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")"
|
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")"
|
||||||
@ -269,7 +269,7 @@ else
|
|||||||
local chat="";
|
local chat="";
|
||||||
[ "${1}" != "" ] && chat='"chat_id":'"${1}"','
|
[ "${1}" != "" ] && chat='"chat_id":'"${1}"','
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
res="$(wget --no-check-certificate -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - --post-data='{'"${chat} $2"'}' \
|
res="$(wget -t 2 -T "${TIMEOUT}" ${BASHBOT_WGET_ARGS} -qO - --post-data='{'"${chat} $(iconv -f utf-8 -t utf-8 -c <<<$2)"'}' \
|
||||||
--header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -s -b -n )"
|
--header='Content-Type:application/json' "${3}" | "${JSONSHFILE}" -s -b -n )"
|
||||||
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
|
BOTSENT[OK]="$(JsonGetLine '"ok"' <<< "$res")"
|
||||||
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")"
|
BOTSENT[ID]="$(JsonGetValue '"result","message_id"' <<< "$res")"
|
||||||
@ -628,7 +628,7 @@ start_bot() {
|
|||||||
trap "kill -9 $!; exit" EXIT INT HUP TERM QUIT
|
trap "kill -9 $!; exit" EXIT INT HUP TERM QUIT
|
||||||
fi
|
fi
|
||||||
while true; do
|
while true; do
|
||||||
UPDATE="$(getJson "$UPD_URL$OFFSET" | "${JSONSHFILE}" -s -b -n)"
|
UPDATE="$(getJson "$UPD_URL$OFFSET" | "${JSONSHFILE}" -s -b -n | iconv -f utf-8 -t utf-8 -c)"
|
||||||
|
|
||||||
# Offset
|
# Offset
|
||||||
OFFSET="$(grep <<< "${UPDATE}" '\["result",[0-9]*,"update_id"\]' | tail -1 | cut -f 2)"
|
OFFSET="$(grep <<< "${UPDATE}" '\["result",[0-9]*,"update_id"\]' | tail -1 | cut -f 2)"
|
||||||
|
Loading…
Reference in New Issue
Block a user