mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
mod/notification-*: support extra text (or emojis 🚀) in notification tags
This commit is contained in:
parent
c8e22f33c2
commit
47a657d25c
6 changed files with 16 additions and 7 deletions
|
@ -9,6 +9,9 @@
|
||||||
# Set this to 'true' to disable news and change notifications.
|
# Set this to 'true' to disable news and change notifications.
|
||||||
:global NoNewsAndChangesNotification false;
|
:global NoNewsAndChangesNotification false;
|
||||||
|
|
||||||
|
# Add extra text (or emojis) in notification tags.
|
||||||
|
:global IdentityExtra "";
|
||||||
|
|
||||||
# This is used for DNS and backup file.
|
# This is used for DNS and backup file.
|
||||||
:global Domain "example.com";
|
:global Domain "example.com";
|
||||||
:global HostNameInZone true;
|
:global HostNameInZone true;
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
84="Support for e-mail notifications moved to a module. It is installed automatically if required.";
|
84="Support for e-mail notifications moved to a module. It is installed automatically if required.";
|
||||||
85="Dropped 'netwatch-syslog', filtering in firewall is advised.";
|
85="Dropped 'netwatch-syslog', filtering in firewall is advised.";
|
||||||
86="Added support for hooks in 'sms-forward'. This now provides similar functionality to 'sms-action', but is more flexible.";
|
86="Added support for hooks in 'sms-forward'. This now provides similar functionality to 'sms-action', but is more flexible.";
|
||||||
|
87="Added support for extra text (or emojis \F0\9F\9A\80) in notification tags.";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Migration steps to be applied on script updates
|
# Migration steps to be applied on script updates
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
:local 0 "global-functions";
|
:local 0 "global-functions";
|
||||||
|
|
||||||
# expected configuration version
|
# expected configuration version
|
||||||
:global ExpectedConfigVersion 86;
|
:global ExpectedConfigVersion 87;
|
||||||
|
|
||||||
# global variables not to be changed by user
|
# global variables not to be changed by user
|
||||||
:global GlobalFunctionsReady false;
|
:global GlobalFunctionsReady false;
|
||||||
|
|
|
@ -107,10 +107,11 @@
|
||||||
# generate the e-mail subject
|
# generate the e-mail subject
|
||||||
:set NotificationEMailSubject do={
|
:set NotificationEMailSubject do={
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
:global IdentityExtra;
|
||||||
|
|
||||||
:global QuotedPrintable;
|
:global QuotedPrintable;
|
||||||
|
|
||||||
:return [ $QuotedPrintable ("[" . $Identity . "] " . $1) ];
|
:return [ $QuotedPrintable ("[" . $IdentityExtra . $Identity . "] " . $1) ];
|
||||||
}
|
}
|
||||||
|
|
||||||
# send notification via e-mail - expects one array argument
|
# send notification via e-mail - expects one array argument
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
:local Notification $1;
|
:local Notification $1;
|
||||||
|
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
:global IdentityExtra;
|
||||||
:global MatrixAccessToken;
|
:global MatrixAccessToken;
|
||||||
:global MatrixAccessTokenOverride;
|
:global MatrixAccessTokenOverride;
|
||||||
:global MatrixHomeServer;
|
:global MatrixHomeServer;
|
||||||
|
@ -106,10 +107,11 @@
|
||||||
:return false;
|
:return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Plain [ $PrepareText ("## [" . $Identity . "] " . ($Notification->"subject") . "\n```\n" . \
|
:local Plain [ $PrepareText ("## [" . $IdentityExtra . $Identity . "] " . \
|
||||||
($Notification->"message") . "\n```") "plain" ];
|
($Notification->"subject") . "\n```\n" . ($Notification->"message") . "\n```") "plain" ];
|
||||||
:local Formatted ("<h2>" . [ $PrepareText ("[" . $Identity . "] " . ($Notification->"subject")) "format" ] . "</h2>" . \
|
:local Formatted ("<h2>" . [ $PrepareText ("[" . $IdentityExtra . $Identity . "] " . \
|
||||||
"<pre><code>" . [ $PrepareText ($Notification->"message") "format" ] . "</code></pre>");
|
($Notification->"subject")) "format" ] . "</h2>" . "<pre><code>" . \
|
||||||
|
[ $PrepareText ($Notification->"message") "format" ] . "</code></pre>");
|
||||||
:if ([ :len ($Notification->"link") ] > 0) do={
|
:if ([ :len ($Notification->"link") ] > 0) do={
|
||||||
:set Plain ($Plain . "\\n" . [ $SymbolForNotification "link" ] . \
|
:set Plain ($Plain . "\\n" . [ $SymbolForNotification "link" ] . \
|
||||||
[ $PrepareText ("[" . $Notification->"link" . "](" . $Notification->"link" . ")") "plain" ]);
|
[ $PrepareText ("[" . $Notification->"link" . "](" . $Notification->"link" . ")") "plain" ]);
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
:local Notification $1;
|
:local Notification $1;
|
||||||
|
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
:global IdentityExtra;
|
||||||
:global TelegramChatId;
|
:global TelegramChatId;
|
||||||
:global TelegramChatIdOverride;
|
:global TelegramChatIdOverride;
|
||||||
:global TelegramFixedWidthFont;
|
:global TelegramFixedWidthFont;
|
||||||
|
@ -105,7 +106,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Truncated false;
|
:local Truncated false;
|
||||||
:local Text ("*__" . [ $EscapeMD ("[" . $Identity . "] " . ($Notification->"subject")) "plain" ] . "__*\n\n");
|
:local Text ("*__" . [ $EscapeMD ("[" . $IdentityExtra . $Identity . "] " . \
|
||||||
|
($Notification->"subject")) "plain" ] . "__*\n\n");
|
||||||
: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") ];
|
||||||
|
|
Loading…
Reference in a new issue