Update nutNotifyFct.sh

Add Discord support
This commit is contained in:
NeoPlayer13
2023-08-06 11:16:07 -05:00
committed by GitHub
parent f4155cb8dc
commit 6d9c18c44a
+28 -1
View File
@@ -156,6 +156,33 @@ function sendPushover {
return $returnCurl
}
function sendDiscord {
#replace default mesg
if [ "$2" != "" ] ; then
textDiscord="$2"
fi
#var verification
if [ "$discordWebhookUrl" == "" ]; then
echo "Can't send message without a Discord webhook URL" 1>&2
addLog "Can't send message without a Discord webhook URL"
return 1
fi
tempjson=$(mktemp --suffix '.nutNotifyDiscord')
payload="{
\"content\": \"$message\"
}"
curl -s -H "Content-Type: application/json" -d "$payload" "$discordWebhookUrl" > $tempjson
returnCurl=$?
if [ $returnCurl -ne 0 ]; then
cat $tempjson
fi
rm $tempjson
return $returnCurl
}
function conditionalNotification {
local event=$1
local text=$2
@@ -205,4 +232,4 @@ function conditionalNotification {
sendSms "$text"
fi
}
}