convert newlines to STRING \n when send to telegra

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-06-19 18:50:55 +02:00
parent 4d8c2054a6
commit e4d13fd92d

View File

@ -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-39-g35d5e05 #### $$VERSION$$ v0.98-dev-57-g4d8c205
# will be automatically sourced from bashbot # will be automatically sourced from bashbot
@ -191,8 +191,8 @@ send_message() {
[ -z "$2" ] && return [ -z "$2" ] && return
local text keyboard btext burl no_keyboard file lat long title address sent local text keyboard btext burl no_keyboard file lat long title address sent
text="$(sed <<< "${2}" 's/ mykeyboardend.*//;s/ *my[kfltab][a-z]\{2,13\}startshere.*//')$(sed <<< "${2}" -n '/mytextstartshere/ s/.*mytextstartshere//p')" text="$(sed <<< "${2}" 's/ mykeyboardend.*//;s/ *my[kfltab][a-z]\{2,13\}startshere.*//')$(sed <<< "${2}" -n '/mytextstartshere/ s/.*mytextstartshere//p')"
# shellcheck disable=SC2001 text="${text//*([[:space:]])mynewlinestartshere*([[:space:]])/ \\n}"
text="$(sed <<< "${text}" 's/ *mynewlinestartshere */\r\n/g')" text="${text//$'\n'/\\n}"
[ "$3" != "safe" ] && { [ "$3" != "safe" ] && {
no_keyboard="$(sed <<< "${2}" '/mykeyboardendshere/!d;s/.*mykeyboardendshere.*/mykeyboardendshere/')" no_keyboard="$(sed <<< "${2}" '/mykeyboardendshere/!d;s/.*mykeyboardendshere.*/mykeyboardendshere/')"
keyboard="$(sed <<< "${2}" '/mykeyboardstartshere /!d;s/.*mykeyboardstartshere *//;s/ *my[nkfltab][a-z]\{2,13\}startshere.*//;s/ *mykeyboardendshere.*//')" keyboard="$(sed <<< "${2}" '/mykeyboardstartshere /!d;s/.*mykeyboardstartshere *//;s/ *my[nkfltab][a-z]\{2,13\}startshere.*//;s/ *mykeyboardendshere.*//')"
@ -239,10 +239,10 @@ send_message() {
send_text() { send_text() {
case "$2" in case "$2" in
html_parse_mode*) 'html_parse_mode'*)
send_html_message "$1" "${2//html_parse_mode}" send_html_message "$1" "${2//html_parse_mode}"
;; ;;
markdown_parse_mode*) 'markdown_parse_mode'*)
send_markdown_message "$1" "${2//markdown_parse_mode}" send_markdown_message "$1" "${2//markdown_parse_mode}"
;; ;;
*) *)