mirror of
https://github.com/nymurbd/MikroTik-scripts.git
synced 2025-07-25 21:34:36 +02:00
mod/notification-ntfy: switch to $LogPrint
This commit is contained in:
parent
279993e965
commit
fb88521ed5
1 changed files with 8 additions and 7 deletions
|
@ -18,10 +18,10 @@
|
||||||
:global NtfyMessageIDs;
|
:global NtfyMessageIDs;
|
||||||
|
|
||||||
:global IsFullyConnected;
|
:global IsFullyConnected;
|
||||||
:global LogPrintExit2;
|
:global LogPrint;
|
||||||
|
|
||||||
:if ([ $IsFullyConnected ] = false) do={
|
:if ([ $IsFullyConnected ] = false) do={
|
||||||
$LogPrintExit2 debug $0 ("System is not fully connected, not flushing.") false;
|
$LogPrint debug $0 ("System is not fully connected, not flushing.");
|
||||||
:return false;
|
:return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
:local QueueLen [ :len $NtfyQueue ];
|
:local QueueLen [ :len $NtfyQueue ];
|
||||||
|
|
||||||
:if ([ :len [ /system/scheduler/find where name="_FlushNtfyQueue" ] ] > 0 && $QueueLen = 0) do={
|
:if ([ :len [ /system/scheduler/find where name="_FlushNtfyQueue" ] ] > 0 && $QueueLen = 0) do={
|
||||||
$LogPrintExit2 warning $0 ("Flushing Ntfy messages from scheduler, but queue is empty.") false;
|
$LogPrint warning $0 ("Flushing Ntfy messages from scheduler, but queue is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Id,Message in=$NtfyQueue do={
|
:foreach Id,Message in=$NtfyQueue do={
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
($Message->"url") http-header-field=($Message->"headers") http-data=($Message->"text") as-value;
|
($Message->"url") http-header-field=($Message->"headers") http-data=($Message->"text") as-value;
|
||||||
:set ($NtfyQueue->$Id);
|
:set ($NtfyQueue->$Id);
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 debug $0 ("Sending queued Ntfy message failed.") false;
|
$LogPrint debug $0 ("Sending queued Ntfy message failed.");
|
||||||
:set AllDone false;
|
:set AllDone false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
:global CertificateAvailable;
|
:global CertificateAvailable;
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
:global LogPrintExit2;
|
:global LogPrint;
|
||||||
:global SymbolForNotification;
|
:global SymbolForNotification;
|
||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
|
|
||||||
|
@ -88,13 +88,14 @@
|
||||||
:do {
|
:do {
|
||||||
:if ($NtfyServer = "ntfy.sh") do={
|
:if ($NtfyServer = "ntfy.sh") do={
|
||||||
:if ([ $CertificateAvailable "R3" ] = false) do={
|
:if ([ $CertificateAvailable "R3" ] = false) do={
|
||||||
$LogPrintExit2 warning $0 ("Downloading required certificate failed.") true;
|
$LogPrint warning $0 ("Downloading required certificate failed.");
|
||||||
|
:error false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
|
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
|
||||||
$Url http-header-field=$Headers http-data=$Text as-value;
|
$Url http-header-field=$Headers http-data=$Text as-value;
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 info $0 ("Failed sending ntfy notification! Queuing...") false;
|
$LogPrint info $0 ("Failed sending ntfy notification! Queuing...");
|
||||||
|
|
||||||
:if ([ :typeof $NtfyQueue ] = "nothing") do={
|
:if ([ :typeof $NtfyQueue ] = "nothing") do={
|
||||||
:set NtfyQueue ({});
|
:set NtfyQueue ({});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue