diff --git a/.gitignore b/.gitignore index f9c3ec3..af7abfb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ htmlcov *.orig .coverage cover +.venv/ diff --git a/README.rst b/README.rst index a3d6789..02730e5 100644 --- a/README.rst +++ b/README.rst @@ -376,6 +376,16 @@ Required parameters: * ``password`` - login password * ``room`` - room/channel name to post in +`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 `_ - ``matrix`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Requires extras, install like this: ``pip install ntfy[matrix]``. diff --git a/ntfy/backends/rocketchat_token.py b/ntfy/backends/rocketchat_token.py new file mode 100644 index 0000000..c4a3fd2 --- /dev/null +++ b/ntfy/backends/rocketchat_token.py @@ -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, + }, + )