Update nutNotifyFct.sh
Add Discord support
This commit is contained in:
+28
-1
@@ -156,6 +156,33 @@ function sendPushover {
|
|||||||
return $returnCurl
|
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 {
|
function conditionalNotification {
|
||||||
local event=$1
|
local event=$1
|
||||||
local text=$2
|
local text=$2
|
||||||
@@ -205,4 +232,4 @@ function conditionalNotification {
|
|||||||
sendSms "$text"
|
sendSms "$text"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user