aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-11-30 22:37:26 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-12-01 09:11:37 +0100
commitcef0e8c0791298e00cf8c4e359fdb3628d8c4ff5 (patch)
tree7d143f88b67b6b7226cdd6c9980bac74036b0bdd /global-functions
parente2e831dbf94aed1fd628fbef6758449bbf4bca6b (diff)
global-functions: $SendTelegram: give amount of truncated text
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions6
1 files 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" "" ];