Skip to main content

Nio-Bot

Making Matrix bots simple

GitHub issues GitHub pull requests GitHub GitHub Repo stars

PyPI - Downloads PyPI - Version Python Version from PEP 621 TOML

Matrix


Installing

You can install the latest stable release from PyPi:

pip install nio-bot
# Or for cutting-edge releases:
# pip install --pre nio-bot

You may also want some extras:

  • End-to-End encryption support: nio-bot[e2ee]
  • The CLI (recommended): nio-bot[cli]
  • Both: nio-bot[cli,e2ee]
  • Development dependencies: nio-bot[dev]

Please note that e2ee uses olm, which depends on libolm. You can likely install this though your system package manager.

Features

Nio-Bot is built on the solid client library, matrix-nio. This means that you get the full experience of a Matrix client, with the added benefit of being able to easily create bots.

Nio-Bot comes with a whole host of features to help make your development experience as easy as possible. Some features include, but are not limited to:

  • A powerful commands framework (Modules, aliases, checks, easy extensibility)
  • Custom argument parser support
  • A flexible event system
  • Simple end-to-end encryption
  • Automatic markdown rendering when sending/editing messages
  • Super simple to use Attachments system
  • Very customisable monolithic client instance
  • A simple, easy-to-use CLI tool for some on-the-go tasks
  • Full attachment support (File, Image, Audio, Video), with encryption support
  • In-depth, simple, clean documentation

Help

You can join our Matrix Room for help, or to just chat. You can also get the latest updates in development there, including having your say in how new things are implemented!

A quick example

# This example was written using version 1.1.0.
import niobot

client = niobot.NioBot(
    # Note that all of these options other than the following are optional:
    # * homeserver
    # * user_id
    # * command_prefix
    homeserver="https://matrix.example.org",  # it is important that you use the matrix server, not the delegation URL
    user_id="@example1:example.org",
    device_id="my-device-name",
    command_prefix="!",
    case_insensitive=True,
    owner_id="@example2:example.org",
    ignore_self=True  # default is True, set to false to not ignore the bot's own messages
)

@client.on_event("ready")
async def on_ready(sync_result: niobot.SyncResponse):
    print("Logged in!")


# A simple command
@client.command()
async def ping(ctx: niobot.Context):
    latency = ctx.latency
    await ctx.respond(f"Pong! {latency:.2f}ms")


# A command with arguments
@client.command()
async def echo(ctx: niobot.Context, *, message: str):
    await ctx.respond("You said: " + message)


client.run(access_token="...")

Using the CLI to get an access token

If you install the cli extras, you can use niocli to get an access token from a username and password (read this for why you'd want to use an access token):

niocli get-access-token -U '@example1:example.org' -D 'my-device-name'

After putting in your password, an access token will be printed to the console once the login is successful.

Further reading

Look at the docs for more information on how to use Nio-Bot, or the examples on github.

Metadata

Release files for nio-bot 1.2.1

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

Source distribution (sdist)

Source distribution for nio-bot 1.2.1
File Size Uploaded
nio_bot-1.2.1.tar.gz 1.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for nio-bot 1.2.1
File Interpreter ABI Platform
nio_bot-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 3.3 MB

Release files / nio_bot-1.2.1.tar.gz

Download URL nio_bot-1.2.1.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
d834b3ccf22e1ef80405874072121477a7e6770d05664619825b9264f33d01cb
BLAKE2b-256 checksum
How to use checksums
3fb72bfb7fbf10340bb2ca62bcaab364acfe66fdd756f5b87c787b2bfddb8c8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / nio_bot-1.2.1-py3-none-any.whl

Download URL nio_bot-1.2.1-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
d080a6fca92ac0a539ecbb9d1904855ee75e6ad3d8ce6171b2dcf3fb1257d075
BLAKE2b-256 checksum
How to use checksums
569c8f4263836da4ed3d6378c4fcb388dbee51d0d15479e8ab3ba2a30a105540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.0

2 release files

0.1.0

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