mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
basic support for pushsafer.com
Currently, only a message with the link to the pi.alert page is sent. I am still struggling with the display of more detailed information.
This commit is contained in:
@@ -27,6 +27,8 @@ import socket
|
|||||||
import io
|
import io
|
||||||
import smtplib
|
import smtplib
|
||||||
import csv
|
import csv
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -1359,6 +1361,11 @@ def email_reporting ():
|
|||||||
print (' Skip mail...')
|
print (' Skip mail...')
|
||||||
else :
|
else :
|
||||||
print (' No changes to report...')
|
print (' No changes to report...')
|
||||||
|
if REPORT_PUSHSAFER :
|
||||||
|
print (' Sending report by PUSHSAFER...')
|
||||||
|
send_pushsafer (mail_text)
|
||||||
|
else :
|
||||||
|
print (' Skip PUSHSAFER...')
|
||||||
|
|
||||||
|
|
||||||
# Clean Pending Alert Events
|
# Clean Pending Alert Events
|
||||||
@@ -1376,6 +1383,27 @@ def email_reporting ():
|
|||||||
sql_connection.commit()
|
sql_connection.commit()
|
||||||
closeDB()
|
closeDB()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def send_pushsafer (_Text):
|
||||||
|
url = 'https://www.pushsafer.com/api'
|
||||||
|
post_fields = {
|
||||||
|
"t" : 'Pi.Alert Message',
|
||||||
|
"m" : 'Something has changed',
|
||||||
|
"s" : 11,
|
||||||
|
"v" : 3,
|
||||||
|
"i" : 148,
|
||||||
|
"c" : '#ef7f7f',
|
||||||
|
"d" : 'a',
|
||||||
|
"u" : REPORT_DASHBOARD_URL,
|
||||||
|
"ut" : 'Open Pi.Alert',
|
||||||
|
"k" : PUSHSAFER_TOKEN,
|
||||||
|
}
|
||||||
|
|
||||||
|
request = Request(url, urlencode(post_fields).encode())
|
||||||
|
json = urlopen(request).read().decode()
|
||||||
|
# print(json)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
def format_report_section (pActive, pSection, pTable, pText, pHTML):
|
def format_report_section (pActive, pSection, pTable, pText, pHTML):
|
||||||
global mail_text
|
global mail_text
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ REPORT_FROM = 'Pi.Alert <' + SMTP_USER +'>'
|
|||||||
REPORT_TO = 'user@gmail.com'
|
REPORT_TO = 'user@gmail.com'
|
||||||
REPORT_DEVICE_URL = 'http://pi.alert/deviceDetails.php?mac='
|
REPORT_DEVICE_URL = 'http://pi.alert/deviceDetails.php?mac='
|
||||||
|
|
||||||
|
REPORT_PUSHSAFER = False
|
||||||
|
REPORT_DASHBOARD_URL = ''
|
||||||
|
PUSHSAFER_TOKEN = 'ApiKey'
|
||||||
|
|
||||||
# QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip'
|
# QUERY_MYIP_SERVER = 'https://diagnostic.opendns.com/myip'
|
||||||
QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'
|
QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'
|
||||||
DDNS_ACTIVE = False
|
DDNS_ACTIVE = False
|
||||||
|
|||||||
Reference in New Issue
Block a user