diff --git a/nutNotifyFct.sh b/nutNotifyFct.sh index 8100589..560db75 100644 --- a/nutNotifyFct.sh +++ b/nutNotifyFct.sh @@ -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 -} \ No newline at end of file +}