From 4d0425724065c3832caabe874d54c012a22aa406 Mon Sep 17 00:00:00 2001 From: Vasyl Gnatiuk Date: Wed, 19 Oct 2022 20:54:09 -0400 Subject: [PATCH 1/2] Add Telegram notification --- cloudflare-template.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cloudflare-template.sh b/cloudflare-template.sh index 454c9db..2f52989 100644 --- a/cloudflare-template.sh +++ b/cloudflare-template.sh @@ -12,7 +12,8 @@ sitename="" # Title of site "Example Sit slackchannel="" # Slack Channel #example slackuri="" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx" discorduri="" # URI for Discord WebHook "https://discordapp.com/api/webhooks/xxxxx" - +telegramtoken="" # Telegram bot API Token +telegramchatid="" # Telegram Chat ID ########################################### ## Check if we have a public IP @@ -103,6 +104,12 @@ case "$update" in "content" : "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')." }' $discorduri fi + if [[ $telegramtoken != "" ]] && [[ $telegramchatid != "" ]]; then + curl -H 'Content-Type: application/json' -X POST \ + --data-raw '{ + "chat_id": "'$telegramchatid'", "text": "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip').", "disable_notification": true + }' https://api.telegram.org/bot$telegramtoken/sendMessage + fi exit 1;; *) logger "DDNS Updater: $ip $record_name DDNS updated." @@ -119,5 +126,11 @@ case "$update" in "content" : "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'" }' $discorduri fi + if [[ $telegramtoken != "" ]] && [[ $telegramchatid != "" ]]; then + curl -H 'Content-Type: application/json' -X POST \ + --data-raw '{ + "chat_id": "'$telegramchatid'", "text": "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'", "disable_notification": true + }' https://api.telegram.org/bot$telegramtoken/sendMessage + fi exit 0;; esac From 080b948051d730728f7a00b12327c60538ff3646 Mon Sep 17 00:00:00 2001 From: Vasyl Gnatiuk Date: Wed, 19 Oct 2022 21:26:08 -0400 Subject: [PATCH 2/2] Remove Telegram silent notifications --- cloudflare-template.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudflare-template.sh b/cloudflare-template.sh index 2f52989..45be821 100644 --- a/cloudflare-template.sh +++ b/cloudflare-template.sh @@ -107,7 +107,7 @@ case "$update" in if [[ $telegramtoken != "" ]] && [[ $telegramchatid != "" ]]; then curl -H 'Content-Type: application/json' -X POST \ --data-raw '{ - "chat_id": "'$telegramchatid'", "text": "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip').", "disable_notification": true + "chat_id": "'$telegramchatid'", "text": "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')." }' https://api.telegram.org/bot$telegramtoken/sendMessage fi exit 1;; @@ -129,7 +129,7 @@ case "$update" in if [[ $telegramtoken != "" ]] && [[ $telegramchatid != "" ]]; then curl -H 'Content-Type: application/json' -X POST \ --data-raw '{ - "chat_id": "'$telegramchatid'", "text": "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'", "disable_notification": true + "chat_id": "'$telegramchatid'", "text": "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'" }' https://api.telegram.org/bot$telegramtoken/sendMessage fi exit 0;;