diff options
author | Christian Hesse <mail@eworm.de> | 2020-11-26 23:02:15 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-11-26 23:04:05 +0100 |
commit | ca4e25283fa7a3c72d4b678cd0e5781f71cfed7e (patch) | |
tree | 87892cbd20b3f1d8911676c9cf15752b3b30ec47 | |
parent | d09baddac30b8221ed34db41b9f0536daf83a084 (diff) |
global-functions: clickable links in telegram notifications
-rw-r--r-- | check-certificates | 2 | ||||
-rw-r--r-- | check-lte-firmware-upgrade | 2 | ||||
-rw-r--r-- | check-routeros-update | 15 | ||||
-rw-r--r-- | cloud-backup | 2 | ||||
-rw-r--r-- | daily-psk.capsman | 4 | ||||
-rw-r--r-- | daily-psk.local | 4 | ||||
-rw-r--r-- | daily-psk.template | 4 | ||||
-rw-r--r-- | global-functions | 24 | ||||
-rw-r--r-- | upload-backup | 2 |
9 files changed, 29 insertions, 30 deletions
diff --git a/check-certificates b/check-certificates index d5c08b9..f3a8e99 100644 --- a/check-certificates +++ b/check-certificates @@ -91,7 +91,7 @@ $WaitFullyConnected; "Fingerprint: " . ($CertNewVal->"fingerprint") . "\n" . \ "Issuer: " . ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") . "\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; } on-error={ $LogPrintExit debug ("Could not renew certificate " . ($CertVal->"name") . ".") false; diff --git a/check-lte-firmware-upgrade b/check-lte-firmware-upgrade index 0e4cb3d..08b27ce 100644 --- a/check-lte-firmware-upgrade +++ b/check-lte-firmware-upgrade @@ -30,7 +30,7 @@ "LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \ "Interface: " . [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] . "\n" . \ "Installed: " . ($Firmware->"installed") . "\n" . \ - "Available: " . ($Firmware->"latest")) "" "true"; + "Available: " . ($Firmware->"latest")) "" "" "true"; :set SentLteFirmwareUpgradeNotification ($Firmware->"latest"); } } diff --git a/check-routeros-update b/check-routeros-update index b8e87d9..a4dfe9d 100644 --- a/check-routeros-update +++ b/check-routeros-update @@ -48,13 +48,14 @@ :local NumInstalled [ $VersionToNum ($Update->"installed-version") ]; :local NumLatest [ $VersionToNum ($Update->"latest-version") ]; +:local Link ("https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree"); :if ($NumInstalled < $NumLatest) do={ :if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={ $LogPrintExit info ("Version " . $Update->"latest-version" . " is a patch release, updating...") false; $SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \ ("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \ - ", updating on " . $Identity . "...") "" "true"; + ", updating on " . $Identity . "...") $Link "" "true"; $DoUpdate; } @@ -63,7 +64,7 @@ $LogPrintExit info ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false; $SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \ ("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \ - ", updating on " . $Identity . "...") "" "true"; + ", updating on " . $Identity . "...") $Link "" "true"; $DoUpdate; } @@ -80,7 +81,7 @@ $LogPrintExit info ("Version " . $Update->"latest-version" . " is considered safe, updating...") false; $SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \ ("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \ - ", updating on " . $Identity . "...") "" "true"; + ", updating on " . $Identity . "...") $Link "" "true"; $DoUpdate; } } @@ -102,9 +103,7 @@ $SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \ ("A new RouterOS version " . ($Update->"latest-version") . \ " is available for " . $Identity . ".\n\n" . \ - [ $DeviceInfo ] . "\n\n" . \ - "https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree") \ - "" "true"; + [ $DeviceInfo ]) $Link "" "true"; :set SentRouterosUpdateNotification ($Update->"latest-version"); } @@ -117,9 +116,7 @@ $SendNotification ([ $SymbolForNotification "warning-sign" ] . "RouterOS version") \ ("A different RouterOS version " . ($Update->"latest-version") . \ " is available for " . $Identity . ", but it is a downgrade.\n\n" . \ - [ $DeviceInfo ] . "\n\n" . \ - "https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree") \ - "" "true"; + [ $DeviceInfo ]) $Link "" "true"; $LogPrintExit info ("A different RouterOS version " . ($Update->"latest-version") . \ " is available for downgrade.") false; :set SentRouterosUpdateNotification ($Update->"latest-version"); diff --git a/cloud-backup b/cloud-backup index e1386f0..46777b9 100644 --- a/cloud-backup +++ b/cloud-backup @@ -32,7 +32,7 @@ [ $DeviceInfo ] . "\n\n" . \ "Name: " . $Cloud->"name" . "\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={ $SendNotification ([ $SymbolForNotification "warning-sign" ] . "Cloud backup failed") \ ("Failed uploading backup for " . $Identity . " to cloud!\n\n" . [ $DeviceInfo ]); diff --git a/daily-psk.capsman b/daily-psk.capsman index 33208f5..2f7e8f2 100644 --- a/daily-psk.capsman +++ b/daily-psk.capsman @@ -93,8 +93,8 @@ $WaitFullyConnected; "SSID: " . $Ssid . "\n" . \ "PSK: " . $NewPsk . "\n" . \ "Date: " . $Date . "\n\n" . \ - "A client device specific rule must not exist!\n\n" . \ - $Url) $Attach; + "A client device specific rule must not exist!") \ + $Url $Attach; } } } diff --git a/daily-psk.local b/daily-psk.local index 13a878e..d51d5f6 100644 --- a/daily-psk.local +++ b/daily-psk.local @@ -93,8 +93,8 @@ $WaitFullyConnected; "SSID: " . $Ssid . "\n" . \ "PSK: " . $NewPsk . "\n" . \ "Date: " . $Date . "\n\n" . \ - "A client device specific rule must not exist!\n\n" . \ - $Url) $Attach; + "A client device specific rule must not exist!") \ + $Url $Attach; } } } diff --git a/daily-psk.template b/daily-psk.template index fd5bd2b..acc8edd 100644 --- a/daily-psk.template +++ b/daily-psk.template @@ -99,8 +99,8 @@ $WaitFullyConnected; "SSID: " . $Ssid . "\n" . \ "PSK: " . $NewPsk . "\n" . \ "Date: " . $Date . "\n\n" . \ - "A client device specific rule must not exist!\n\n" . \ - $Url) $Attach; + "A client device specific rule must not exist!") \ + $Url $Attach; } } } diff --git a/global-functions b/global-functions index de62a59..f42d8f9 100644 --- a/global-functions +++ b/global-functions @@ -682,17 +682,18 @@ "\n\nChanges are not available."); } + :local Link; :if ($IDonate != true) do={ :set NotificationMessage ($NotificationMessage . \ "\n\n==== donation hint ====\n" . \ "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 " . \ - "of value for you or your business please consider a donation:\n" . \ - "https://git.eworm.de/cgit/routeros-scripts/about/#donate"); + "of value for you or your business please consider a donation."); + :set Link "https://git.eworm.de/cgit/routeros-scripts/about/#donate"; } $SendNotification ([ $SymbolForNotification "pushpin" ] . "News and configuration changes") \ - $NotificationMessage; + $NotificationMessage $Link; :set SentConfigChangesNotification $ExpectedConfigVersion; } } @@ -712,8 +713,8 @@ :set SendEMail do={ :local Subject [ :tostr $1 ]; :local Message [ :tostr $2 ]; - :local Link; - :local Attach [ :tostr $3 ]; + :local Link [ :tostr $3 ]; + :local Attach [ :tostr $4 ]; :global Identity; :global EmailGeneralTo; @@ -744,22 +745,23 @@ :set SendNotification do={ :local Subject [ :tostr $1 ]; :local Message [ :tostr $2 ]; - :local Attach [ :tostr $3 ]; - :local Silent [ :tostr $4 ]; + :local Link [ :tostr $3 ]; + :local Attach [ :tostr $4 ]; + :local Silent [ :tostr $5 ]; :global SendEMail; :global SendTelegram; - $SendEMail $Subject $Message $Attach; - $SendTelegram $Subject $Message $Silent; + $SendEMail $Subject $Message $Link $Attach; + $SendTelegram $Subject $Message $Link $Silent; } # send notification via telegram :set SendTelegram do={ :local Subject [ :tostr $1 ]; :local Message [ :tostr $2 ]; - :local Link; - :local Silent [ :tostr $3 ]; + :local Link [ :tostr $3 ]; + :local Silent [ :tostr $4 ]; :global Identity; :global TelegramChatId; diff --git a/upload-backup b/upload-backup index 27eab0c..5d4dd8e 100644 --- a/upload-backup +++ b/upload-backup @@ -72,7 +72,7 @@ $SendNotification [ $IfThenElse ($Failed > 0) \ ("Backup and config export upload for " . $Identity . ".\n\n" . \ [ $DeviceInfo ] . "\n\n" . \ "Backup file: " . $BackupFile . "\n" . \ - "Config file: " . $ConfigFile) "" "true"; + "Config file: " . $ConfigFile) "" "" "true"; :if ($Failed = 1) do={ :error "An error occured!"; |