Metadata-Version: 2.1
Name: matrix-bot-lib
Version: 0.1.8
Summary: Super early lib for interacting with Matrix
Author: Nicolai Søborg
Author-email: git@xn--sb-lka.org
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: httpx[http2] (>=0.27.0,<0.28.0)
Requires-Dist: result (>=0.17.0,<0.18.0)
Description-Content-Type: text/markdown

# matrix-bot-lib

Requires python >= 3.10

## TODO

* e2e crypto
* Better models and validation
  -> Refactor EventMetadata and EventMessage
  -> Better (more loose?) signature for EventData

## How to use

```python3
import os
from getpass import getpass
from shlex import join as cmd_join
from matrix_bot_lib import MatrixBot

async def main() -> None:
    BOT_USER = "@dtuhax-bot:xn--sb-lka.org"
    BOT_PASS = getpass(f'Password for {BOT_USER}: ')

    bot = MatrixBot(BOT_USER)
    await bot.login(BOT_PASS)

    @bot.on_message
    async def recv_msg(room_id: str, content: dict, metadata: dict):
        match content:
            case {'body': msg_txt, 'msgtype': 'm.text'}:
                print(f'Message: {msg_txt}')

    @bot.on_reaction
    async def recv_react(room_id: str, content: dict, metadata: dict):
        """ MSC2677 """
        match content:
            case {'m.relates_to': {'rel_type': 'm.annotation', 'key': emoji}}:
                print(f'Reaction: {emoji}')  # e.g. '🚪'

    await bot.run(full_sync=False)

if __name__ == '__main__':
    import asyncio
    asyncio.run(main())
```

