Skip to main content

The library for developing systems for messengers and social networks

Project description

Kutana

Kutana logo

Documentation Status Build Status CodeFactor Codacy Badge Coverage Status Codebeat Badge PyPI version

English | Русский

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

Nice foundation for bot using kutana library - kubot.

Installation

python -m pip install kutana

Usage

  • Create Kutana application and add managers.
  • Register your plugins in the executor. You can import plugin from folders with function load_plugins. Files should be a valid python modules with available plugin field with your plugin (Plugin) or field plugins with list of instances of Plugin class.
  • Start application.

Example run.py

Token for VKManager is loaded from the file "configuration.json" and plugins are loaded from folder "plugins/"

from kutana import *

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

# Create application
app = Kutana()

# Create and add VKManager to application
app.add_manager(VKManager(config["vk_token"]))

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

# Run application
app.run()

Example plugin (plugins/echo.py)

from kutana import Plugin

plugin = Plugin(name="Echo")

@plugin.on_startswith_text("echo")
async def _(message, env):
    await env.reply("{}".format(env.body))

If your function exists only to be decorated, you can use _ to avoid unnecessary names

Available managers

  • VKManager (for vk.com groups)
  • TGManager (for telegram.org bots)
    • document's type is named doc inside of Kutana.

    • TGAttachmentTemp is used for storing attachments before sending them with send_message or reply. Attachments can't be uploaded other way

    • If you want to download file (attachment) from telegram, you have to use TGEnvironment.get_file_from_attachment

Authors

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

kutana-3.2.0.tar.gz (26.6 kB view hashes)

Uploaded Source

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