forked from daghaian/nzbthrottle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification.py
28 lines (26 loc) · 1.06 KB
/
notification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import apprise
import json
import logging
import sys
class NotificationClient(object):
def __init__(self):
self._logger = logging.getLogger()
try:
with open("./config.json") as w:
self._logger.debug("Loading Notification Data from config.json")
cfg = json.load(w)
self._logger.debug("Notification Data loaded successfully" + str(cfg))
self._notifier = apprise.Apprise(asset=apprise.AppriseAsset(
image_url_mask="https://avatars3.githubusercontent.com/u/3368377?s=200&v=4",
default_extension=".jpeg"))
for k,v in cfg['notifications'].items():
if(v['enabled'] == True):
self._notifier.add(v['url'])
except Exception as e:
self._logger.exception("Problem encountered when creating Notification object")
sys.exit(1)
def notify(self,message):
self._notifier.notify(
title='NZBThrottle Notification',
body=message
)