2019-02-17 05:46:00 -05:00
|
|
|
# Matrix Webhook
|
2019-02-10 16:02:48 -05:00
|
|
|
|
2021-07-13 06:28:01 -04:00
|
|
|
[![Tests](https://github.com/nim65s/matrix-webhook/actions/workflows/test.yml/badge.svg)](https://github.com/nim65s/matrix-webhook/actions/workflows/test.yml)
|
|
|
|
[![Lints](https://github.com/nim65s/matrix-webhook/actions/workflows/lint.yml/badge.svg)](https://github.com/nim65s/matrix-webhook/actions/workflows/lint.yml)
|
2021-07-13 05:54:24 -04:00
|
|
|
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
|
|
|
|
[![codecov](https://codecov.io/gh/nim65s/matrix-webhook/branch/master/graph/badge.svg?token=BLGISGCYKG)](https://codecov.io/gh/nim65s/matrix-webhook)
|
|
|
|
|
2019-02-17 05:46:00 -05:00
|
|
|
Post a message to a matrix room with a simple HTTP POST
|
2019-02-10 19:32:57 -05:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2019-02-17 06:31:49 -05:00
|
|
|
Create a matrix user for the bot, make it join the rooms you want it to talk into, and then set the following
|
|
|
|
environment variables:
|
2019-02-10 19:32:57 -05:00
|
|
|
|
2019-02-10 19:56:50 -05:00
|
|
|
- `MATRIX_URL`: the url of the matrix homeserver
|
|
|
|
- `MATRIX_ID`: the user id of the bot on this server
|
|
|
|
- `MATRIX_PW`: the password for this user
|
2019-03-06 10:47:35 -05:00
|
|
|
- `API_KEY`: a secret to share with the users of the service
|
2021-05-30 10:34:09 -04:00
|
|
|
- `HOST`: HOST to listen on, all interfaces if `''` (default).
|
|
|
|
- `PORT`: PORT to listed on, default to 4785.
|
2019-02-10 19:32:57 -05:00
|
|
|
|
|
|
|
## Dev
|
|
|
|
|
|
|
|
```
|
2020-03-14 13:09:18 -04:00
|
|
|
pip3 install --user markdown matrix-nio
|
2019-02-17 06:15:27 -05:00
|
|
|
./matrix_webhook.py
|
2019-02-10 19:32:57 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
## Prod
|
|
|
|
|
2019-02-17 06:29:50 -05:00
|
|
|
- Use [Traefik](https://traefik.io/) on the `web` docker network, eg. with
|
|
|
|
[proxyta.net](https://framagit.org/oxyta.net/proxyta.net)
|
2019-02-17 06:44:00 -05:00
|
|
|
- Put the configuration into a `.env` file
|
2020-06-07 04:31:21 -04:00
|
|
|
- Configure your DNS for `${CHATONS_SERVICE:-matrixwebhook}.${CHATONS_DOMAIN:-localhost}`
|
2019-02-10 19:32:57 -05:00
|
|
|
|
|
|
|
```
|
|
|
|
docker-compose up -d
|
|
|
|
```
|
|
|
|
|
2019-02-17 06:29:50 -05:00
|
|
|
## Test / Usage
|
2019-02-10 19:32:57 -05:00
|
|
|
|
|
|
|
```
|
2020-03-14 13:10:32 -04:00
|
|
|
curl -d '{"text":"new contrib from toto: [44](http://radio.localhost/map/#44)", "key": "secret"}' \
|
|
|
|
'http://matrixwebhook.localhost/!DPrUlnwOhBEfYwsDLh:matrix.org'
|
2019-02-10 19:32:57 -05:00
|
|
|
```
|
2019-03-06 10:47:35 -05:00
|
|
|
(or localhost:4785 without docker)
|
2020-03-14 12:17:01 -04:00
|
|
|
|
|
|
|
## Test room
|
|
|
|
|
|
|
|
[#matrix-webhook:tetaneutral.net](https://matrix.to/#/!DPrUlnwOhBEfYwsDLh:matrix.org?via=laas.fr&via=tetaneutral.net&via=aen.im)
|