-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathwebhook.sh
More file actions
38 lines (35 loc) · 1.21 KB
/
webhook.sh
File metadata and controls
38 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Function to generate JSON data for the Discord message
# Webpage for COLOR-Calculation - https://www.spycolor.com/
# IMPORTANT: Dont use Hex-Colors! Go to the page search for the Hex-Color.
# After that add the DECIMAL-Represenetation to the color field or it will break!
generate_post_data() {
cat <<EOF
{
"content": "",
"embeds": [{
"title": "$1",
"description": "$2",
"color": "$3"
}]
}
EOF
}
# Function to send a notification to a webhook
send_webhook_notification() {
if [ ${WEBHOOK_ENABLED:false} == "true" ]; then
local title="$1"
local description="$2"
local color="$3"
# Debug Curl
#curl --ssl-no-revoke -H "Content-Type: application/json" -X POST -d "$(generate_post_data "$title" "$description" "$color")" "$WEBHOOK_URL"
# Prod Curl
curl --silent --ssl-no-revoke -H "Content-Type: application/json" -X POST -d "$(generate_post_data "$title" "$description" "$color")" "$WEBHOOK_URL"
fi
}
#Aliases to use in scripts
send_start_notification() {
send_webhook_notification "$WEBHOOK_START_TITLE" "$WEBHOOK_START_DESCRIPTION" "$WEBHOOK_START_COLOR"
}
send_stop_notification() {
send_webhook_notification "$WEBHOOK_STOP_TITLE" "$WEBHOOK_STOP_DESCRIPTION" "$WEBHOOK_STOP_COLOR"
}