From 227151e189f465ea426dd11bb912ff818046ff8f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 5 Mar 2020 10:59:13 +0100 Subject: global-functions: $SendTelegram: invert condition --- global-functions | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'global-functions') diff --git a/global-functions b/global-functions index 1fb832a..c2727fc 100644 --- a/global-functions +++ b/global-functions @@ -438,16 +438,18 @@ :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=" . $ChatId . "&disable_notification=" . $Silent . \ - "&text=" . [ $UrlEncode ("[" . $Identity . "] " . $Subject . "\n\n" . $Message) ]); - } on-error={ - :log warning "Failed sending telegram notification!"; - } + :if ([ :len $TelegramTokenId ] = 0 || [ :len $ChatId ] = 0) do={ + :return; + } + + $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=" . $ChatId . "&disable_notification=" . $Silent . \ + "&text=" . [ $UrlEncode ("[" . $Identity . "] " . $Subject . "\n\n" . $Message) ]); + } on-error={ + :log warning "Failed sending telegram notification!"; } } -- cgit v1.2.3-70-g09d2