From 1f1e76b822689297faff56cfcbdd574da4a2bd9f Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Tue, 28 Mar 2023 15:55:48 +0200
Subject: [PATCH 0001/1562] sms-forward: drop workaround, add required RouterOS
---
doc/sms-forward.md | 2 ++
sms-forward.rsc | 13 ++-----------
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/doc/sms-forward.md b/doc/sms-forward.md
index 9dccaf3..bfab38d 100644
--- a/doc/sms-forward.md
+++ b/doc/sms-forward.md
@@ -3,6 +3,8 @@ Forward received SMS
[⬅️ Go back to main README](../README.md)
+
+
> ℹ️ **Info**: This script can not be used on its own but requires the base
> installation. See [main README](../README.md) for details.
diff --git a/sms-forward.rsc b/sms-forward.rsc
index e6ac9aa..542fe0d 100644
--- a/sms-forward.rsc
+++ b/sms-forward.rsc
@@ -4,6 +4,8 @@
# Anatoly Bubenkov
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
#
+# requires RouterOS, version=7.9beta4
+#
# forward SMS to e-mail
# https://git.eworm.de/cgit/routeros-scripts/about/doc/sms-forward.md
@@ -13,11 +15,9 @@
:global Identity;
:global SmsForwardHooks;
-:global SmsForwardWorkaround;
:global IfThenElse;
:global LogPrintExit2;
-:global RequiredRouterOS;
:global ScriptLock;
:global SendNotification2;
:global SymbolForNotification;
@@ -30,15 +30,6 @@ $ScriptLock $0;
$LogPrintExit2 warning $0 ("Receiving of SMS is not enabled.") true;
}
-:if ($SmsForwardWorkaround != true && \
- [ $RequiredRouterOS $0 "7.8" false ] = true && \
- [ $RequiredRouterOS $0 "7.9beta4" false ] = false) do={
- :local AutoErase [ /tool/sms/get auto-erase ];
- /tool/sms/set auto-erase=(!$AutoErase);
- /tool/sms/set auto-erase=$AutoErase;
- :set SmsForwardWorkaround true;
-}
-
$WaitFullyConnected;
:local Settings [ /tool/sms/get ];
From 3fe66c841392c8cbfa6d6514fe0b2f685911364a Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Tue, 2 May 2023 16:19:44 +0200
Subject: [PATCH 0002/1562] update list of contributors
---
CONTRIBUTIONS.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md
index efa418c..0213b45 100644
--- a/CONTRIBUTIONS.md
+++ b/CONTRIBUTIONS.md
@@ -28,6 +28,7 @@ Add yourself to the list,
* Christoph Boss (@Kampfwurst)
* Devin Dean (@dd2594gh)
* Evaldo Gardenal
+* Harold Schoemaker
* Hugo BV
* Klaus Michael Rübsam
* Linux-Schmie.de Michael Gisbers
From d586a5ab1975e7f06a43f816e3809753d9606cba Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Wed, 10 May 2023 13:28:51 +0200
Subject: [PATCH 0003/1562] daily-psk: simplify calculation
Use a named array, and drop the loop...
---
daily-psk.capsman.rsc | 12 +++---------
daily-psk.local.rsc | 12 +++---------
daily-psk.template.rsc | 12 +++---------
3 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc
index e589991..65a17d0 100644
--- a/daily-psk.capsman.rsc
+++ b/daily-psk.capsman.rsc
@@ -33,19 +33,13 @@ $WaitFullyConnected;
:global DailyPskSecrets;
- :local Months { "jan"; "feb"; "mar"; "apr"; "may"; "jun";
- "jul"; "aug"; "sep"; "oct"; "nov"; "dec" };
+ :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
+ "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
- :local Month [ :pick $Date 0 3 ];
+ :local Month ($Months->[ :pick $Date 0 3 ]);
:local Day [ :tonum [ :pick $Date 4 6 ] ];
:local Year [ :pick $Date 7 11 ];
- :for MIndex from=0 to=[ :len $Months ] do={
- :if ($Months->$MIndex = $Month) do={
- :set Month ($MIndex + 1);
- }
- }
-
:local A ((14 - $Month) / 12);
:local B ($Year - $A);
:local C ($Month + 12 * $A - 2);
diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc
index df17173..94991a7 100644
--- a/daily-psk.local.rsc
+++ b/daily-psk.local.rsc
@@ -33,19 +33,13 @@ $WaitFullyConnected;
:global DailyPskSecrets;
- :local Months { "jan"; "feb"; "mar"; "apr"; "may"; "jun";
- "jul"; "aug"; "sep"; "oct"; "nov"; "dec" };
+ :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
+ "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
- :local Month [ :pick $Date 0 3 ];
+ :local Month ($Months->[ :pick $Date 0 3 ]);
:local Day [ :tonum [ :pick $Date 4 6 ] ];
:local Year [ :pick $Date 7 11 ];
- :for MIndex from=0 to=[ :len $Months ] do={
- :if ($Months->$MIndex = $Month) do={
- :set Month ($MIndex + 1);
- }
- }
-
:local A ((14 - $Month) / 12);
:local B ($Year - $A);
:local C ($Month + 12 * $A - 2);
diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc
index 5f30ce3..e2a3d59 100644
--- a/daily-psk.template.rsc
+++ b/daily-psk.template.rsc
@@ -34,19 +34,13 @@ $WaitFullyConnected;
:global DailyPskSecrets;
- :local Months { "jan"; "feb"; "mar"; "apr"; "may"; "jun";
- "jul"; "aug"; "sep"; "oct"; "nov"; "dec" };
+ :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
+ "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
- :local Month [ :pick $Date 0 3 ];
+ :local Month ($Months->[ :pick $Date 0 3 ]);
:local Day [ :tonum [ :pick $Date 4 6 ] ];
:local Year [ :pick $Date 7 11 ];
- :for MIndex from=0 to=[ :len $Months ] do={
- :if ($Months->$MIndex = $Month) do={
- :set Month ($MIndex + 1);
- }
- }
-
:local A ((14 - $Month) / 12);
:local B ($Year - $A);
:local C ($Month + 12 * $A - 2);
From e7927e0eee62ea331e97c3e572b12a594eca14fd Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Wed, 10 May 2023 18:10:02 +0200
Subject: [PATCH 0004/1562] daily-psk: explicitly cast to num
---
daily-psk.capsman.rsc | 2 +-
daily-psk.local.rsc | 2 +-
daily-psk.template.rsc | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc
index 65a17d0..2bfb576 100644
--- a/daily-psk.capsman.rsc
+++ b/daily-psk.capsman.rsc
@@ -38,7 +38,7 @@ $WaitFullyConnected;
:local Month ($Months->[ :pick $Date 0 3 ]);
:local Day [ :tonum [ :pick $Date 4 6 ] ];
- :local Year [ :pick $Date 7 11 ];
+ :local Year [ :tonum [ :pick $Date 7 11 ] ];
:local A ((14 - $Month) / 12);
:local B ($Year - $A);
diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc
index 94991a7..5f4382f 100644
--- a/daily-psk.local.rsc
+++ b/daily-psk.local.rsc
@@ -38,7 +38,7 @@ $WaitFullyConnected;
:local Month ($Months->[ :pick $Date 0 3 ]);
:local Day [ :tonum [ :pick $Date 4 6 ] ];
- :local Year [ :pick $Date 7 11 ];
+ :local Year [ :tonum [ :pick $Date 7 11 ] ];
:local A ((14 - $Month) / 12);
:local B ($Year - $A);
diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc
index e2a3d59..7dd5c7e 100644
--- a/daily-psk.template.rsc
+++ b/daily-psk.template.rsc
@@ -39,7 +39,7 @@ $WaitFullyConnected;
:local Month ($Months->[ :pick $Date 0 3 ]);
:local Day [ :tonum [ :pick $Date 4 6 ] ];
- :local Year [ :pick $Date 7 11 ];
+ :local Year [ :tonum [ :pick $Date 7 11 ] ];
:local A ((14 - $Month) / 12);
:local B ($Year - $A);
From bafd71344d2d2c1523b0f3a34ac238a59fb46d27 Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Wed, 10 May 2023 13:44:11 +0200
Subject: [PATCH 0005/1562] global-functions: introduce $ParseDate
The extra indention is intended for a later change.
---
global-functions.rsc | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/global-functions.rsc b/global-functions.rsc
index 4ec5857..fa8b767 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -45,6 +45,7 @@
:global LogPrintExit2;
:global MkDir;
:global NotificationFunctions;
+:global ParseDate;
:global ParseKeyValueStore;
:global PrettyPrint;
:global RandomDelay;
@@ -682,6 +683,18 @@
:set NotificationFunctions ({});
}
+# parse the date and return a named array
+:set ParseDate do={
+ :local Date [ :tostr $1 ];
+
+ :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
+ "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
+
+ :return ({ "year"=[ :tonum [ :pick $Date 7 11 ] ];
+ "month"=($Months->[ :pick $Date 0 3 ]);
+ "day"=[ :tonum [ :pick $Date 4 6 ] ] });
+}
+
# parse key value store
:set ParseKeyValueStore do={
:local Source $1;
From 60f863871ca4ebe450011bdd0e6998eab6820fcd Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Wed, 10 May 2023 14:42:48 +0200
Subject: [PATCH 0006/1562] global-functions: $ParseDate: handle date in ISO
standard format
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This was introduced with RouterOS 7.10beta5...
https://xkcd.com/1179/ 😜
---
global-functions.rsc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/global-functions.rsc b/global-functions.rsc
index fa8b767..c2c01ea 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -687,12 +687,18 @@
:set ParseDate do={
:local Date [ :tostr $1 ];
+ :if ([ :pick $Date 4 5 ] != "-") do={
:local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
"jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
:return ({ "year"=[ :tonum [ :pick $Date 7 11 ] ];
"month"=($Months->[ :pick $Date 0 3 ]);
"day"=[ :tonum [ :pick $Date 4 6 ] ] });
+ }
+
+ :return ({ "year"=[ :tonum [ :pick $Date 0 4 ] ];
+ "month"=[ :tonum [ :pick $Date 5 7 ] ];
+ "day"=[ :tonum [ :pick $Date 8 10 ] ] });
}
# parse key value store
From 9069f71ee6168a651fd42f90b7aea309fefa260b Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Wed, 10 May 2023 13:48:46 +0200
Subject: [PATCH 0007/1562] daily-psk: use $ParseDate
---
daily-psk.capsman.rsc | 19 ++++++++-----------
daily-psk.local.rsc | 19 ++++++++-----------
daily-psk.template.rsc | 19 ++++++++-----------
3 files changed, 24 insertions(+), 33 deletions(-)
diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc
index 2bfb576..a24d761 100644
--- a/daily-psk.capsman.rsc
+++ b/daily-psk.capsman.rsc
@@ -33,21 +33,18 @@ $WaitFullyConnected;
:global DailyPskSecrets;
- :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
- "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
+ :global ParseDate;
- :local Month ($Months->[ :pick $Date 0 3 ]);
- :local Day [ :tonum [ :pick $Date 4 6 ] ];
- :local Year [ :tonum [ :pick $Date 7 11 ] ];
+ :set Date [ $ParseDate $Date ];
- :local A ((14 - $Month) / 12);
- :local B ($Year - $A);
- :local C ($Month + 12 * $A - 2);
- :local WeekDay (7000 + $Day + $B + ($B / 4) - ($B / 100) + ($B / 400) + ((31 * $C) / 12));
+ :local A ((14 - ($Date->"month")) / 12);
+ :local B (($Date->"year") - $A);
+ :local C (($Date->"month") + 12 * $A - 2);
+ :local WeekDay (7000 + ($Date->"day") + $B + ($B / 4) - ($B / 100) + ($B / 400) + ((31 * $C) / 12));
:set WeekDay ($WeekDay - (($WeekDay / 7) * 7));
- :return (($DailyPskSecrets->0->($Day - 1)) . \
- ($DailyPskSecrets->1->($Month - 1)) . \
+ :return (($DailyPskSecrets->0->(($Date->"day") - 1)) . \
+ ($DailyPskSecrets->1->(($Date->"month") - 1)) . \
($DailyPskSecrets->2->$WeekDay));
}
diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc
index 5f4382f..5e6e30f 100644
--- a/daily-psk.local.rsc
+++ b/daily-psk.local.rsc
@@ -33,21 +33,18 @@ $WaitFullyConnected;
:global DailyPskSecrets;
- :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
- "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
+ :global ParseDate;
- :local Month ($Months->[ :pick $Date 0 3 ]);
- :local Day [ :tonum [ :pick $Date 4 6 ] ];
- :local Year [ :tonum [ :pick $Date 7 11 ] ];
+ :set Date [ $ParseDate $Date ];
- :local A ((14 - $Month) / 12);
- :local B ($Year - $A);
- :local C ($Month + 12 * $A - 2);
- :local WeekDay (7000 + $Day + $B + ($B / 4) - ($B / 100) + ($B / 400) + ((31 * $C) / 12));
+ :local A ((14 - ($Date->"month")) / 12);
+ :local B (($Date->"year") - $A);
+ :local C (($Date->"month") + 12 * $A - 2);
+ :local WeekDay (7000 + ($Date->"day") + $B + ($B / 4) - ($B / 100) + ($B / 400) + ((31 * $C) / 12));
:set WeekDay ($WeekDay - (($WeekDay / 7) * 7));
- :return (($DailyPskSecrets->0->($Day - 1)) . \
- ($DailyPskSecrets->1->($Month - 1)) . \
+ :return (($DailyPskSecrets->0->(($Date->"day") - 1)) . \
+ ($DailyPskSecrets->1->(($Date->"month") - 1)) . \
($DailyPskSecrets->2->$WeekDay));
}
diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc
index 7dd5c7e..966a407 100644
--- a/daily-psk.template.rsc
+++ b/daily-psk.template.rsc
@@ -34,21 +34,18 @@ $WaitFullyConnected;
:global DailyPskSecrets;
- :local Months { "jan"=1; "feb"=2; "mar"=3; "apr"=4; "may"=5; "jun"=6;
- "jul"=7; "aug"=8; "sep"=9; "oct"=10; "nov"=11; "dec"=12 };
+ :global ParseDate;
- :local Month ($Months->[ :pick $Date 0 3 ]);
- :local Day [ :tonum [ :pick $Date 4 6 ] ];
- :local Year [ :tonum [ :pick $Date 7 11 ] ];
+ :set Date [ $ParseDate $Date ];
- :local A ((14 - $Month) / 12);
- :local B ($Year - $A);
- :local C ($Month + 12 * $A - 2);
- :local WeekDay (7000 + $Day + $B + ($B / 4) - ($B / 100) + ($B / 400) + ((31 * $C) / 12));
+ :local A ((14 - ($Date->"month")) / 12);
+ :local B (($Date->"year") - $A);
+ :local C (($Date->"month") + 12 * $A - 2);
+ :local WeekDay (7000 + ($Date->"day") + $B + ($B / 4) - ($B / 100) + ($B / 400) + ((31 * $C) / 12));
:set WeekDay ($WeekDay - (($WeekDay / 7) * 7));
- :return (($DailyPskSecrets->0->($Day - 1)) . \
- ($DailyPskSecrets->1->($Month - 1)) . \
+ :return (($DailyPskSecrets->0->(($Date->"day") - 1)) . \
+ ($DailyPskSecrets->1->(($Date->"month") - 1)) . \
($DailyPskSecrets->2->$WeekDay));
}
From 4254b01a32a965a1850c6dc5c669dca34a64a297 Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Mon, 15 May 2023 21:43:18 +0200
Subject: [PATCH 0008/1562] mod/notification-telegram: fix copy-and-paste error
---
mod/notification-telegram.rsc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc
index e59dbb2..0ab1aa0 100644
--- a/mod/notification-telegram.rsc
+++ b/mod/notification-telegram.rsc
@@ -37,7 +37,7 @@
("https://api.telegram.org/bot" . ($Message->"tokenid") . "/sendMessage") \
http-data=("chat_id=" . ($Message->"chatid") . \
"&disable_notification=" . ($Message->"silent") . \
- "&reply_to_message_id=" . ($Notification->"replyto") . \
+ "&reply_to_message_id=" . ($Message->"replyto") . \
"&disable_web_page_preview=true&parse_mode=" . ($Message->"parsemode") . \
"&text=" . ($Message->"text")) as-value;
:set ($TelegramQueue->$Id);
From 8284035ad8e945f70859c3a9a270058546d11cb6 Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Mon, 22 May 2023 09:51:23 +0200
Subject: [PATCH 0009/1562] doc/mod/notification-email: describe how to declare
functions...
... to use them in own scripts.
---
doc/mod/notification-email.md | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/doc/mod/notification-email.md b/doc/mod/notification-email.md
index 61798e6..2186777 100644
--- a/doc/mod/notification-email.md
+++ b/doc/mod/notification-email.md
@@ -44,8 +44,8 @@ Usage and invocation
There's nothing special to do. Every script or function sending a notification
will now send it to your e-mail account.
-But of course you can send notifications directly or use a function in your
-own scripts. Give it a try:
+But of course you can use the function to send notifications directly. Give
+it a try:
$SendEMail "Subject..." "Body..."
@@ -54,6 +54,12 @@ methods:
$SendNotification "Subject..." "Body..."
+To use the functions in your own scripts you have to declare them first.
+Place this before you call them:
+
+ :global SendEMail;
+ :global SendNotification;
+
See also
--------
From c0aeee3d3eb4abc006a3cfd4f57da7ab9f290e03 Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Mon, 22 May 2023 09:52:18 +0200
Subject: [PATCH 0010/1562] doc/mod/notification-matrix: describe how to
declare functions...
... to use them in own scripts.
---
doc/mod/notification-matrix.md | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/doc/mod/notification-matrix.md b/doc/mod/notification-matrix.md
index 6bb04b6..639fa98 100644
--- a/doc/mod/notification-matrix.md
+++ b/doc/mod/notification-matrix.md
@@ -90,8 +90,8 @@ Usage and invocation
There's nothing special to do. Every script or function sending a notification
will now send it to your Matrix account.
-But of course you can send notifications directly or use a function in your
-own scripts. Give it a try:
+But of course you can use the function to send notifications directly. Give
+it a try:
$SendMatrix "Subject..." "Body..."
@@ -100,6 +100,12 @@ methods:
$SendNotification "Subject..." "Body..."
+To use the functions in your own scripts you have to declare them first.
+Place this before you call them:
+
+ :global SendMatrix;
+ :global SendNotification;
+
See also
--------
From e9b7c7f7ed540e88006c626c205d9c60c50c1677 Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Mon, 22 May 2023 09:52:34 +0200
Subject: [PATCH 0011/1562] doc/mod/notification-telegram: describe how to
declare functions...
... to use them in own scripts.
---
doc/mod/notification-telegram.md | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/doc/mod/notification-telegram.md b/doc/mod/notification-telegram.md
index 5e6c1a0..7141fe9 100644
--- a/doc/mod/notification-telegram.md
+++ b/doc/mod/notification-telegram.md
@@ -53,8 +53,8 @@ Usage and invocation
There's nothing special to do. Every script or function sending a notification
will now send it to your Telegram account.
-But of course you can send notifications directly or use a function in your
-own scripts. Give it a try:
+But of course you can use the function to send notifications directly. Give
+it a try:
$SendTelegram "Subject..." "Body..."
@@ -63,6 +63,12 @@ methods:
$SendNotification "Subject..." "Body..."
+To use the functions in your own scripts you have to declare them first.
+Place this before you call them:
+
+ :global SendTelegram;
+ :global SendNotification;
+
See also
--------
From c2e7567c13bba80190ad5c2dd7c6ad7b025619e3 Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Tue, 23 May 2023 11:25:43 +0200
Subject: [PATCH 0012/1562] logo: rename SVG ids
---
logo.svg | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/logo.svg b/logo.svg
index 4812897..a30e04e 100644
--- a/logo.svg
+++ b/logo.svg
@@ -1,14 +1,14 @@
-
-