A bridge between Discord and Twitch chat.
Project description
Kasai
Kasai serves as a bridge between Discord and Twitch, allowing a single bot to interact with both platforms.
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!")
# Run the bot.
bot.run()
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.
Project details
Release history Release notifications | RSS feed
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 hikari_kasai-0.7a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 992a4101bd4c533c9f87cb9fe081d747efb16acf033d1c6b29e7c1a47f3b75e3 |
|
MD5 | b92daa5d408447509e57c0b65b9a36a3 |
|
BLAKE2b-256 | a4c3d34d508b09ba5319a620a69b196e4c6df2020665f655425ba4b11b5e4bf6 |