A bridge between Discord and Twitch chat.
Project description
hikari-kasai
A bridge between Discord and Twitch chat.
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"],
)
@bot.listen(hikari.GuildMessageCreateEvent)
async def on_message(event):
if event.content == "!start":
# Start listening for messages.
await bot.start_irc("#channel1", "#channel2")
elif event.content == "!close":
# Stop listening for messages.
await bot.close_irc()
elif event.content.startswith("!send"):
# Send a message to Twitch chat.
await bot.twitch.create_message("#channel1", event.content[6:])
@bot.listen(kasai.PrivMessageCreateEvent)
async def on_twitch_message(event):
# Display message information.
print(f"{event.author.name} said {event.content} in {event.channel.name}")
# 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.4a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a89891d1d5ea21daef3b6cde81791ec69e172b884385d3e7c5178808ffe0ec70 |
|
MD5 | 359a4ffbe0f1f3b0c5d79728e2f40fb3 |
|
BLAKE2b-256 | 56d4d29e1acac65bfd320bf2bfbf3651af80dce5497516da849cb2b8b7ed767e |