mirror of https://github.com/l3uddz/traktarr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
import requests
|
|
|
|
from misc.log import logger
|
|
|
|
log = logger.get_logger(__name__)
|
|
|
|
|
|
class Pushover:
|
|
NAME = "Pushover"
|
|
|
|
def __init__(self, app_token, user_token, priority=0):
|
|
self.app_token = app_token
|
|
self.user_token = user_token
|
|
self.priority = priority
|
|
log.debug("Initialized Pushover notification agent")
|
|
|
|
def send(self, **kwargs):
|
|
if not self.app_token or not self.user_token:
|
|
log.error("You must specify an app_token and user_token when initializing this class")
|
|
return False
|
|
|
|
# send notification
|
|
try:
|
|
payload = {
|
|
'token': self.app_token,
|
|
'user': self.user_token,
|
|
'message': kwargs['message'],
|
|
'priority': self.priority,
|
|
}
|
|
resp = requests.post('https://api.pushover.net/1/messages.json', data=payload, timeout=30)
|
|
return resp.status_code == 200
|
|
|
|
except Exception:
|
|
log.exception("Error sending notification to %r", self.user_token)
|
|
return False
|