sms-forward: pass phone number and message to hook

These are available as $Phone and $Message in hook.
This commit is contained in:
Christian Hesse 2023-10-11 10:03:48 +02:00
parent f6e65dd68c
commit 5fbf584d4c
2 changed files with 4 additions and 2 deletions

View file

@ -40,7 +40,8 @@ The configuration goes to `global-config-overlay`, this is the only parameter:
* `SmsForwardHooks`: an array with pre-defined hooks, where each hook consists * `SmsForwardHooks`: an array with pre-defined hooks, where each hook consists
of `match` (which is matched against the received message), `allowed-number` of `match` (which is matched against the received message), `allowed-number`
(which is matched against the sending phone number or name) and `command`. (which is matched against the sending phone number or name) and `command`.
For `match` and `allowed-number` regular expressions are supported. For `match` and `allowed-number` regular expressions are supported. Actual
phone number (`$Phone`) and message (`$Message`) are available for the hook.
> **Info**: Copy relevant configuration from > **Info**: Copy relevant configuration from
> [`global-config`](../global-config.rsc) (the one without `-overlay`) to > [`global-config`](../global-config.rsc) (the one without `-overlay`) to

View file

@ -58,7 +58,8 @@ $WaitFullyConnected;
$LogPrintExit2 info $0 ("Running hook '" . $Hook->"match" . "': " . \ $LogPrintExit2 info $0 ("Running hook '" . $Hook->"match" . "': " . \
$Hook->"command") false; $Hook->"command") false;
:do { :do {
[ :parse ($Hook->"command") ]; :local Command [ :parse ($Hook->"command") ];
$Command Phone=$Phone Message=($SmsVal->"message");
:set Messages ($Messages . "\n\nRan hook '" . $Hook->"match" . "':\n" . \ :set Messages ($Messages . "\n\nRan hook '" . $Hook->"match" . "':\n" . \
$Hook->"command"); $Hook->"command");
} on-error={ } on-error={