diff options
author | Christian Hesse <mail@eworm.de> | 2021-09-28 16:26:26 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2021-09-28 16:26:26 +0200 |
commit | 4ebe2628b0819000fe359afbb7d17a883148eabd (patch) | |
tree | b6edfc264cd47a10d2b2e0f21075bef0753a79b1 | |
parent | 72d50aa13ffb4b80859b6ef191ddaec7541a21ad (diff) |
global-functions.d/notification-telegram: fix calculation on cut off
-rw-r--r-- | global-functions.d/notification-telegram | 5 |
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" "" ]; |