A general purpose library for command-based iteraction made for bots
Project description
Command For Bot
:warning: The document is still working in progress!
command4bot
is a general purpose library for command-based iteraction made for bots, with command registry, command dependency (a.k.a. setup
), ability to enable / disable commands, fallback functions included.
Installation
pip install command4bot
Quick Start
from command4bot import CommandsManager
mgr = CommandsManager()
@mgr.command
def greet(payload):
return f"Hello, {payload}!"
mgr.exec('greet John') # 'Hello, John!'
Basic Concepts and Usage
Command
Command is a function taking a positional argument (payload
) and optional keyword arguments.
Setup (Command Dependency)
Command dependencies is trivial to manage if the command is always open.
For example, setup web socket connection if any command needs, and close the connection if all commands need the socket are closed.
@mgr.setup
def ws():
ws_client = WSClient('localhost:8888')
yield ws_client
ws_client.close()
@mgr.command
def send(paload, ws):
ws.send(payload)
Documentation
https://command4bot.readthedocs.io/en/latest/
Todo
- Support for commands need interaction
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
Built Distribution
Hashes for command4bot-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f11ed9b2fde0db473ef35445b214154fb2e49a830d1ec59047b9877a2f44e77c |
|
MD5 | a4b3a76d03d174d68fc3687bebac2ff2 |
|
BLAKE2b-256 | dda49617b2d233ac67f59b4aff4db25f3032a902f312a560a1c4a1e31164c366 |