mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: add identity tag in $SendNotification
... and send subject in telegram message.
This commit is contained in:
parent
c4f8c1ad52
commit
6e4d715937
|
@ -36,7 +36,7 @@
|
|||
:local fingerprint [ / certificate get $cert fingerprint ];
|
||||
:local invalidbefore [ / certificate get $cert invalid-before ];
|
||||
:local invalidafter [ / certificate get $cert invalid-after ];
|
||||
$SendNotification ("[" . $identity . "] Certificate warning!") \
|
||||
$SendNotification ("Certificate warning!") \
|
||||
("A certificate on " . $identity . " is about to expire.\n\n" . \
|
||||
"Certificate Name: " . $certname . "\n" . \
|
||||
"Common Name: " . $commonname . "\n" . \
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"&latest=" . $latestversion) output=user as-value ];
|
||||
:if ($result->"status" = "finished" && $result->"data" = $latestversion) do={
|
||||
:log info ("Version " . $latestversion . " is assumed safe, updating...");
|
||||
$SendNotification ("[" . $identity . "] RouterOS update notification") \
|
||||
$SendNotification ("RouterOS update notification") \
|
||||
("Version " . $latestversion . " is assumed safe for " . $channel . \
|
||||
", updating on " . $identity . "...");
|
||||
/ system package update install;
|
||||
|
@ -45,7 +45,7 @@
|
|||
$latestversion . ".");
|
||||
}
|
||||
|
||||
$SendNotification ("[" . $identity . "] RouterOS update notification") \
|
||||
$SendNotification ("RouterOS update notification") \
|
||||
("There is a RouterOS update available\n\n" . \
|
||||
"Routerboard: " . $model . "\n" . \
|
||||
"Serial number: " . $serialnumber . "\n" . \
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
$datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||
/ log info $message;
|
||||
/ caps-man access-list add place-before=$"place-before" comment=$message mac-address=$mac disabled=yes;
|
||||
$SendNotification ("[" . $identity . "] " . $mac . " connected to " . $ssid) \
|
||||
$SendNotification ($mac . " connected to " . $ssid) \
|
||||
("A device with unknown MAC address connected to " . $ssid . " on " . $identity . ".\n\n" . \
|
||||
"Controller: " . $identity . "\n" . \
|
||||
"Interface: " . $interface . "\n" . \
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
$datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||
/ log info $message;
|
||||
/ interface wireless access-list add place-before=$"place-before" comment=$message mac-address=$mac disabled=yes;
|
||||
$SendNotification ("[" . $identity . "] " . $mac . " connected to " . $ssid) \
|
||||
$SendNotification ($mac . " connected to " . $ssid) \
|
||||
("A device with unknown MAC address connected to " . $ssid . " on " . $identity . ".\n\n" . \
|
||||
"Controller: " . $identity . "\n" . \
|
||||
"Interface: " . $interface . "\n" . \
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
$datetime . " connected to SSID " . $ssid . ", interface " . $interface);
|
||||
/ log info $message;
|
||||
/ %PATH% access-list add place-before=$"place-before" comment=$message mac-address=$mac disabled=yes;
|
||||
$SendNotification ("[" . $identity . "] " . $mac . " connected to " . $ssid) \
|
||||
$SendNotification ($mac . " connected to " . $ssid) \
|
||||
("A device with unknown MAC address connected to " . $ssid . " on " . $identity . ".\n\n" . \
|
||||
"Controller: " . $identity . "\n" . \
|
||||
"Interface: " . $interface . "\n" . \
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
:set attach "";
|
||||
}
|
||||
|
||||
$SendNotification ("[" . $identity . "] daily PSK " . $ssid) \
|
||||
$SendNotification ("daily PSK " . $ssid) \
|
||||
("This is the daily PSK on " . $identity . ":\n\n" . \
|
||||
"SSID: " . $ssid . "\n" . \
|
||||
"PSK: " . $newpsk . "\n" . \
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
# Run different commands with multiple mode-button presses.
|
||||
:global "mode-button" {
|
||||
1="/ system script run leds-toggle-mode;";
|
||||
2=":global SendNotification; :global identity; \$SendNotification (\"[\" . \$identity . \"] Hello...\") (\"Hello world, \" . \$identity . \" calling!\");";
|
||||
2=":global SendNotification; :global identity; \$SendNotification (\"Hello...\") (\"Hello world, \" . \$identity . \" calling!\");";
|
||||
3="/ system shutdown;";
|
||||
4="/ system reboot;";
|
||||
5="/ system script run bridge-port-toggle;";
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
:local message [ :tostr $2 ];
|
||||
:local attach [ :tostr $3 ];
|
||||
|
||||
:global "identity";
|
||||
:global "email-general-to";
|
||||
:global "email-general-cc";
|
||||
:global "telegram-tokenid";
|
||||
|
@ -72,7 +73,7 @@
|
|||
:if ([ :len $"email-general-to" ] > 0) do={
|
||||
:do {
|
||||
/ tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \
|
||||
subject=$subject body=$message file=$attach;
|
||||
subject=("[" . $"identity" . "] " . $subject) body=$message file=$attach;
|
||||
} on-error={
|
||||
:log warning "Failed sending notification mail!";
|
||||
}
|
||||
|
@ -83,7 +84,8 @@
|
|||
:do {
|
||||
/ tool fetch check-certificate=yes-without-crl keep-result=no http-method=post \
|
||||
("https://api.telegram.org/bot" . $"telegram-tokenid" . "/sendMessage") \
|
||||
http-data=("chat_id=" . $"telegram-chatid" . "&text=" . [ $UrlEncode $message ]);
|
||||
http-data=("chat_id=" . $"telegram-chatid" . "&text=" . \
|
||||
[ $UrlEncode ("[" . $"identity" . "] " . $subject . "\n\n" . $message) ]);
|
||||
} on-error={
|
||||
:log warning "Failed sending telegram notification!";
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
:if ($phone = $allowed && message~("^:cmd " . $secret . " script ")) do={
|
||||
:log debug "Ignoring SMS, which starts a script.";
|
||||
} else={
|
||||
$SendNotification ("[" . $identity . "] SMS Forwarding") \
|
||||
$SendNotification ("SMS Forwarding") \
|
||||
("A message was received by " . $identity . ":\n\n" . \
|
||||
"Phone: " . $phone . "\n" . \
|
||||
"Timestamp: " . $timestamp . "\n" . \
|
||||
|
|
Loading…
Reference in a new issue