mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-08-17 16:21:00 +02:00
mod/notification-matrix: RouterOS v7 path syntax
This commit is contained in:
parent
9bd9f4b4ba
commit
50a139248f
1 changed files with 8 additions and 8 deletions
|
@ -18,14 +18,14 @@
|
||||||
:local AllDone true;
|
:local AllDone true;
|
||||||
:local QueueLen [ :len $MatrixQueue ];
|
:local QueueLen [ :len $MatrixQueue ];
|
||||||
|
|
||||||
:if ([ :len [ / system scheduler find where name="FlushMatrixQueue" ] ] > 0 && $QueueLen = 0) do={
|
:if ([ :len [ /system/scheduler/find where name="FlushMatrixQueue" ] ] > 0 && $QueueLen = 0) do={
|
||||||
$LogPrintExit2 warning $0 ("Flushing Matrix messages from scheduler, but queue is empty.") false;
|
$LogPrintExit2 warning $0 ("Flushing Matrix messages from scheduler, but queue is empty.") false;
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Id,Message in=$MatrixQueue do={
|
:foreach Id,Message in=$MatrixQueue do={
|
||||||
:if ([ :typeof $Message ] = "array" ) do={
|
:if ([ :typeof $Message ] = "array" ) do={
|
||||||
:do {
|
:do {
|
||||||
/ tool fetch check-certificate=yes-without-crl output=none http-method=post \
|
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
|
||||||
("https://" . $Message->"homeserver" . "/_matrix/client/r0/rooms/" . $Message->"room" . \
|
("https://" . $Message->"homeserver" . "/_matrix/client/r0/rooms/" . $Message->"room" . \
|
||||||
"/send/m.room.message?access_token=" . $Message->"accesstoken") \
|
"/send/m.room.message?access_token=" . $Message->"accesstoken") \
|
||||||
http-data=("{ \"msgtype\": \"m.text\", \"body\": \"" . $Message->"plain" . "\"," . \
|
http-data=("{ \"msgtype\": \"m.text\", \"body\": \"" . $Message->"plain" . "\"," . \
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($AllDone = true && $QueueLen = [ :len $MatrixQueue ]) do={
|
:if ($AllDone = true && $QueueLen = [ :len $MatrixQueue ]) do={
|
||||||
/ system scheduler remove [ find where name="FlushMatrixQueue" ];
|
/system/scheduler/remove [ find where name="FlushMatrixQueue" ];
|
||||||
:set MatrixQueue;
|
:set MatrixQueue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:do {
|
:do {
|
||||||
/ tool fetch check-certificate=yes-without-crl output=none http-method=post \
|
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
|
||||||
("https://" . $HomeServer . "/_matrix/client/r0/rooms/" . $Room . \
|
("https://" . $HomeServer . "/_matrix/client/r0/rooms/" . $Room . \
|
||||||
"/send/m.room.message?access_token=" . $AccessToken) \
|
"/send/m.room.message?access_token=" . $AccessToken) \
|
||||||
http-data=("{ \"msgtype\": \"m.text\", \"body\": \"" . $Plain . "\"," . \
|
http-data=("{ \"msgtype\": \"m.text\", \"body\": \"" . $Plain . "\"," . \
|
||||||
|
@ -126,15 +126,15 @@
|
||||||
:set MatrixQueue [ :toarray "" ];
|
:set MatrixQueue [ :toarray "" ];
|
||||||
}
|
}
|
||||||
:local Text ([ $SymbolForNotification "alarm-clock" ] . \
|
:local Text ([ $SymbolForNotification "alarm-clock" ] . \
|
||||||
"This message was queued since " . [ / system clock get date ] . \
|
"This message was queued since " . [ /system/clock/get date ] . \
|
||||||
" " . [ / system clock get time ] . " and may be obsolete.");
|
" " . [ /system/clock/get time ] . " and may be obsolete.");
|
||||||
:set Plain ($Plain . "\\n" . $Text);
|
:set Plain ($Plain . "\\n" . $Text);
|
||||||
:set Formatted ($Formatted . "<br/>" . $Text);
|
:set Formatted ($Formatted . "<br/>" . $Text);
|
||||||
:set ($MatrixQueue->[ :len $MatrixQueue ]) { room=$Room; \
|
:set ($MatrixQueue->[ :len $MatrixQueue ]) { room=$Room; \
|
||||||
accesstoken=$AccessToken; homeserver=$HomeServer; \
|
accesstoken=$AccessToken; homeserver=$HomeServer; \
|
||||||
plain=$Plain; formatted=$Formatted };
|
plain=$Plain; formatted=$Formatted };
|
||||||
:if ([ :len [ / system scheduler find where name="FlushMatrixQueue" ] ] = 0) do={
|
:if ([ :len [ /system/scheduler/find where name="FlushMatrixQueue" ] ] = 0) do={
|
||||||
/ system scheduler add name=FlushMatrixQueue interval=1m start-time=startup \
|
/system/scheduler/add name=FlushMatrixQueue interval=1m start-time=startup \
|
||||||
on-event=(":global FlushMatrixQueue; \$FlushMatrixQueue;");
|
on-event=(":global FlushMatrixQueue; \$FlushMatrixQueue;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue