Twitch Bot Module
This module contains the main TwitchBot class and related functionality.
The TwitchBot class is responsible for handling Twitch chat commands and interacting with AI engines (Claude and GPT) to generate responses.
- class twitch_claude_bot.twitch_bot.TwitchBot[source]
Bases:
BotA Twitch bot that interacts with AI engines to respond to chat commands.
This bot can switch between Claude and GPT engines, change personas, and respond to various commands in the Twitch chat.
- clear_history = <twitchio.ext.commands.core.Command object>
- engine = <twitchio.ext.commands.core.Command object>
- async event_message(message)[source]
Runs every time a message is sent in chat.
- Parameters:
message – The message object containing information about the sent message.
- async get_ai_response(prompt: str) str[source]
Generate an AI response based on the current engine and persona.
This method calls the appropriate AI engine (Claude or GPT) with the given prompt and current persona to generate a response.
- Parameters:
prompt (str) – The user’s input prompt.
- Returns:
The generated AI response prefixed with the persona name.
- Return type:
str
- get_persona_name(persona_data: Dict[str, Any]) str[source]
Get the display name of the current persona.
This method returns the name of the current persona, using the ‘name’ field if available, or a formatted version of the persona key otherwise.
- Parameters:
persona_data (Dict[str, Any]) – The persona data dictionary.
- Returns:
The display name of the current persona.
- Return type:
str
- help = <twitchio.ext.commands.core.Command object>
- persona = <twitchio.ext.commands.core.Command object>
- persona_list = <twitchio.ext.commands.core.Command object>
- prompt = <twitchio.ext.commands.core.Command object>
- async split_and_send_message(ctx: Context, message: str)[source]
Split a long message into smaller chunks and send them sequentially.
This method breaks down a long message into sentences and sends them in chunks that do not exceed the maximum message length allowed by Twitch.
- Parameters:
ctx (commands.Context) – The context of the command execution.
message (str) – The message to be split and sent.