global-functions: $SendTelegram: give amount of truncated text

This commit is contained in:
Christian Hesse 2020-11-30 22:37:26 +01:00
parent e2e831dbf9
commit cef0e8c079

View file

@ -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" "" ];