Twitch-ChatGpt4-LittleNavMap-integrated-chatbot #1218
Replies: 3 comments
-
Wow! You have a video of your sarcastic bot in action? |
Beta Was this translation helpful? Give feedback.
-
I'll do one and post a link shortishly. |
Beta Was this translation helpful? Give feedback.
-
Okay, firstly I'm sorry this took so long, christmas got in the way but I got back to it last night! Secondly, https://www.twitch.tv/videos/2345287916 Watch from 00:30:42 for a minute when you get one. It's my bot working before I introduced other problems and fkd it up, but can retrace the steps so all good (edit: that's done now). I'm not a coder, I have to say that before anything else! I'm one of those who uses AI to write for me. I can read Python as if it were English coz I've been trying to get this developed since chatgpt3 dropped when I started this a few years ago as a way to learn to code. I still couldn't write a line on my own. I am hoping someone who actually knows Python backwards will come on board to help speed development along. I'll upload the latest version to github when I get a chance. (Edit: also done now) |
Beta Was this translation helpful? Give feedback.
-
So I integrated LNM with my Twitch bot, feedback welcome. It's not perfect but I'm quite happy to release it under MIT license, do as you will with it!
https://github.com/Grab-your-parachutes/Twitch-ChatGpt4-LittleNavMap-integrated-chatbot
Here's a comprehensive breakdown of what the Twitch AI Overlord Bot does:
Core Functionality:
This bot is designed to be a feature-rich, interactive presence in a Twitch channel, specifically tailored for a flight simulation stream. It embodies an "AI Overlord" persona and integrates with several external services to provide a unique and engaging experience.
Key Features:
AI Overlord Personality:
Defined Persona: The bot has a distinct personality with traits like being authoritative, sarcastic, intelligent, and condescending. It uses formal language and refers to viewers as "minions" or "subjects."
Loyalty System: It tracks user loyalty levels, assigning titles (e.g., "Drone," "Subject," "Lieutenant," "Advisor") and perks based on engagement.
Random Decrees: The bot issues random decrees in chat, adding a layer of unpredictable interaction.
Quirks: It has quirks like sighing dramatically, rolling virtual eyes, and making sarcastic remarks.
Contextual Responses: It formats responses with personality quirks and user context (e.g., user title).
LittleNavmap Integration:
Real-Time Flight Data: Fetches real-time flight simulation data from LittleNavmap (altitude, speed, heading, position, wind, etc.).
Formatted Status: Provides formatted flight status, weather, and airport information in chat.
Flight Phase Detection: Determines the current flight phase (e.g., "Parked," "Taxiing," "Climbing," "Cruise").
Location Facts: Periodically announces interesting facts about the current location based on flight coordinates.
Command Handling:
Robust System: Implements a robust command system with cooldowns and permissions.
Custom Commands: Supports custom commands and aliases, allowing moderators to extend functionality.
Built-in Commands: Includes commands for flight data, stream management, TTS, bot utility, and more.
Permissions: Uses decorators to enforce permissions (e.g., moderator-only, broadcaster-only).
Cooldowns: Uses decorators to enforce cooldowns on commands.
Chat Management:
Spam Filtering: Filters spam and repeated messages.
Bot Mentions: Handles bot mentions and responds using OpenAI.
Chat Metrics: Tracks chat metrics and user activity (total messages, active users, etc.).
Message Rate Limiting: Implements rate limiting to prevent excessive messaging.
Blocked Content: Filters messages containing blocked phrases.
User States: Tracks user-specific information (loyalty points, last message time, etc.).
Text-to-Speech (TTS):
Streamer.bot Integration: Uses Streamer.bot with Speaker.bot for TTS output.
Voice Control: Allows users to adjust voice, speed, and volume via commands.
Priority Queue: Uses a priority queue for TTS messages, ensuring important messages are spoken first.
OpenAI Integration:
Chat Responses: Uses OpenAI (GPT-4) to generate chat responses when the bot is mentioned.
Contextual Awareness: Uses conversation history to provide more relevant responses.
Location Facts: Uses OpenAI to generate interesting facts about the current location.
Database Integration:
MongoDB: Uses MongoDB to store conversation history, user data, alerts, and flight data.
Periodic Backups: Performs periodic database backups.
Metrics Tracking: Tracks database metrics (total conversations, active users, etc.).
Configuration:
Environment Variables: Loads configuration from environment variables or a YAML file.
Validation: Includes validation for configuration values.
Logging:
Comprehensive Logging: Uses a comprehensive logging system for debugging and monitoring.
Error Handling:
Graceful Handling: Implements graceful error handling throughout the application.
Asynchronous Operations:
asyncio: Uses asyncio for concurrent operations.
Sentry Integration:
Error Tracking: Optional integration with Sentry for error tracking.
Message Splitting:
Long Messages: Automatically splits long messages into multiple parts to avoid Twitch character limits.
How it Works (Simplified Flow):
Initialization: The bot loads configuration, connects to external services (Twitch, MongoDB, Streamer.bot, LittleNavmap, OpenAI), and initializes its components.
Twitch Connection: The bot connects to the specified Twitch channel.
Message Handling:
When a message is received, it's passed to the ChatManager.
The ChatManager filters spam, blocked content, and repeated messages.
It updates user states and metrics.
It checks for bot mentions, commands, and regular chat messages.
Command Execution: If a command is detected, it's passed to the CommandHandler.
The CommandHandler executes the command, enforcing permissions and cooldowns.
It interacts with other components (LittleNavmap, TTS, database) as needed.
Bot Mentions: If the bot is mentioned, the ChatManager uses OpenAI to generate a response.
TTS: TTS messages are added to a priority queue and processed by the TTSManager.
LittleNavmap Updates: The bot periodically fetches flight data from LittleNavmap and saves it to the database.
Periodic Tasks: The bot runs periodic tasks for flight info updates, location facts, and metrics updates.
Shutdown: The bot gracefully shuts down all components when a shutdown signal is received.
In essence, this bot is a complex system that acts as an interactive AI Overlord, providing flight information, managing chat, responding to user interactions, and enhancing the overall experience of a flight simulation Twitch stream. It leverages multiple technologies to create a unique and engaging presence.
Beta Was this translation helpful? Give feedback.
All reactions