diff --git a/README.rst b/README.rst index 7f58e9a..3436401 100644 --- a/README.rst +++ b/README.rst @@ -81,6 +81,7 @@ Extras * Telegram support requires installing as ``ntfy[telegram]`` * Instapush support requires installing as ``ntfy[instapush]`` * Slack support requires installing as ``ntfy[slack]`` + * Simplepush support requires installing as ``ntfy[simplepush]`` To install multiple extras, separate with commas: e.g., ``ntfy[pid,emjoi]``. @@ -157,11 +158,14 @@ Optional parameters: `Simplepush `_ - ``simplepush`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Requires extras, install like this: pip install ntfy[simplepush]. + Required parameter: * ``key`` - Your Simplepush key, created by installing the Android App (no registration required) at https://simplepush.io Optional parameters: - * ``event`` - sets ringtone and vibration pattern for incoming notifications (can be defined in the simplepush app) + * ``password`` - password for end-to-end encryption (has to be also defined in the app) + * ``event`` - identifier for ringtone and vibration pattern for incoming notifications (can be defined in the simplepush app) XMPP - ``xmpp`` ~~~~~~~~~~~~~~~ diff --git a/ntfy/backends/simplepush.py b/ntfy/backends/simplepush.py index cc77db3..d16c7bb 100644 --- a/ntfy/backends/simplepush.py +++ b/ntfy/backends/simplepush.py @@ -1,4 +1,5 @@ import requests +from simplepush import generate_payload from ..config import USER_AGENT @@ -7,6 +8,7 @@ def notify(title, message, key, event=None, + password=None, retcode=None): """ Required paramter: @@ -14,17 +16,12 @@ def notify(title, installing the Android App (https://simplepush.io) Optional parameters: + * ``password`` - password for end-to-end encryption (can + be set in the app) * ``event`` - use custom ringtones and vibration patterns """ - data = { - 'title': title if len(title) <= 20 else title[:19] + u'\u2026', - 'msg': message, - 'key': key - } - - if event: - data['event'] = event + data = generate_payload(key, title if len(title) <= 200 else title[:199] + u'\u2026', message, event, password) headers = {'User-Agent': USER_AGENT} diff --git a/setup.py b/setup.py index 0c57209..8091fed 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ 'emoji': ['emoji'], 'pid':['psutil'], 'slack':['slacker'], + 'simplepush':['simplepush'], } test_deps = ['mock', 'sleekxmpp', 'emoji', 'psutil']