From 34db2e34db40867c97c87c6604cf8049a3b7e53b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 5 Mar 2020 10:39:34 +0100 Subject: global-functions: $SendTelegram: allow to override chatid This allows to send Telegram messages to different contact or group. Use something like this: /system scheduler add name=netwatch-notify interval=1m start-time=startup \ on-event=":global TelegramChatIdOverride \"-1234\"; / system script run netwatch-notify; :set TelegramChatIdOverride;" --- global-functions | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/global-functions b/global-functions index b9f3cc4..1fb832a 100644 --- a/global-functions +++ b/global-functions @@ -428,16 +428,22 @@ :global Identity; :global TelegramTokenId; :global TelegramChatId; + :global TelegramChatIdOverride; :global UrlEncode; :global CertificateAvailable; - :if ([ :len $TelegramTokenId ] > 0 && [ :len $TelegramChatId ] > 0) do={ + :local ChatId $TelegramChatId; + :if ([ :len $TelegramChatIdOverride ] > 0) do={ + :set ChatId $TelegramChatIdOverride; + } + + :if ([ :len $TelegramTokenId ] > 0 && [ :len $ChatId ] > 0) do={ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2"; :do { / tool fetch check-certificate=yes-without-crl output=none http-method=post \ ("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \ - http-data=("chat_id=" . $TelegramChatId . "&disable_notification=" . $Silent . \ + http-data=("chat_id=" . $ChatId . "&disable_notification=" . $Silent . \ "&text=" . [ $UrlEncode ("[" . $Identity . "] " . $Subject . "\n\n" . $Message) ]); } on-error={ :log warning "Failed sending telegram notification!"; -- cgit v1.2.3-54-g00ecf