Skip to content

Commit

Permalink
Add rocketchat_token backend
Browse files Browse the repository at this point in the history
  • Loading branch information
pmav99 committed May 24, 2022
1 parent 698333c commit 593effe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ htmlcov
*.orig
.coverage
cover
.venv/
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ Required parameters:
* ``password`` - login password
* ``room`` - room/channel name to post in

`Rocket.Chat <https://rocket.chat>`_ using tokens - ``rocketchat_token``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Does not require any extras but you must generate an "personal access token": https://developer.rocket.chat/api/rest-api/personal-access-tokens

Required parameters:
* ``url`` - URL of your Rocket.Chat instance
* ``user_id`` - login username
* ``auth_token`` - login password
* ``channel`` - room/channel name to post in

`Matrix.org <https://matrix.org>`_ - ``matrix``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Requires extras, install like this: ``pip install ntfy[matrix]``.
Expand Down
15 changes: 15 additions & 0 deletions ntfy/backends/rocketchat_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import requests


def notify(title, message, url, user_id, auth_token, channel, **kwargs):
requests.post(
url,
headers={
"X-Auth-Token": auth_token,
"X-User-Id": user_id,
},
json={
"text": "{0}\n{1}".format(title, message),
"channel": channel,
},
)

0 comments on commit 593effe

Please sign in to comment.