A simple Matrix client library wrapped around `matrix-nio`
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
niolithic-0.1.0.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file niolithic-0.1.0.tar.gz
.
File metadata
- Download URL: niolithic-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.10.109-1-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 674d65bc098e3b2823e9a8af79154dc44c7428e58151c7b6d16baa22efa2cf88 |
|
MD5 | 1f79b0b319f34a445f6368ce2e2a9b6f |
|
BLAKE2b-256 | 620fde898eaf37c42aaddc0d716d1dfc863abf2c4108f9d164addf6244928587 |
File details
Details for the file niolithic-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: niolithic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.10.109-1-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d62fb1b2be4a019f8bc1a409b86977e08e74e3ba9b12580757610836d6ae46ce |
|
MD5 | beec8739e088d7e4b0dc5ab27bf79a26 |
|
BLAKE2b-256 | 0d6ee8fd2c30a8bbb395dd4d3d4298414a03b325195931bf3724afeb79b07577 |