Matrix ASGI
with matrix-nio
Install
python3 -m pip install matrix-asgi
Use it in your app
You can look at the models.py and consumers.py files in the test application for a simple and quick example.
Start
Create a matrix user for the bot, and launch this server with the following arguments and/or environment variables (environment variables update defaults, arguments take precedence):
matrix-asgi
# OR
python -m matrix_asgi
usage: matrix-asgi [-h] [-u MATRIX_URL] -i MATRIX_ID -p MATRIX_PW [-v] application
Matrix ASGI Server.
positional arguments:
application The ASGI application instance to use as path.to.module:application
options:
-h, --help show this help message and exit
-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`
-v, --verbose increment verbosity level
Unit tests
docker compose -f test.yml up --exit-code-from tests --force-recreate --build
JSON Specification
ref. spec.md
Changes
ref. CHANGELOG.md