Git Product home page Git Product logo

niobot's Introduction

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.

niobot's People

Contributors

nexy7574 avatar matthieu-laurent39 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.