Skip to main content

Making matrix bots simple

Project description

Nio-Bot

Making Matrix bots simple

GitHub Workflow Status (with event) 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",
    user_id="@example1:example.org",
    device_id="my-device-name",
    command_prefix="!",
    case_insensitive=True,
    owner_id="@example2:example.org",
    ignore_self=False
)

@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.reply("Pong!")


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


client.run(access_token="aaaaaaaaaaaaaa")

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.

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

nio_bot-1.1.1.post1.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

nio_bot-1.1.1.post1-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file nio_bot-1.1.1.post1.tar.gz.

File metadata

  • Download URL: nio_bot-1.1.1.post1.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.5

File hashes

Hashes for nio_bot-1.1.1.post1.tar.gz
Algorithm Hash digest
SHA256 d1f42e50371ae27bcd91a9aa8a7d010f1a49616b0f9524dd82e58985c0f1ecf0
MD5 e4e5c39bcc03963ae50c2afb51cc3219
BLAKE2b-256 c17996c368347abe609aec4498cb4970d644a696bb70fe52947d362b77a74fca

See more details on using hashes here.

File details

Details for the file nio_bot-1.1.1.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for nio_bot-1.1.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 b37c4245c8a348c45ba31acc26c903f8f16780646d967cd7cc5bda975787b7c3
MD5 1454f8a01ab466890152e2736b04f345
BLAKE2b-256 c95b30a9cce9d3247b5d990c651d2d7cc25b8782f32d421b9026e592e89ac96a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page