Skip to main content

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())

Metadata

Release files for matrix-bot-lib 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matrix-bot-lib 0.1.8
File Size Uploaded Provenance Actions
matrix_bot_lib-0.1.8.tar.gz 6.6 kB With provenance Details for matrix_bot_lib-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for matrix-bot-lib 0.1.8
File Interpreter ABI Platform Actions
matrix_bot_lib-0.1.8-py3-none-any.whl Python 3 none any Details for matrix_bot_lib-0.1.8-py3-none-any.whl

Total release size: 14.3 kB

Release files / matrix_bot_lib-0.1.8.tar.gz

Download URL matrix_bot_lib-0.1.8.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0bf2c145e63f813dcfd07de38e97b58283eee9e310ff8afb4468983d9a41f1dd
BLAKE2b-256 checksum
How to use checksums
57149275a75928d0100866ab266eb0bfca195c503a299534a5814e752285984b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2024.

Transparency log

Release files / matrix_bot_lib-0.1.8-py3-none-any.whl

Download URL matrix_bot_lib-0.1.8-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e60d7ed524a9d6ff01a43eca710aed65b8270f13e0d5bc33e635d2075641962a
BLAKE2b-256 checksum
How to use checksums
beaac2230995dab99c62c151231a971ac867a7f6046f7bf4c21f9f09319c8dda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2024.

Transparency log

Security for matrix-bot-lib 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for matrix_bot_lib-0.1.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2024.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page