Skip to main content

Post a message to a matrix room with a simple HTTP POST

Project description

Matrix Webhook

Tests Lints Docker-Hub PyPI Code style: black codecov

Post a message to a matrix room with a simple HTTP POST

Install

python3 -m pip install matrix-webhook
# OR
docker pull nim65s/matrix-webhook

Start

Create a matrix user for the bot, make it join the rooms you want it to talk into, and launch it with the following arguments or environment variables:

python -m matrix_webhook -h
# OR
docker run --rm -it nim65s/matrix-webhook -h
usage: python -m matrix_webhook [-h] [-H HOST] [-P PORT] [-u MATRIX_URL] -i MATRIX_ID -p MATRIX_PW -k API_KEY [-v]

Configuration for Matrix Webhook.


optional arguments:
  -h, --help            show this help message and exit
  -H HOST, --host HOST  host to listen to. Default: `''`. Environment variable: `HOST`
  -P PORT, --port PORT  port to listed to. Default: 4785. Environment variable: `PORT`
  -u MATRIX_URL, --matrix-url MATRIX_URL
                        matrix homeserver url. Default: `https://matrix.org`. Environment variable: `MATRIX_URL`
  -i MATRIX_ID, --matrix-id MATRIX_ID
                        matrix user-id. Required. Environment variable: `MATRIX_ID`
  -p MATRIX_PW, --matrix-pw MATRIX_PW
                        matrix password. Required. Environment variable: `MATRIX_PW`
  -k API_KEY, --api-key API_KEY
                        shared secret to use this service. Required. Environment variable: `API_KEY`
  -v, --verbose         increment verbosity level

Dev

poetry install
# or python3 -m pip install --user markdown matrix-nio
python3 -m matrix_webhook

Prod

A docker-compose.yml is provided:

  • Use Traefik on the web docker network, eg. with proxyta.net
  • Put the configuration into a .env file
  • Configure your DNS for ${CHATONS_SERVICE:-matrixwebhook}.${CHATONS_DOMAIN:-localhost}
docker-compose up -d

Test / Usage

curl -d '{"text":"new contrib from toto: [44](http://radio.localhost/map/#44)", "key": "secret"}' \
  'http://matrixwebhook.localhost/!DPrUlnwOhBEfYwsDLh:matrix.org'

(or localhost:4785 without docker)

Test room

#matrix-webhook:tetaneutral.net](https://matrix.to/#/!DPrUlnwOhBEfYwsDLh:matrix.org?via=laas.fr&via=tetaneutral.net&via=aen.im)

Unit tests

docker-compose -f test.yml up --exit-code-from tests --force-recreate --build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matrix-webhook-3.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrix_webhook-3.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file matrix-webhook-3.1.0.tar.gz.

File metadata

  • Download URL: matrix-webhook-3.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.12.15-arch1-1

File hashes

Hashes for matrix-webhook-3.1.0.tar.gz
Algorithm Hash digest
SHA256 85aedfd65a9a5033a3b25b8203c7b3a730c867d3aedf261b67ceb4f350ce9c47
MD5 4c4f4d98fb5cf78822bd198a7f9ef953
BLAKE2b-256 bfc0c669dc5cfa71b2160d45ac7aa8cda0160deaeb4a8c2d490a88f088f21aa7

See more details on using hashes here.

File details

Details for the file matrix_webhook-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: matrix_webhook-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.12.15-arch1-1

File hashes

Hashes for matrix_webhook-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 668f3e649f5ef816aaf0a77aaf98405255e4f09edef815bfd71db654b3deb1a7
MD5 a1c8c8c4001567cd736de5b8c4cf26f3
BLAKE2b-256 f0695709c25a466dfbcc9a698a08b2c9d5e7d5b6c965504f4dec99c5a2bd9cbc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page