Add Telegram notification

This commit is contained in:
Vasyl Gnatiuk 2022-10-19 20:54:09 -04:00 committed by GitHub
parent 88c73e30f8
commit 4d04257240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -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