Skip to main content

Niolithic

A simple Matrix client library wrapped around matrix-nio.

It's meant to ressemble the very easy to work with design of discord.py. The intention is to make it quicker and simpler to set up a bot regardless of your skill level. But if you want to make a full-blown application or intricate bot, you should use matrix-nio as it is.

Example

from niolithic import SimpleClient


class MyBot(SimpleClient):
    async def on_ready(self):
        print('Bot is live!')

    async def on_message(self, room: MatrixRoom, event: RoomMessageText):
        print(
            f"Message received in room {room.display_name}\n"
            f"{room.user_name(event.sender)} | {event.body}"
        )

        command, *args = event.body.split()

        if command == '!clear':
            # Remove the last N messages
            
            if len(args) < 1:
                await self.send_text(
                    room.room_id,
                    'You need to provide the number of messages to clear out. Ex. `!clear 10`'
                )
                return

            limit = int(args[0]) + 1  # Plus 1 to include the command
            
            async for message in self.get_messages(
                    room.room_id, (RoomMessageText,), limit=limit):

                await self.redact_event(message, reason='Mass deletion by `!clear`')

            print(f'{limit} messages redacted.')


client = MyBot(
    'https://matrix.org',       # Homeserver
    '@username123:matrix.org',  # User ID
    'MyBot',                    # Device name
)
client.run()

Metadata

Release files for niolithic 0.1.0

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

Source distribution (sdist)

Source distribution for niolithic 0.1.0
File Size Uploaded
niolithic-0.1.0.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for niolithic 0.1.0
File Interpreter ABI Platform
niolithic-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / niolithic-0.1.0.tar.gz

Download URL niolithic-0.1.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
674d65bc098e3b2823e9a8af79154dc44c7428e58151c7b6d16baa22efa2cf88
BLAKE2b-256 checksum
How to use checksums
620fde898eaf37c42aaddc0d716d1dfc863abf2c4108f9d164addf6244928587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.4 Linux/5.10.109-1-MANJARO

Release files / niolithic-0.1.0-py3-none-any.whl

Download URL niolithic-0.1.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d62fb1b2be4a019f8bc1a409b86977e08e74e3ba9b12580757610836d6ae46ce
BLAKE2b-256 checksum
How to use checksums
0d6ee8fd2c30a8bbb395dd4d3d4298414a03b325195931bf3724afeb79b07577
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.4 Linux/5.10.109-1-MANJARO

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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