mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-08-18 00:28:28 +02:00
mod/notification-telegram: switch to $LogPrint
This commit is contained in:
parent
fb88521ed5
commit
699f09c282
1 changed files with 8 additions and 7 deletions
|
@ -18,12 +18,12 @@
|
||||||
:global TelegramMessageIDs;
|
:global TelegramMessageIDs;
|
||||||
|
|
||||||
:global IsFullyConnected;
|
:global IsFullyConnected;
|
||||||
:global LogPrintExit2;
|
:global LogPrint;
|
||||||
:global ParseJson;
|
:global ParseJson;
|
||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
|
|
||||||
: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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
:local QueueLen [ :len $TelegramQueue ];
|
:local QueueLen [ :len $TelegramQueue ];
|
||||||
|
|
||||||
:if ([ :len [ /system/scheduler/find where name="_FlushTelegramQueue" ] ] > 0 && $QueueLen = 0) do={
|
:if ([ :len [ /system/scheduler/find where name="_FlushTelegramQueue" ] ] > 0 && $QueueLen = 0) do={
|
||||||
$LogPrintExit2 warning $0 ("Flushing Telegram messages from scheduler, but queue is empty.") false;
|
$LogPrint warning $0 ("Flushing Telegram messages from scheduler, but queue is empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Id,Message in=$TelegramQueue do={
|
:foreach Id,Message in=$TelegramQueue do={
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
:set ($TelegramQueue->$Id);
|
:set ($TelegramQueue->$Id);
|
||||||
:set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
|
:set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 debug $0 ("Sending queued Telegram message failed.") false;
|
$LogPrint debug $0 ("Sending queued Telegram message failed.");
|
||||||
:set AllDone false;
|
:set AllDone false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
:global LogPrintExit2;
|
:global LogPrint;
|
||||||
:global ParseJson;
|
:global ParseJson;
|
||||||
:global SymbolForNotification;
|
:global SymbolForNotification;
|
||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
|
@ -136,7 +136,8 @@
|
||||||
|
|
||||||
:do {
|
:do {
|
||||||
:if ([ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2" ] = false) do={
|
:if ([ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2" ] = false) do={
|
||||||
$LogPrintExit2 warning $0 ("Downloading required certificate failed.") true;
|
$LogPrint warning $0 ("Downloading required certificate failed.");
|
||||||
|
:error false;
|
||||||
}
|
}
|
||||||
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user http-method=post \
|
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user http-method=post \
|
||||||
("https://api.telegram.org/bot" . $TokenId . "/sendMessage") \
|
("https://api.telegram.org/bot" . $TokenId . "/sendMessage") \
|
||||||
|
@ -145,7 +146,7 @@
|
||||||
"&parse_mode=MarkdownV2&text=" . [ $UrlEncode $Text ]) as-value ]->"data");
|
"&parse_mode=MarkdownV2&text=" . [ $UrlEncode $Text ]) as-value ]->"data");
|
||||||
:set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
|
:set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 info $0 ("Failed sending telegram notification! Queuing...") false;
|
$LogPrint info $0 ("Failed sending telegram notification! Queuing...");
|
||||||
|
|
||||||
:if ([ :typeof $TelegramQueue ] = "nothing") do={
|
:if ([ :typeof $TelegramQueue ] = "nothing") do={
|
||||||
:set TelegramQueue ({});
|
:set TelegramQueue ({});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue