@@ -29,6 +29,7 @@ import smtplib
|
|||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
from base64 import b64encode
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -1488,14 +1489,26 @@ def email_reporting ():
|
|||||||
closeDB()
|
closeDB()
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
def send_ntfy (_Text):
|
def send_ntfy (_Text):
|
||||||
requests.post("{}/{}".format( NTFY_HOST,NTFY_TOPIC),
|
headers = {
|
||||||
data=_Text,
|
|
||||||
headers={
|
|
||||||
"Title": "Pi.Alert Notification",
|
"Title": "Pi.Alert Notification",
|
||||||
"Actions": "view, Open Dashboard, "+ REPORT_DASHBOARD_URL,
|
"Actions": "view, Open Dashboard, "+ REPORT_DASHBOARD_URL,
|
||||||
"Priority": "urgent",
|
"Priority": "urgent",
|
||||||
"Tags": "warning"
|
"Tags": "warning"
|
||||||
})
|
}
|
||||||
|
# if username and password are set generate hash and update header
|
||||||
|
if NTFY_USER and NTFY_PASSWORD:
|
||||||
|
# Generate hash for basic auth
|
||||||
|
usernamepassword = "{}:{}".format(NTFY_USER,NTFY_PASSWORD)
|
||||||
|
basichash = b64encode(bytes(NTFY_USER + ':' + NTFY_PASSWORD, "utf-8")).decode("ascii")
|
||||||
|
|
||||||
|
# add authorization header with hash
|
||||||
|
headers["Authorization"] = "Basic {}".format(basichash)
|
||||||
|
|
||||||
|
requests.post("{}/{}".format( NTFY_HOST,NTFY_TOPIC),
|
||||||
|
data=_Text,
|
||||||
|
headers=headers)
|
||||||
|
|
||||||
|
send_ntfy("selfhosted ntfy test")
|
||||||
|
|
||||||
def send_pushsafer (_Text):
|
def send_pushsafer (_Text):
|
||||||
url = 'https://www.pushsafer.com/api'
|
url = 'https://www.pushsafer.com/api'
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ APPRISE_URL = 'mailto://smtp-relay.sendinblue.com:587?from=user@gmai
|
|||||||
REPORT_NTFY = False
|
REPORT_NTFY = False
|
||||||
NTFY_HOST = 'https://ntfy.sh'
|
NTFY_HOST = 'https://ntfy.sh'
|
||||||
NTFY_TOPIC = 'replace_my_secure_topicname_91h889f28'
|
NTFY_TOPIC = 'replace_my_secure_topicname_91h889f28'
|
||||||
|
# set username and password if authentication is used https://docs.ntfy.sh/config/#users-and-roles
|
||||||
|
NTFY_USER = ''
|
||||||
|
NTFY_PASSWORD = ''
|
||||||
|
|
||||||
# PUSHSAFER (https://www.pushsafer.com/) settings
|
# PUSHSAFER (https://www.pushsafer.com/) settings
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user