Skip to main content

Building blocks and utility extensions for discord.py bots

Project description

Python versions License Status Issues Commit activity


Kasushi

Building blocks and utility extensions for discord.py bots


Kasushi is an extension of the discord.py library. It provides a number of useful features for bots, such as cache, IPC, tortoise models and more.

It is really easy to use, and requires a minimum amount of configuration.

  1. Download kasushi on the command line using pip:
pip install -U kasushi
  1. Configure the extensions:
import kasushi
# See below for settings you can pass to configure.
await kasushi.configure(bot, {}) 
  1. Load the extensions in your bot code before it runs:
await bot.load_extension('kasushi.cache')

You're done!

Modules and settings

Many modules are available in kasushi. You should load them in your bot, and pass settings to configure.

Depending on the module(s) you want to use, you can pass different settings to configure.

Cache

The cache module allows for connecting to a memcached server. It can be used to store cached data between reboots of the bot, like cooldowns and user data.

Usage

Once installed and loaded, the cache class is made available in bot.cache.

await bot.cache.set("coins", 0)
await bot.cache.set("coins", 10)
await bot.cache.get("coins")  # 10
await bot.cache.delete("coins")
await bot.cache.get("coins", default=5)  # 5

Configuration example

You can pass the following dictionary to configure:

{
    "cache": {
        "server_ip": "127.0.0.1",
        "server_port": 11211,
    }
}

IPC

IPC stands for Inter-Process Communication. It allows for sending messages between processes, or, in our case, different processes for the same bot.

The process hosting the first shard (shard 0) will be the "master process". It'll host the webserver allowing other processes to connect to it.

It'll also pass messages to the other bots if needed.

Usage

Once installed and loaded, the IPC class is made available in bot.ipc. All bots need to be able to access the first shard's IPC server.

Configuration example

{
    "ipc": {
        "shared_secret": "secret",  # This is used to authenticate with the IPC server.
        "server": {
            "host": "0.0.0.0",
            "port": 12321,
        },
        "client": {
            "server_url": "http://127.0.0.1:12321",
        },
        "handlers": [GuildInfoHandler]  # See above for handlers.
    },
}

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

kasushi-0.1.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kasushi-0.1.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file kasushi-0.1.2.tar.gz.

File metadata

  • Download URL: kasushi-0.1.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for kasushi-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3f90fca5e3a8cef058846a1d3d86ac9c779d5ddff99c9ccfe4d3531ab8eca00f
MD5 fa74b1f1a2d44fe3220f2fd807b560f6
BLAKE2b-256 629de842befbb06d11dbec41dfc75463073361c6801cd4e4e3707a5f76d03581

See more details on using hashes here.

File details

Details for the file kasushi-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kasushi-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for kasushi-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 084fab8b6009f88091a8717e2bc498538c17c8d5177b205c27675a248d5cabc6
MD5 370f8885174f9fe10ca23c67148f30c0
BLAKE2b-256 4ca93a089db6813a44deabe465018c2e7cd2fb5c71b07e5df8858a822f42bf6d

See more details on using hashes here.

Supported by

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