mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-23 20:34:27 +02:00
global-functions.d/notification-telegram: fix calculation on cut off
This commit is contained in:
parent
72d50aa13f
commit
4ebe2628b0
1 changed files with 3 additions and 2 deletions
|
@ -103,7 +103,8 @@
|
||||||
:local LenSubject [ :len $Text ];
|
:local LenSubject [ :len $Text ];
|
||||||
:local LenMessage [ :len ($Notification->"message") ];
|
:local LenMessage [ :len ($Notification->"message") ];
|
||||||
:local LenLink [ :len ($Notification->"link") ];
|
: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 Text ($Text . [ $EscapeMD ([ :pick ($Notification->"message") 0 (3840 - $LenSubject - $LenLink) ] . "...") "body" ]);
|
||||||
:set Truncated true;
|
:set Truncated true;
|
||||||
} else={
|
} else={
|
||||||
|
@ -115,7 +116,7 @@
|
||||||
:if ($Truncated = true) do={
|
:if ($Truncated = true) do={
|
||||||
:set Text ($Text . "\n" . [ $SymbolForNotification "scissors" ] . \
|
:set Text ($Text . "\n" . [ $SymbolForNotification "scissors" ] . \
|
||||||
[ $EscapeMD ("The Telegram message was too long and has been truncated, cut off " . \
|
[ $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 ];
|
:set Text [ $UrlEncode $Text ];
|
||||||
:local ParseMode [ $IfThenElse ($TelegramFixedWidthFont = true) "MarkdownV2" "" ];
|
:local ParseMode [ $IfThenElse ($TelegramFixedWidthFont = true) "MarkdownV2" "" ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue