mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-01-15 18:36:48 +00:00
send_messages split messages >4096 at last newline
This commit is contained in:
parent
e4d13fd92d
commit
21f29a496f
@ -5,7 +5,7 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.98-dev-57-g4d8c205
|
#### $$VERSION$$ v0.98-dev-58-ge4d13fd
|
||||||
|
|
||||||
# will be automatically sourced from bashbot
|
# will be automatically sourced from bashbot
|
||||||
|
|
||||||
@ -27,10 +27,19 @@ ACTION_URL=$URL'/sendChatAction'
|
|||||||
FORWARD_URL=$URL'/forwardMessage'
|
FORWARD_URL=$URL'/forwardMessage'
|
||||||
|
|
||||||
send_normal_message() {
|
send_normal_message() {
|
||||||
local text; text="$(JsonEscape "${2}")"
|
local len text; text="$(JsonEscape "${2}")"
|
||||||
|
text="${text//$'\n'/\\n}"
|
||||||
until [ -z "${text}" ]; do
|
until [ -z "${text}" ]; do
|
||||||
sendJson "${1}" '"text":"'"${text:0:4096}"'"' "${MSG_URL}"
|
if [ "${#text}" -le 4096 ]; then\
|
||||||
text="${text:4096}"
|
sendJson "${1}" '"text":"'"${text}"'"' "${MSG_URL}"
|
||||||
|
unset text
|
||||||
|
else
|
||||||
|
len=4095
|
||||||
|
[ "${text:4095:2}" != "\n" ] &&\
|
||||||
|
len="${text:0:4096}" && len="${len%\\n*}" && len="${#len}"
|
||||||
|
sendJson "${1}" '"text":"'"${text:0:${len}}"'"' "${MSG_URL}"
|
||||||
|
text="${text:$((len+2))}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user