merge pushover PR

This commit is contained in:
belgotux
2023-01-09 00:01:57 +01:00
parent 9f0d4d3f9f
commit 6f16022b45
3 changed files with 47 additions and 4 deletions
+8 -1
View File
@@ -36,4 +36,11 @@ telegramProviderApi='https://api.telegram.org'
telegramAccessToken='' telegramAccessToken=''
telegramChatID='' telegramChatID=''
telegramSubject="UPS event $argument" #subject sent by telegram telegramSubject="UPS event $argument" #subject sent by telegram
telegramMessage="$bodyDefault" #body message sent by telegram telegramMessage="$bodyDefault" #body message sent by telegram
#--- Data for Pushover ---#
pushoverProviderApi='https://api.pushover.net/1/messages.json'
pushoverAppToken='xxxxxxxxxxxxxxxxxxxxxxxxxxxx' #ApplicationToken
pushoverUserkey='xxxxxxxxxxxxxxxxxxxxxxxxxxxx' #UserKey
pushoverSubject="UPS event $argument" #subject sent by Pushover
pushoverMessage="$bodyDefault" #body message sent by Pushover
+8 -1
View File
@@ -53,6 +53,7 @@ ONLINE)
writeLog writeLog
sendMail "$subjectMail" "$text" sendMail "$subjectMail" "$text"
#sendPushBullet "$pushbulletSubject" "$text" #sendPushBullet "$pushbulletSubject" "$text"
#sendPushover "$pushoverSubject" "$text"
sendTelegram "$text" "$telegramSubject" sendTelegram "$text" "$telegramSubject"
;; ;;
@@ -61,6 +62,7 @@ ONBATT)
writeLog writeLog
#sendMail "$subjectMail" "$text" #sendMail "$subjectMail" "$text"
#sendPushBullet "$pushbulletSubject" "$text" #sendPushBullet "$pushbulletSubject" "$text"
#sendPushover "$pushoverSubject" "$text"
emoji=$(echo -e "\xE2\x9A\xA0") emoji=$(echo -e "\xE2\x9A\xA0")
sendTelegram "$text" "$telegramSubject" "$emoji" sendTelegram "$text" "$telegramSubject" "$emoji"
# sendSms "$text" # sendSms "$text"
@@ -72,6 +74,7 @@ LOWBATT)
writeLog writeLog
#sendMail "$subjectMail" "$text" #sendMail "$subjectMail" "$text"
#sendPushBullet "$pushbulletSubject" "$text" #sendPushBullet "$pushbulletSubject" "$text"
#sendPushover "$pushoverSubject" "$text"
emoji=$(echo -e "\xF0\x9F\x94\xA5") emoji=$(echo -e "\xF0\x9F\x94\xA5")
sendTelegram "$text" "$telegramSubject" "$emoji" sendTelegram "$text" "$telegramSubject" "$emoji"
# sendSms "$text" # sendSms "$text"
@@ -83,6 +86,7 @@ FSD)
writeLog writeLog
#sendMail "$subjectMail" "$text" #sendMail "$subjectMail" "$text"
#sendPushBullet "$pushbulletSubject" "$text" #sendPushBullet "$pushbulletSubject" "$text"
#sendPushover "$pushoverSubject" "$text"
emoji=$(echo -e "\xE2\x9A\xA0") emoji=$(echo -e "\xE2\x9A\xA0")
sendTelegram "$text" "$telegramSubject" "$emoji" sendTelegram "$text" "$telegramSubject" "$emoji"
# sendSms "$text" # sendSms "$text"
@@ -94,6 +98,7 @@ SHUTDOWN)
writeLog writeLog
#sendMail "$subjectMail" "$text" #sendMail "$subjectMail" "$text"
#sendPushBullet "$pushbulletSubject" "$text" #sendPushBullet "$pushbulletSubject" "$text"
#sendPushover "$pushoverSubject" "$text"
emoji=$(echo -e "\xF0\x9F\x94\xA5") emoji=$(echo -e "\xF0\x9F\x94\xA5")
sendTelegram "$text" "$telegramSubject" "$emoji" sendTelegram "$text" "$telegramSubject" "$emoji"
# sendSms "$text" # sendSms "$text"
@@ -103,6 +108,7 @@ COMMOK|COMMBAD|REPLBATT|NOCOMM)
writeLog writeLog
#sendMail #sendMail
#sendPushBullet #sendPushBullet
#sendPushover "$pushoverSubject" "$text"
sendTelegram "$text" "$telegramSubject" sendTelegram "$text" "$telegramSubject"
# sendSms # sendSms
;; ;;
@@ -116,7 +122,8 @@ SERVERONLINE)
rm -f $powerdownflag && \ rm -f $powerdownflag && \
writeLog && \ writeLog && \
sendMail "$subjectMail" "$text" sendMail "$subjectMail" "$text"
sendPushBullet "$pushbulletSubject" "$text" #sendPushBullet "$pushbulletSubject" "$text"
#sendPushover "$pushoverSubject" "$text"
sendTelegram "$text" "$telegramSubject" sendTelegram "$text" "$telegramSubject"
fi fi
;; ;;
+31 -2
View File
@@ -86,8 +86,8 @@ function sendPushBullet {
#var verification #var verification
if [ "$pushbulletProviderApi" == "" ] || [ "$pushbulletAccessToken" == "" ] ; then if [ "$pushbulletProviderApi" == "" ] || [ "$pushbulletAccessToken" == "" ] ; then
echo "Can't sen push notification without complete variables for PushBullet" 1>&2 echo "Can't send push notification without complete variables for PushBullet" 1>&2
addLog "Can't sen push notification without complete variables for PushBullet" addLog "Can't send push notification without complete variables for PushBullet"
return 1 return 1
fi fi
@@ -125,4 +125,33 @@ function sendTelegram {
if [ $returnCurl -ne 0 ] ; then cat $tempfile ; fi if [ $returnCurl -ne 0 ] ; then cat $tempfile ; fi
rm $tempfile rm $tempfile
return $returnCurl return $returnCurl
}
function sendPushover {
#replace default mesg
if [ "$1" != "" ] ; then
subjectPushover=$1
fi
if [ "$2" != "" ] ; then
textPushover=$2
fi
#var verification
if [ "$pushoverProviderApi" == "" ] || [ "$pushoverAppToken" == "" ] || [ "$pushoverUserkey" == "" ] ; then
echo "Can't send push notification without complete variables for Pushover" 1>&2
addLog "Can't send push notification without complete variables for Pushover"
return 1
fi
tempfile=$(mktemp --suffix '.nutNotifyPushOver')
curl -s \
--form-string "token=$pushoverAppToken" \
--form-string "user=$pushoverUserkey" \
--form-string "title=$subjectPushover" \
--form-string "message=$textPushover" \
$pushoverProviderApi
returnCurl=$?
if [ $returnCurl -ne 0 ] ; then cat $tempfile ; fi
rm $tempfile
return $returnCurl
} }