mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $SendTelegram: truncate messages if too long
Telegram messages have a maximum length of 4096 characters. Truncate if too long, keep some spare characters for status messages.
This commit is contained in:
parent
697e32a306
commit
9ea6b159b6
1 changed files with 8 additions and 1 deletions
|
@ -744,6 +744,7 @@
|
|||
|
||||
:global CertificateAvailable;
|
||||
:global LogPrintExit;
|
||||
:global SymbolForNotification;
|
||||
:global UrlEncode;
|
||||
|
||||
:local ChatId $TelegramChatId;
|
||||
|
@ -755,7 +756,13 @@
|
|||
:return false;
|
||||
}
|
||||
|
||||
:local Text [ $UrlEncode ("[" . $Identity . "] " . $Subject . "\n\n" . $Message) ];
|
||||
:local Text ("[" . $Identity . "] " . $Subject . "\n\n" . $Message);
|
||||
:if ([ :len $Text ] > 3968) do={
|
||||
:set Text ([ :pick $Text 0 3840 ] . "...\n\n" . [ $SymbolForNotification "warning-sign" ] . \
|
||||
"The Telegram message was too long and has been truncated.");
|
||||
}
|
||||
:set Text [ $UrlEncode $Text ];
|
||||
|
||||
:do {
|
||||
:if ([ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2" ] = false) do={
|
||||
$LogPrintExit warning ("Downloading required certificate failed.") true;
|
||||
|
|
Loading…
Reference in a new issue