From d3da1d02ad83313b08524790ce59a9049a55b92c Mon Sep 17 00:00:00 2001 From: Mitchell Klijs Date: Wed, 30 May 2018 21:44:06 +0200 Subject: [PATCH] Add priorty to pushover notifications --- README.md | 8 ++++++-- notifications/pushover.py | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1c58e2e..1c6c8d0 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,8 @@ You can repeat this process for as many users as you like. "pushover": { "service": "pushover", "app_token": "", - "user_token": "" + "user_token": "", + "priority": 0 }, "slack": { "service": "slack", @@ -564,7 +565,8 @@ Currently, only Pushover and Slack are supported. More will be added later. "pushover": { "service": "pushover", "app_token": "", - "user_token": "" + "user_token": "", + "priority": 0 }, "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. +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"`._ diff --git a/notifications/pushover.py b/notifications/pushover.py index 9374dc1..35f8ddd 100644 --- a/notifications/pushover.py +++ b/notifications/pushover.py @@ -8,9 +8,10 @@ log = logger.get_logger(__name__) class 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.user_token = user_token + self.priority = priority log.debug("Initialized Pushover notification agent") def send(self, **kwargs): @@ -23,7 +24,8 @@ class Pushover: payload = { 'token': self.app_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) return True if resp.status_code == 200 else False