Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rocketchat_token backend #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
},
)