mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-17 16:21:15 +02:00
global-functions: clickable links in telegram notifications
This commit is contained in:
parent
d09baddac3
commit
ca4e25283f
9 changed files with 29 additions and 30 deletions
|
@ -91,7 +91,7 @@ $WaitFullyConnected;
|
||||||
"Fingerprint: " . ($CertNewVal->"fingerprint") . "\n" . \
|
"Fingerprint: " . ($CertNewVal->"fingerprint") . "\n" . \
|
||||||
"Issuer: " . ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") . "\n" . \
|
"Issuer: " . ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") . "\n" . \
|
||||||
"Validity: " . ($CertNewVal->"invalid-before") . " to " . ($CertNewVal->"invalid-after") . "\n" . \
|
"Validity: " . ($CertNewVal->"invalid-before") . " to " . ($CertNewVal->"invalid-after") . "\n" . \
|
||||||
"Expires in: " . [ $FormatExpire ($CertNewVal->"expires-after") ]) "" "true";
|
"Expires in: " . [ $FormatExpire ($CertNewVal->"expires-after") ]) "" "" "true";
|
||||||
$LogPrintExit info ("The certificate " . ($CertVal->"name") . " has been renewed.") false;
|
$LogPrintExit info ("The certificate " . ($CertVal->"name") . " has been renewed.") false;
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit debug ("Could not renew certificate " . ($CertVal->"name") . ".") false;
|
$LogPrintExit debug ("Could not renew certificate " . ($CertVal->"name") . ".") false;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
"LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \
|
"LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \
|
||||||
"Interface: " . [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] . "\n" . \
|
"Interface: " . [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] . "\n" . \
|
||||||
"Installed: " . ($Firmware->"installed") . "\n" . \
|
"Installed: " . ($Firmware->"installed") . "\n" . \
|
||||||
"Available: " . ($Firmware->"latest")) "" "true";
|
"Available: " . ($Firmware->"latest")) "" "" "true";
|
||||||
:set SentLteFirmwareUpgradeNotification ($Firmware->"latest");
|
:set SentLteFirmwareUpgradeNotification ($Firmware->"latest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,13 +48,14 @@
|
||||||
|
|
||||||
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
|
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
|
||||||
:local NumLatest [ $VersionToNum ($Update->"latest-version") ];
|
:local NumLatest [ $VersionToNum ($Update->"latest-version") ];
|
||||||
|
:local Link ("https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree");
|
||||||
|
|
||||||
:if ($NumInstalled < $NumLatest) do={
|
:if ($NumInstalled < $NumLatest) do={
|
||||||
:if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={
|
:if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={
|
||||||
$LogPrintExit info ("Version " . $Update->"latest-version" . " is a patch release, updating...") false;
|
$LogPrintExit info ("Version " . $Update->"latest-version" . " is a patch release, updating...") false;
|
||||||
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
|
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
|
||||||
("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
|
("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
|
||||||
", updating on " . $Identity . "...") "" "true";
|
", updating on " . $Identity . "...") $Link "" "true";
|
||||||
$DoUpdate;
|
$DoUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@
|
||||||
$LogPrintExit info ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false;
|
$LogPrintExit info ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false;
|
||||||
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
|
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
|
||||||
("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \
|
("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \
|
||||||
", updating on " . $Identity . "...") "" "true";
|
", updating on " . $Identity . "...") $Link "" "true";
|
||||||
$DoUpdate;
|
$DoUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@
|
||||||
$LogPrintExit info ("Version " . $Update->"latest-version" . " is considered safe, updating...") false;
|
$LogPrintExit info ("Version " . $Update->"latest-version" . " is considered safe, updating...") false;
|
||||||
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
|
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
|
||||||
("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \
|
("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \
|
||||||
", updating on " . $Identity . "...") "" "true";
|
", updating on " . $Identity . "...") $Link "" "true";
|
||||||
$DoUpdate;
|
$DoUpdate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,9 +103,7 @@
|
||||||
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
|
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \
|
||||||
("A new RouterOS version " . ($Update->"latest-version") . \
|
("A new RouterOS version " . ($Update->"latest-version") . \
|
||||||
" is available for " . $Identity . ".\n\n" . \
|
" is available for " . $Identity . ".\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ]) $Link "" "true";
|
||||||
"https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree") \
|
|
||||||
"" "true";
|
|
||||||
:set SentRouterosUpdateNotification ($Update->"latest-version");
|
:set SentRouterosUpdateNotification ($Update->"latest-version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,9 +116,7 @@
|
||||||
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "RouterOS version") \
|
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "RouterOS version") \
|
||||||
("A different RouterOS version " . ($Update->"latest-version") . \
|
("A different RouterOS version " . ($Update->"latest-version") . \
|
||||||
" is available for " . $Identity . ", but it is a downgrade.\n\n" . \
|
" is available for " . $Identity . ", but it is a downgrade.\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ]) $Link "" "true";
|
||||||
"https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree") \
|
|
||||||
"" "true";
|
|
||||||
$LogPrintExit info ("A different RouterOS version " . ($Update->"latest-version") . \
|
$LogPrintExit info ("A different RouterOS version " . ($Update->"latest-version") . \
|
||||||
" is available for downgrade.") false;
|
" is available for downgrade.") false;
|
||||||
:set SentRouterosUpdateNotification ($Update->"latest-version");
|
:set SentRouterosUpdateNotification ($Update->"latest-version");
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
"Name: " . $Cloud->"name" . "\n" . \
|
"Name: " . $Cloud->"name" . "\n" . \
|
||||||
"Size: " . $Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)\n" . \
|
"Size: " . $Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)\n" . \
|
||||||
"Download key: " . $Cloud->"secret-download-key") "" "true";
|
"Download key: " . $Cloud->"secret-download-key") "" "" "true";
|
||||||
} on-error={
|
} on-error={
|
||||||
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "Cloud backup failed") \
|
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "Cloud backup failed") \
|
||||||
("Failed uploading backup for " . $Identity . " to cloud!\n\n" . [ $DeviceInfo ]);
|
("Failed uploading backup for " . $Identity . " to cloud!\n\n" . [ $DeviceInfo ]);
|
||||||
|
|
|
@ -93,8 +93,8 @@ $WaitFullyConnected;
|
||||||
"SSID: " . $Ssid . "\n" . \
|
"SSID: " . $Ssid . "\n" . \
|
||||||
"PSK: " . $NewPsk . "\n" . \
|
"PSK: " . $NewPsk . "\n" . \
|
||||||
"Date: " . $Date . "\n\n" . \
|
"Date: " . $Date . "\n\n" . \
|
||||||
"A client device specific rule must not exist!\n\n" . \
|
"A client device specific rule must not exist!") \
|
||||||
$Url) $Attach;
|
$Url $Attach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,8 @@ $WaitFullyConnected;
|
||||||
"SSID: " . $Ssid . "\n" . \
|
"SSID: " . $Ssid . "\n" . \
|
||||||
"PSK: " . $NewPsk . "\n" . \
|
"PSK: " . $NewPsk . "\n" . \
|
||||||
"Date: " . $Date . "\n\n" . \
|
"Date: " . $Date . "\n\n" . \
|
||||||
"A client device specific rule must not exist!\n\n" . \
|
"A client device specific rule must not exist!") \
|
||||||
$Url) $Attach;
|
$Url $Attach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,8 @@ $WaitFullyConnected;
|
||||||
"SSID: " . $Ssid . "\n" . \
|
"SSID: " . $Ssid . "\n" . \
|
||||||
"PSK: " . $NewPsk . "\n" . \
|
"PSK: " . $NewPsk . "\n" . \
|
||||||
"Date: " . $Date . "\n\n" . \
|
"Date: " . $Date . "\n\n" . \
|
||||||
"A client device specific rule must not exist!\n\n" . \
|
"A client device specific rule must not exist!") \
|
||||||
$Url) $Attach;
|
$Url $Attach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,17 +682,18 @@
|
||||||
"\n\nChanges are not available.");
|
"\n\nChanges are not available.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:local Link;
|
||||||
:if ($IDonate != true) do={
|
:if ($IDonate != true) do={
|
||||||
:set NotificationMessage ($NotificationMessage . \
|
:set NotificationMessage ($NotificationMessage . \
|
||||||
"\n\n==== donation hint ====\n" . \
|
"\n\n==== donation hint ====\n" . \
|
||||||
"This project is developed in private spare time and usage is " . \
|
"This project is developed in private spare time and usage is " . \
|
||||||
"free of charge for you. If you like the scripts and think this is " . \
|
"free of charge for you. If you like the scripts and think this is " . \
|
||||||
"of value for you or your business please consider a donation:\n" . \
|
"of value for you or your business please consider a donation.");
|
||||||
"https://git.eworm.de/cgit/routeros-scripts/about/#donate");
|
:set Link "https://git.eworm.de/cgit/routeros-scripts/about/#donate";
|
||||||
}
|
}
|
||||||
|
|
||||||
$SendNotification ([ $SymbolForNotification "pushpin" ] . "News and configuration changes") \
|
$SendNotification ([ $SymbolForNotification "pushpin" ] . "News and configuration changes") \
|
||||||
$NotificationMessage;
|
$NotificationMessage $Link;
|
||||||
:set SentConfigChangesNotification $ExpectedConfigVersion;
|
:set SentConfigChangesNotification $ExpectedConfigVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -712,8 +713,8 @@
|
||||||
:set SendEMail do={
|
:set SendEMail do={
|
||||||
:local Subject [ :tostr $1 ];
|
:local Subject [ :tostr $1 ];
|
||||||
:local Message [ :tostr $2 ];
|
:local Message [ :tostr $2 ];
|
||||||
:local Link;
|
:local Link [ :tostr $3 ];
|
||||||
:local Attach [ :tostr $3 ];
|
:local Attach [ :tostr $4 ];
|
||||||
|
|
||||||
:global Identity;
|
:global Identity;
|
||||||
:global EmailGeneralTo;
|
:global EmailGeneralTo;
|
||||||
|
@ -744,22 +745,23 @@
|
||||||
:set SendNotification do={
|
:set SendNotification do={
|
||||||
:local Subject [ :tostr $1 ];
|
:local Subject [ :tostr $1 ];
|
||||||
:local Message [ :tostr $2 ];
|
:local Message [ :tostr $2 ];
|
||||||
:local Attach [ :tostr $3 ];
|
:local Link [ :tostr $3 ];
|
||||||
:local Silent [ :tostr $4 ];
|
:local Attach [ :tostr $4 ];
|
||||||
|
:local Silent [ :tostr $5 ];
|
||||||
|
|
||||||
:global SendEMail;
|
:global SendEMail;
|
||||||
:global SendTelegram;
|
:global SendTelegram;
|
||||||
|
|
||||||
$SendEMail $Subject $Message $Attach;
|
$SendEMail $Subject $Message $Link $Attach;
|
||||||
$SendTelegram $Subject $Message $Silent;
|
$SendTelegram $Subject $Message $Link $Silent;
|
||||||
}
|
}
|
||||||
|
|
||||||
# send notification via telegram
|
# send notification via telegram
|
||||||
:set SendTelegram do={
|
:set SendTelegram do={
|
||||||
:local Subject [ :tostr $1 ];
|
:local Subject [ :tostr $1 ];
|
||||||
:local Message [ :tostr $2 ];
|
:local Message [ :tostr $2 ];
|
||||||
:local Link;
|
:local Link [ :tostr $3 ];
|
||||||
:local Silent [ :tostr $3 ];
|
:local Silent [ :tostr $4 ];
|
||||||
|
|
||||||
:global Identity;
|
:global Identity;
|
||||||
:global TelegramChatId;
|
:global TelegramChatId;
|
||||||
|
|
|
@ -72,7 +72,7 @@ $SendNotification [ $IfThenElse ($Failed > 0) \
|
||||||
("Backup and config export upload for " . $Identity . ".\n\n" . \
|
("Backup and config export upload for " . $Identity . ".\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
"Backup file: " . $BackupFile . "\n" . \
|
"Backup file: " . $BackupFile . "\n" . \
|
||||||
"Config file: " . $ConfigFile) "" "true";
|
"Config file: " . $ConfigFile) "" "" "true";
|
||||||
|
|
||||||
:if ($Failed = 1) do={
|
:if ($Failed = 1) do={
|
||||||
:error "An error occured!";
|
:error "An error occured!";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue