aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-28 22:43:18 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-04-01 22:45:35 +0200
commit29bcbc4db9d39573e8c8017e75eea4df7f603c2c (patch)
treeeb64e05707ae635510e08b80ce394e42f0d34cc7
parent7e5010a60853c946e6e73406031fe0e937bee8df (diff)
mod/notification-telegram: use :deserialize ...
... instead of $ParseJson. This requires RouterOS 7.13.
-rw-r--r--doc/mod/notification-telegram.md2
-rw-r--r--mod/notification-telegram.rsc8
2 files changed, 5 insertions, 5 deletions
diff --git a/doc/mod/notification-telegram.md b/doc/mod/notification-telegram.md
index cb326f0..159fda9 100644
--- a/doc/mod/notification-telegram.md
+++ b/doc/mod/notification-telegram.md
@@ -4,7 +4,7 @@ Send notifications via Telegram
[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network)
[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers)
-[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.12-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
+[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.13-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts)
[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
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...");