Skip to content
forked from ekonda/kutana

The library for developing systems for messengers and social networks

License

Notifications You must be signed in to change notification settings

eoan-ermine/kutana

 
 

Repository files navigation

Kutana

Kutana logo

Documentation Status CodeFactor Coverage Status Codebeat Badge PyPI version

The library for developing systems for messengers and social networks. Great for developing bots. Refer to example for the showcase of the library abilities.

This library uses generalized attachment types, possible actions e.t.c. for flexibility to use plugins with different backends.

Installation

python -m pip install kutana

Running

From CLI

Following command will populate application's config, add specified backends and load plugins from specified folder.

python3 -m kutana --config example/config.yml --plugins example/plugins

# usage: python3 -m kutana [-h] [--config CONFIG] [--plugins PLUGINS] [--debug]

# Run kutana application instance using provided config.

# optional arguments:
#   -h, --help         show this help message and exit
#   --config CONFIG    file with config in yaml format (default: config.yml
#   --plugins PLUGINS  folder with plugins to load (default: plugins)
#   --debug            set logging level to debug

Refer to the example config.yml for the configuration details.

From python

import json
from kutana import Kutana, load_plugins
from kutana.backends import Vkontakte

# Import configuration
with open("config.json") as fh:
    config = json.load(fh)

# Create application
app = Kutana()

# Add manager to application
app.add_backend(Vkontakte(token=config["vk_token"]))

# Load and register plugins
app.add_plugins(load_plugins("plugins/"))

if __name__ == "__main__":
    # Run application
    app.run()

Token for Vkontakte is loaded from the file "config.json" and plugins are loaded from folder "plugins/"

Example plugin (plugins/echo.py)

from kutana import Plugin, t

plugin = Plugin(name=t("Echo"))

@plugin.on_commands(["echo"])
async def __(msg, ctx):
    await ctx.reply(ctx.body, attachments=msg.attachments)

If your function exists only to be decorated, you can use _ to avoid unnecessary names. Use __ if you use something like pydash.

Available backends

Authors

About

The library for developing systems for messengers and social networks

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.5%
  • Makefile 0.5%