aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-03-05 10:39:34 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-03-05 10:54:48 +0100
commit34db2e34db40867c97c87c6604cf8049a3b7e53b (patch)
treee164ca53b90613e971c66109d442a93302365c7f
parent71ae8cb75f7ffc4dd3a9672582157b60da12fd34 (diff)
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;"
-rw-r--r--global-functions10
1 files 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!";