From cef0e8c0791298e00cf8c4e359fdb3628d8c4ff5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 30 Nov 2020 22:37:26 +0100 Subject: global-functions: $SendTelegram: give amount of truncated text --- global-functions | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/global-functions b/global-functions index 5e4ef8b..5e643d9 100644 --- a/global-functions +++ b/global-functions @@ -816,7 +816,8 @@ :local Truncated false; :local LenLink [ :len $Link ]; :local Text ("[" . $Identity . "] " . $Subject . "\n\n" . $Message); - :if ([ :len $Text ] > (3968 - $LenLink)) do={ + :local LenText [ :len $Text ]; + :if ($LenText > (3968 - $LenLink)) do={ :set Text [ $EscapeMD ([ :pick $Text 0 (3840 - $LenLink) ] . "...") "body" ]; :set Truncated true; } else={ @@ -827,7 +828,8 @@ } :if ($Truncated = true) do={ :set Text ($Text . "\n" . [ $SymbolForNotification "scissors" ] . \ - [ $EscapeMD "The Telegram message was too long and has been truncated!" "hint" ]); + [ $EscapeMD ("The Telegram message was too long and has been truncated, cut off " . \ + (($LenText - [ :len $Text ]) * 100 / $LenText) . "%!") "hint" ]); } :set Text [ $UrlEncode $Text ]; :local ParseMode [ $IfThenElse ($TelegramFixedWidthFont = true) "MarkdownV2" "" ]; -- cgit v1.2.3-54-g00ecf