Skip to content

Commit

Permalink
Merge 96c804f into ecfeee9
Browse files Browse the repository at this point in the history
  • Loading branch information
mike325 committed May 3, 2019
2 parents ecfeee9 + 96c804f commit 0099c83
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.rst
Expand Up @@ -393,6 +393,17 @@ Required parameters:

For more info, see _`ntfy-webpush` <https://github.com/dschep/ntfy-webpush>`_

`Gotify <https://gotify.net>`_ - ``gotify``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Required parameter:
* ``url`` - The url of the gotify server
* ``access_token`` - Your Gotify App access token

Optional parameters:
* ``extras`` - Additional data in json format sent along the message
* ``priority`` - integer

For more info, see _`gotify` <https://gotify.net/docs>`_

3rd party backends
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -453,3 +464,4 @@ Contributors
- `webworxshop <https://github.com/webworxshop>`_ - Rocket.Chat support
- `rhabbachi <https://github.com/rhabbachi>`_ - transient option in Linux desktop notifications
- `Half-Shot <https://github.com/Half-Shot>`_ - Matrix support
- `Mike325 <https://github.com/Mike325>`_ - Gotify support
45 changes: 45 additions & 0 deletions ntfy/backends/gotify.py
@@ -0,0 +1,45 @@
import requests
import json

from ..config import USER_AGENT

GOTIFY_MSG_URL = '{url}/message?token={token}'


def notify(title,
message,
url,
access_token,
extras=None,
priority=None,
retcode=None):
"""
Required parameter:
* ``url`` - The url of the gotify server
* ``access_token`` - Your Gotify App access token
Optional parameters:
* ``extras`` - Additional data in json format sent along the message
* ``priority`` - integer
For more info, see: https://gotify.net/docs
"""

data = {
'title': title,
'message': message,
}

if priority is not None:
data['priority'] = priority

if extras is not None:
data['extras'] = json.load(extras)

headers = {'User-Agent': USER_AGENT}

resp = requests.post(GOTIFY_MSG_URL.format(url=url, token=access_token),
json=data,
headers=headers)

resp.raise_for_status()

0 comments on commit 0099c83

Please sign in to comment.