Add priorty to pushover notifications

pull/54/head
Mitchell Klijs 7 years ago
parent da47720ce6
commit d3da1d02ad

@ -259,7 +259,8 @@ You can repeat this process for as many users as you like.
"pushover": { "pushover": {
"service": "pushover", "service": "pushover",
"app_token": "", "app_token": "",
"user_token": "" "user_token": "",
"priority": 0
}, },
"slack": { "slack": {
"service": "slack", "service": "slack",
@ -564,7 +565,8 @@ Currently, only Pushover and Slack are supported. More will be added later.
"pushover": { "pushover": {
"service": "pushover", "service": "pushover",
"app_token": "", "app_token": "",
"user_token": "" "user_token": "",
"priority": 0
}, },
"slack": { "slack": {
"service": "slack", "service": "slack",
@ -582,6 +584,8 @@ Currently, only Pushover and Slack are supported. More will be added later.
`app_token` and `user_token` - retrieve from Pushover.net. `app_token` and `user_token` - retrieve from Pushover.net.
You can specify a priority for the messages send via Pushover using the priority key. It can be any Pushover priority value (https://pushover.net/api#priority).
_Note: The key name (i.e the name right under notifications) can be anything, but the `"service":` must be exactly `"pushover"`._ _Note: The key name (i.e the name right under notifications) can be anything, but the `"service":` must be exactly `"pushover"`._

@ -8,9 +8,10 @@ log = logger.get_logger(__name__)
class Pushover: class Pushover:
NAME = "Pushover" NAME = "Pushover"
def __init__(self, app_token, user_token): def __init__(self, app_token, user_token, priority=0):
self.app_token = app_token self.app_token = app_token
self.user_token = user_token self.user_token = user_token
self.priority = priority
log.debug("Initialized Pushover notification agent") log.debug("Initialized Pushover notification agent")
def send(self, **kwargs): def send(self, **kwargs):
@ -23,7 +24,8 @@ class Pushover:
payload = { payload = {
'token': self.app_token, 'token': self.app_token,
'user': self.user_token, 'user': self.user_token,
'message': kwargs['message'] 'message': kwargs['message'],
'priority': self.priority,
} }
resp = requests.post('https://api.pushover.net/1/messages.json', data=payload, timeout=30) resp = requests.post('https://api.pushover.net/1/messages.json', data=payload, timeout=30)
return True if resp.status_code == 200 else False return True if resp.status_code == 200 else False

Loading…
Cancel
Save