fix formatted message longer 4095

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-08-02 10:03:35 +02:00
parent c4ab7ff4ee
commit afbdb1e7a5

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ 0.99-4-g15eb311
#### $$VERSION$$ 0.99-6-gc4ab7ff
# will be automatically sourced from bashbot
@ -46,7 +46,7 @@ send_normal_message() {
send_markdown_message() {
local text; text="$(JsonEscape "${2}")"
[ "${#text}" -le 4096 ] && log_error "Warning: markdown message longer than 4096 characters, message is rejected if formatting crosses 4096 border."
[ "${#text}" -ge 4096 ] && log_error "Warning: markdown message longer than 4096 characters, message is rejected if formatting crosses 4096 border."
until [ -z "${text}" ]; do
sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"markdown"' "${MSG_URL}"
text="${text:4096}"
@ -55,7 +55,7 @@ send_markdown_message() {
send_markdownv2_message() {
local text; text="$(JsonEscape "${2}")"
[ "${#text}" -le 4096 ] && log_error "Warning: markdown message longer than 4096 characters, message is rejected if formatting crosses 4096 border."
[ "${#text}" -ge 4096 ] && log_error "Warning: markdown message longer than 4096 characters, message is rejected if formatting crosses 4096 border."
# markdown v2 needs additional double escaping!
text="$(sed -E -e 's|([#{}()!.-])|\\\1|g' <<< "$text")"
until [ -z "${text}" ]; do
@ -66,7 +66,7 @@ send_markdownv2_message() {
send_html_message() {
local text; text="$(JsonEscape "${2}")"
[ "${#text}" -le 4096 ] && log_error "Warning: html message longer than 4096 characters, message is rejected if formatting crosses 4096 border."
[ "${#text}" -ge 4096 ] && log_error "Warning: html message longer than 4096 characters, message is rejected if formatting crosses 4096 border."
until [ -z "${text}" ]; do
sendJson "${1}" '"text":"'"${text:0:4096}"'","parse_mode":"html"' "${MSG_URL}"
text="${text:4096}"