Super early lib for interacting with Matrix
Project description
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
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())
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matrix_bot_lib-0.1.8.tar.gz.
File metadata
- Download URL: matrix_bot_lib-0.1.8.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bf2c145e63f813dcfd07de38e97b58283eee9e310ff8afb4468983d9a41f1dd
|
|
| MD5 |
feb397de012fc1ba0eb21d08e8fddebd
|
|
| BLAKE2b-256 |
57149275a75928d0100866ab266eb0bfca195c503a299534a5814e752285984b
|
Provenance
The following attestation bundles were made for matrix_bot_lib-0.1.8.tar.gz:
Publisher:
release.yml on NicolaiSoeborg/matrix-bot-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrix_bot_lib-0.1.8.tar.gz -
Subject digest:
0bf2c145e63f813dcfd07de38e97b58283eee9e310ff8afb4468983d9a41f1dd - Sigstore transparency entry: 149091957
- Sigstore integration time:
-
Permalink:
NicolaiSoeborg/matrix-bot-lib@931aeee01bb95ebd07802e64f969d0b1b190f070 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/NicolaiSoeborg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@931aeee01bb95ebd07802e64f969d0b1b190f070 -
Trigger Event:
push
-
Statement type:
File details
Details for the file matrix_bot_lib-0.1.8-py3-none-any.whl.
File metadata
- Download URL: matrix_bot_lib-0.1.8-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e60d7ed524a9d6ff01a43eca710aed65b8270f13e0d5bc33e635d2075641962a
|
|
| MD5 |
c4e1e4c7bf4b97b64c35998a7e26cc0d
|
|
| BLAKE2b-256 |
beaac2230995dab99c62c151231a971ac867a7f6046f7bf4c21f9f09319c8dda
|
Provenance
The following attestation bundles were made for matrix_bot_lib-0.1.8-py3-none-any.whl:
Publisher:
release.yml on NicolaiSoeborg/matrix-bot-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrix_bot_lib-0.1.8-py3-none-any.whl -
Subject digest:
e60d7ed524a9d6ff01a43eca710aed65b8270f13e0d5bc33e635d2075641962a - Sigstore transparency entry: 149091959
- Sigstore integration time:
-
Permalink:
NicolaiSoeborg/matrix-bot-lib@931aeee01bb95ebd07802e64f969d0b1b190f070 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/NicolaiSoeborg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@931aeee01bb95ebd07802e64f969d0b1b190f070 -
Trigger Event:
push
-
Statement type: