Skip to content

Commit 593effe

Browse files
committed
Add rocketchat_token backend
1 parent 698333c commit 593effe

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ htmlcov
88
*.orig
99
.coverage
1010
cover
11+
.venv/

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,16 @@ Required parameters:
376376
* ``password`` - login password
377377
* ``room`` - room/channel name to post in
378378

379+
`Rocket.Chat <https://rocket.chat>`_ using tokens - ``rocketchat_token``
380+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381+
Does not require any extras but you must generate an "personal access token": https://developer.rocket.chat/api/rest-api/personal-access-tokens
382+
383+
Required parameters:
384+
* ``url`` - URL of your Rocket.Chat instance
385+
* ``user_id`` - login username
386+
* ``auth_token`` - login password
387+
* ``channel`` - room/channel name to post in
388+
379389
`Matrix.org <https://matrix.org>`_ - ``matrix``
380390
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381391
Requires extras, install like this: ``pip install ntfy[matrix]``.

ntfy/backends/rocketchat_token.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import requests
2+
3+
4+
def notify(title, message, url, user_id, auth_token, channel, **kwargs):
5+
requests.post(
6+
url,
7+
headers={
8+
"X-Auth-Token": auth_token,
9+
"X-User-Id": user_id,
10+
},
11+
json={
12+
"text": "{0}\n{1}".format(title, message),
13+
"channel": channel,
14+
},
15+
)

0 commit comments

Comments
 (0)