2024-10-07 21:31:33 +02:00
|
|
|
### DISCLAIMER: This is a third party addition to dockcheck - best effort testing.
|
2025-06-24 09:16:48 -04:00
|
|
|
NOTIFY_DISCORD_VERSION="v0.4"
|
2024-10-07 21:31:33 +02:00
|
|
|
#
|
|
|
|
|
# Required receiving services must already be set up.
|
2025-05-29 16:43:34 -04:00
|
|
|
# Leave (or place) this file in the "notify_templates" subdirectory within the same directory as the main dockcheck.sh script.
|
|
|
|
|
# If you instead wish make your own modifications, make a copy in the same directory as the main dockcheck.sh script.
|
|
|
|
|
# Do not modify this file directly within the "notify_templates" subdirectory. Set DISCORD_WEBHOOK_URL in your dockcheck.config file.
|
2024-10-07 21:31:33 +02:00
|
|
|
|
2025-05-25 12:26:13 -04:00
|
|
|
if [[ -z "${DISCORD_WEBHOOK_URL:-}" ]]; then
|
|
|
|
|
printf "Discord notification channel enabled, but required configuration variables are missing. Discord notifications will not be sent.\n"
|
2025-02-09 22:01:08 +01:00
|
|
|
|
2025-05-25 12:26:13 -04:00
|
|
|
remove_channel discord
|
|
|
|
|
fi
|
2025-02-09 22:01:08 +01:00
|
|
|
|
2025-05-25 12:26:13 -04:00
|
|
|
trigger_discord_notification() {
|
|
|
|
|
DiscordWebhookUrl="${DISCORD_WEBHOOK_URL}" # e.g. DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/<token string>
|
2025-03-16 20:47:46 +01:00
|
|
|
|
2025-05-29 16:43:34 -04:00
|
|
|
JsonData=$( "$jqbin" -n \
|
|
|
|
|
--arg username "$FromHost" \
|
|
|
|
|
--arg body "$MessageBody" \
|
|
|
|
|
'{"username": $username, "content": $body}' )
|
|
|
|
|
|
2025-06-24 09:16:48 -04:00
|
|
|
curl -S -o /dev/null ${CurlArgs} -X POST -H "Content-Type: application/json" -d "$JsonData" "$DiscordWebhookUrl"
|
|
|
|
|
|
|
|
|
|
if [[ $? -gt 0 ]]; then
|
|
|
|
|
NotifyError=true
|
|
|
|
|
fi
|
2024-10-14 06:28:35 +02:00
|
|
|
}
|