This release is a pre-release and may not be stable for production use.
Kasai
Kasai serves as a bridge between Discord and Twitch, allowing a single bot to interact with both platforms.
This serves to extend Hikari, and cannot be used without it.
Installation
To install the latest released version of Kasai, use the following command:
pip install hikari-kasai
You can also install the latest development version using the following command:
pip install git+https://github.com/parafoxia/hikari-kasai
You may need to prefix these commands with a call to the Python interpreter depending on your OS and Python configuration.
Creating your bot
Kasai provides a subclass for hikari.GatewayBot that contains methods and attributes for Twitch chat interfacing.
import kasai
bot = kasai.GatewayBot(...)
To use Kasai with command handlers, you will need to create a custom subclass that inherits from both kasai.GatewayBot and your command handler's bot class.
For example, if you want to use Lightbulb:
import kasai
import lightbulb
class Bot(kasai.GatewayBot, lightbulb.BotApp):
...
bot = Bot(...)
Usage
A working implementation could look something like this:
import os
import dotenv
import hikari
import kasai
# You will need a .env file for this.
dotenv.load_dotenv()
# Create the bot.
bot = kasai.GatewayBot(
os.environ["TOKEN"],
os.environ["IRC_TOKEN"],
os.environ["TWITCH_CLIENT_ID"],
os.environ["TWITCH_CLIENT_SECRET"],
)
@bot.listen(hikari.StartedEvent)
async def on_started(event: hikari.StartedEvent):
# Connect to your Twitch chat.
await bot.twitch.join("twitchdev")
@bot.listen(hikari.GuildMessageCreateEvent)
async def on_message(event: hikari.GuildMessageCreateEvent):
# Send a message from Discord to Twitch chat.
if event.content.startswith("!send"):
await bot.twitch.create_message("twitchdev", event.content[6:])
@bot.listen(kasai.MessageCreateEvent)
async def on_twitch_message(event: kasai.MessageCreateEvent):
# Basic Twitch command implementation.
if event.content.startswith("!ping"):
await event.message.respond("Pong!", reply=True)
# Run the bot.
bot.run()
There are more examples should you wish to see them. It may also be worth looking into how to speed Hikari up to get the best performance out of Kasai.
Contributing
Contributions are very much welcome! To get started:
- Familiarise yourself with the code of conduct
- Have a look at the contributing guide
License
The hikari-kasai module for Python is licensed under the BSD 3-Clause License.
Metadata
Release files for hikari-kasai 0.10a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hikari-kasai-0.10a0.tar.gz | 18.8 kB | Without provenance | Details for hikari-kasai-0.10a0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hikari_kasai-0.10a0-py3-none-any.whl | Python 3 | none | any | Details for hikari_kasai-0.10a0-py3-none-any.whl |
Total release size: 51.1 kB
Release files / hikari-kasai-0.10a0.tar.gz
| Download URL | hikari-kasai-0.10a0.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ec4f4b9c41ec06d7769ec4ff5cd8600dd142e13d07c60c5075a4cfd8d8daac5
|
|
BLAKE2b-256 checksum How to use checksums |
ae757f88b8c77fead86347c2c1b08ac7087b200016ad2c0b4764d5e83b17e277
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / hikari_kasai-0.10a0-py3-none-any.whl
| Download URL | hikari_kasai-0.10a0-py3-none-any.whl |
|---|---|
| Size | 32.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cad81d34064f3611b785f0e36c66481b07962901b463cd906344f9c1c04c4572
|
|
BLAKE2b-256 checksum How to use checksums |
8dbdb244dc75f96b1a6139ed075c5096934e7f59a66f847e32d4b1650c7ee991
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for hikari-kasai 0.10a0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.