TwitchAgents
AI powered Twitch bots that can interact with the audience using TwitchIO Sqlite, and XML
Install / Use
/learn @BlaiseLabs/TwitchAgentsREADME
This script provides a way to create Twitch chatbots using ConvoXML for conversation modeling and TwitchIO for interacting with the Twitch chat.
Prerequisites
Before using this script, make sure you have the following in place:
- Python environment with necessary packages installed (see
requirements.txt). - Twitch account and access to a Twitch channel where you want to deploy the bot.
- API tokens for the Twitch accounts and bots you intend to use.
Getting Started
-
Clone or download the repository to your local machine.
-
Modify the
twitch.xmlfile to define your conversation model. You can specify roles, actions, and triggers in the XML file to control the chatbot's behavior. -
Update the
token_filepaths in the XML file to point to the correct API token files for your Twitch accounts and bots. -
Run the main script to start your Twitch chatbot. Here's how to run it:
python main_script.py
Understanding the Script
+---------------------------------------------------+
| |
| Twitch Chat Script with |
| ConvoXML and TwitchIO Bot |
| |
+-------------------+-------------------------------+
|
|
+--------------------------v--------------------------+
| |
| Twitch Channel (Twitch Chat) |
| |
| +--------------+ +--------------+ +--------------+ |
| | Viewer 1 | | Viewer 2 | | Viewer 3 | |
| | | | | | | |
| | | | | | | |
| +--------------+ +--------------+ +--------------+ |
| |
+---------------------------|---------------------------+
|
| Twitch Messages
|
+---------------------------v---------------------------+
| |
| TwitchFeed (TwitchIO Bot) |
| |
| +---------------------------------------------------+ |
| | TwitchIO | |
| | | |
| | +-------------+ +-------------+ +-------------+ | |
| | | Agent 1 | | Agent 2 | | Agent 3 | | |
| | | | | | | | | |
| | | | | | | | | |
| | +-------------+ +-------------+ +-------------+ | |
| | | |
| +---------------------------------------------------+ |
| |
+---------------------------|---------------------------+
|
| Chatbot Actions and Messages
|
+---------------------------v---------------------------+
| |
| AsyncConvo (ConvoXML Conversation Engine) |
| |
| +---------------------------------------------------+ |
| | ConvoXmlParser | |
| | | |
| | +-------------+ +-------------+ +-------------+ | |
| | | Agent 1 | | Agent 2 | | Agent 3 | | |
| | | | | | | | | |
| | | | | | | | | |
| | +-------------+ +-------------+ +-------------+ | |
| | | |
| +---------------------------------------------------+ |
| |
+-------------------------------------------------------+
-
twitch.xml: This file defines the conversation model using ConvoXML. It specifies roles, actions, and triggers for your Twitch chatbot. -
TwitchBotInterface: This class extends the TwitchIOClientand handles Twitch chat interactions. It sends and receives messages from the Twitch channel. -
TwitchMod: This class represents the Moderator role in the conversation. It decides the next action based on predefined triggers and intervals. -
TwitchAgentMixInandTwitchAgent: These classes enable Twitch messaging for any Agent subclass. You can use theTwitchAgentclass to create your chatbot agents, extending it with custom logic as needed. -
TwitchFeed: This class handles incoming Twitch chat messages and stores them in an SQLite database. It also manages communication between chatbots and the Twitch channel. -
AsyncConvo: This class extends the ConvoXmlParser and handles the asynchronous execution of chatbot actions based on the conversation model defined intwitch.xml.
Customizing Your Chatbot
To customize your Twitch chatbot, you can:
-
Modify the conversation model in
twitch.xmlto define different roles, actions, and triggers for your chatbot interactions. -
Create custom chatbot agents by extending the
TwitchAgentclass and implementing theexecutemethod with your custom logic. -
Adjust the intervals and behavior of the Moderator role in the
TwitchModclass to control when chatbot actions occur.
License
Copyright (c) 2023 Blaiselabs
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Acknowledgments
Related Skills
feishu-drive
348.2k|
things-mac
348.2kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
348.2kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
postkit
PostgreSQL-native identity, configuration, metering, and job queues. SQL functions that work with any language or driver
