A simple, developer-friendly library to create powerful Matrix bots.
matrix.py is a lightweight and intuitive Python library to build bots on the Matrix protocol. It provides a clean, decorator-based API similar to popular event-driven frameworks, allowing developers to focus on behavior rather than boilerplate.
- Minimal setup, easy to extend
- Event-driven API using async/await
- Clean command registration
- Automatic event handler registration
- Built on matrix-nio
Requirements
- Python 3.10+
pip install git+ssh://[email protected]:Code-Society-Lab/matrixpy.git
If you plan on contributing to matrix.py, we recommend to install the development libraries:
pip install .[env]
Note: It is recommended to use a virtual environment when installing python packages.
from matrix import Bot, Context
bot = Bot(username="@gracehopper:matrix.org", password="grace1234")
@bot.command("ping")
async def ping(ctx: Context):
print(f"{ctx.sender} invoked {ctx.body} in room {ctx.room_name}.")
await ctx.send("Pong!")
bot.start()
Documentation - Examples
We welcome everyone to contribute!
Whether it's fixing bugs, suggesting features, or improving the docs - every bit helps.
- Submit an issue
- Open a pull request
- Or just hop into our Discord community and say hi!
If you intend to contribute, please read the CONTRIBUTING.md first. Additionally, every contributor is expected to follow the code of conduct.
matrix.py is released under GPL-3.0