aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-04-01 23:21:50 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-04-02 00:08:44 +0200
commite107247c1684c45d230cd1db3862190f9d0177b6 (patch)
tree6d4af0498b99b7b633ff3102af704eaf24257594 /mod
parentc01a424f4f41997d1b8b4a45c2bb033f37470393 (diff)
parent4db91ec16eb482d0989435f40373f455f1665f97 (diff)
Merge branch 'deserialize' into nextrouteros-7.13-3
Diffstat (limited to 'mod')
-rw-r--r--mod/notification-matrix.rsc8
-rw-r--r--mod/notification-telegram.rsc8
2 files changed, 8 insertions, 8 deletions
diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc
index aa95841..8234779 100644
--- a/mod/notification-matrix.rsc
+++ b/mod/notification-matrix.rsc
@@ -4,6 +4,8 @@
# Christian Hesse <mail@eworm.de>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
#
+# requires RouterOS, version=7.13
+#
# send notifications via Matrix
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mod/notification-matrix.md
@@ -183,9 +185,7 @@
:local User [ :tostr $1 ];
:local Pass [ :tostr $2 ];
- :global CharacterReplace;
:global LogPrint;
- :global ParseJson;
:global MatrixAccessToken;
:global MatrixHomeServer;
@@ -194,7 +194,7 @@
:do {
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
("https://" . $Domain . "/.well-known/matrix/client") as-value ]->"data");
- :set MatrixHomeServer ([ $ParseJson ([ $ParseJson [ $CharacterReplace $Data " " "" ] ]->"m.homeserver") ]->"base_url");
+ :set MatrixHomeServer ([ :deserialize from=json value=$Data ]->"m.homeserver"->"base_url");
$LogPrint debug $0 ("Home server is: " . $MatrixHomeServer);
} on-error={
$LogPrint error $0 ("Failed getting home server!");
@@ -209,7 +209,7 @@
:local Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
http-method=post http-data=("{\"type\":\"m.login.password\", \"user\":\"" . $User . "\", \"password\":\"" . $Pass . "\"}") \
("https://" . $MatrixHomeServer . "/_matrix/client/r0/login") as-value ]->"data");
- :set MatrixAccessToken ([ $ParseJson $Data ]->"access_token");
+ :set MatrixAccessToken ([ :deserialize from=json value=$Data ]->"access_token");
$LogPrint debug $0 ("Access token is: " . $MatrixAccessToken);
} on-error={
$LogPrint error $0 ("Failed logging in (and getting access token)!");
diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc
index 506ec80..a43ff10 100644
--- a/mod/notification-telegram.rsc
+++ b/mod/notification-telegram.rsc
@@ -3,6 +3,8 @@
# Copyright (c) 2013-2024 Christian Hesse <mail@eworm.de>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
#
+# requires RouterOS, version=7.13
+#
# send notifications via Telegram
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mod/notification-telegram.md
@@ -19,7 +21,6 @@
:global IsFullyConnected;
:global LogPrint;
- :global ParseJson;
:global UrlEncode;
:if ([ $IsFullyConnected ] = false) do={
@@ -43,7 +44,7 @@
"&reply_to_message_id=" . ($Message->"replyto") . "&disable_web_page_preview=true" . \
"&parse_mode=MarkdownV2&text=" . [ $UrlEncode ($Message->"text") ]) as-value ]->"data");
:set ($TelegramQueue->$Id);
- :set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
+ :set ($TelegramMessageIDs->[ :tostr ([ :deserialize from=json value=$Data ]->"result"->"message_id") ]) 1;
} on-error={
$LogPrint debug $0 ("Sending queued Telegram message failed.");
:set AllDone false;
@@ -75,7 +76,6 @@
:global EitherOr;
:global IfThenElse;
:global LogPrint;
- :global ParseJson;
:global SymbolForNotification;
:global UrlEncode;
@@ -144,7 +144,7 @@
http-data=("chat_id=" . $ChatId . "&disable_notification=" . ($Notification->"silent") . \
"&reply_to_message_id=" . ($Notification->"replyto") . "&disable_web_page_preview=true" . \
"&parse_mode=MarkdownV2&text=" . [ $UrlEncode $Text ]) as-value ]->"data");
- :set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
+ :set ($TelegramMessageIDs->[ :tostr ([ :deserialize from=json value=$Data ]->"result"->"message_id") ]) 1;
} on-error={
$LogPrint info $0 ("Failed sending telegram notification! Queuing...");