aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--global-functions.d/notification-telegram5
1 files changed, 3 insertions, 2 deletions
diff --git a/global-functions.d/notification-telegram b/global-functions.d/notification-telegram
index d8fe448..faf02d7 100644
--- a/global-functions.d/notification-telegram
+++ b/global-functions.d/notification-telegram
@@ -103,7 +103,8 @@
:local LenSubject [ :len $Text ];
:local LenMessage [ :len ($Notification->"message") ];
:local LenLink [ :len ($Notification->"link") ];
- :if ($LenSubject + $LenMessage + $LenLink > 3968) do={
+ :local LenSum ($LenSubject + $LenMessage + $LenLink);
+ :if ($LenSum > 3968) do={
:set Text ($Text . [ $EscapeMD ([ :pick ($Notification->"message") 0 (3840 - $LenSubject - $LenLink) ] . "...") "body" ]);
:set Truncated true;
} else={
@@ -115,7 +116,7 @@
:if ($Truncated = true) do={
:set Text ($Text . "\n" . [ $SymbolForNotification "scissors" ] . \
[ $EscapeMD ("The Telegram message was too long and has been truncated, cut off " . \
- (($LenText - [ :len $Text ]) * 100 / $LenText) . "%!") "plain" ]);
+ (($LenSum - [ :len $Text ]) * 100 / $LenSum) . "%!") "plain" ]);
}
:set Text [ $UrlEncode $Text ];
:local ParseMode [ $IfThenElse ($TelegramFixedWidthFont = true) "MarkdownV2" "" ];