feature configure method by the config file

This commit is contained in:
belgotux
2023-01-15 23:10:00 +01:00
parent f6f02877e6
commit d1705d3af1
3 changed files with 82 additions and 37 deletions
+51
View File
@@ -154,4 +154,55 @@ function sendPushover {
if [ $returnCurl -ne 0 ] ; then cat $tempfile ; fi
rm $tempfile
return $returnCurl
}
function conditionalNotification {
local event=$1
local text=$2
local emoji=$3
case "$event" in
ONLINE)
method=${methodOnline[*]}
;;
ONBATT)
method=${methodOnbatt[*]}
;;
LOWBATT)
method=${methodLowbatt[*]}
;;
FSD)
method=${methodFsd[*]}
;;
SHUTDOWN)
method=${methodShutdown[*]}
;;
COMMOK|COMMBAD|REPLBATT|NOCOMM)
method=${methodComm[*]}
;;
SERVERONLINE)
method=${methodServerOnline[*]}
;;
*)
echo "Error : this event is not managed" 1>&2
;;
esac
echo "${method[*]}"
if [[ " ${method[*]} " =~ " mail " ]] ; then
sendMail "$subjectMail" "$text"
fi
if [[ " ${method[*]} " =~ " pushbullet " ]] ; then
sendPushBullet "$pushbulletSubject" "$text"
fi
if [[ " ${method[*]} " =~ " pushover " ]] ; then
sendPushover "$pushoverSubject" "$text"
fi
if [[ " ${method[*]} " =~ " telegram " ]] ; then
sendTelegram "$text" "$telegramSubject" "$emoji"
fi
if [[ " ${method[*]} " =~ " sms " ]] ; then
sendSms "$text"
fi
}