Code von github.com/Kenearos/KI-Chat-Bot-Eugen
Enhanced test suite from 97% to 100% coverage with 173 passing tests. ## New Features ### 1. Error Handling Tests (3 tests) - test_add_message_handles_read_error_gracefully - test_add_message_handles_write_error_gracefully - test_clear_user_history_handles_permission_error - test_logger_reuses_existing_handlers Coverage: memory.py 91% → 100%, utils.py 98% → 100% ### 2. Integration Tests (9 tests) - test_integration.py - test_mention_to_response_workflow: Full message flow - test_conversation_context_preserved: Multi-turn conversations - test_config_to_components_integration: Component initialization - test_error_recovery_workflow: Graceful error handling - test_mention_detection_integration_with_nicknames - test_memory_limit_enforcement_in_workflow - test_ambiguous_greeting_workflow - test_logger_integration_with_memory - test_logger_integration_with_ai_provider - test_config_validation_workflow ### 3. Parameterized Tests (45 tests) - 18 mention detection test cases - 17 greeting detection test cases - 8 content extraction test cases - Covers edge cases, unicode, nicknames, false positives ### 4. GitHub Actions CI Workflow - Multi-Python version testing (3.9, 3.10, 3.11, 3.12) - Automated coverage reporting - Code quality checks (Black, isort, flake8) - Codecov integration - Coverage badge generation ## Test Statistics - Tests: 116 → 173 (+49% increase) - Coverage: 97% → 100% (+3pp) - Execution time: ~1.1 seconds - All components: 100% coverage ## Files Modified - tests/test_utils.py: Added parameterized tests and error handling - tests/test_memory.py: Added error handling tests - tests/test_integration.py: NEW - Full integration test suite - tests/README.md: Updated documentation - .github/workflows/test.yml: NEW - CI/CD automation |
||
|---|---|---|
| .github | ||
| tests | ||
| .coveragerc | ||
| .env.example | ||
| .gitignore | ||
| ai_provider.py | ||
| chatbot.py | ||
| CLAUDE.md | ||
| config.py | ||
| eugen_claude.md | ||
| gui.py | ||
| LICENSE | ||
| LICENSE_GUIDE.md | ||
| memory.py | ||
| MODEL_CHANGE.md | ||
| pytest.ini | ||
| README.md | ||
| requirements.txt | ||
| setup_wizard.py | ||
| utils.py | ||
Eugen - Intelligent Twitch Chat Bot
An AI-powered Twitch chat bot specializing in Gaming and 3D Printing topics, powered by Perplexity Sonar API.
Features
- Smart Name Recognition: Automatically responds when mentioned (@Eugen, Eugen:, etc.)
- Persistent Memory: Maintains conversation history per user (max 25 messages)
- Context-Aware: Remembers previous conversations for up to 1 hour
- Perplexity Integration: Uses Perplexity Sonar API for intelligent, real-time responses
- Live Dashboard: GUI monitoring interface showing all activity in real-time
- Topics: Gaming (WoW, Elden Ring), 3D Printing (Prusa, Bambu, Creality), Tech (Python, Linux)
Quick Start
Prerequisites
- Python 3.9+ (3.11+ recommended)
- Twitch account for the bot
- Perplexity API key
Installation
# Clone the repository
git clone https://github.com/Kenearos/KI-Chat-Bot-Eugen.git
cd KI-Chat-Bot-Eugen
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
.\venv\Scripts\Activate.ps1
# On Linux/Mac:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
Configuration
Option 1: Setup Wizard (Recommended)
Run the interactive setup wizard to configure the bot:
python setup_wizard.py
The wizard will:
- Guide you through getting Twitch OAuth token
- Help you set up Perplexity API key
- Validate your credentials
- Create necessary directories and config files
Option 2: Manual Configuration
Copy .env.example to .env and fill in your credentials:
cp .env.example .env
Edit .env with your values:
TWITCH_OAUTH_TOKEN=oauth:your_token_here
TWITCH_BOT_NICKNAME=Eugen
TWITCH_CHANNEL=#your_channel_here
PERPLEXITY_API_KEY=pplx-your_key_here
Getting API Keys
Twitch OAuth Token:
- Visit twitchtokengenerator.com
- Generate token with
chat:readandchat:editscopes - Copy the token (should start with
oauth:)
Perplexity API Key:
- Visit perplexity.ai/api
- Sign up/Login
- Generate new API key
- Copy the key (should start with
pplx-)
Running the Bot
python chatbot.py
The dashboard will open automatically showing live activity.
Usage
Once running, the bot responds when mentioned in Twitch chat:
User: @Eugen what's the best class in WoW?
Eugen: @User The best class depends on your playstyle...
User: Eugen, how do I level my 3D printer?
Eugen: @User For bed leveling, start by...
Project Structure
eugen/
├── chatbot.py # Main entry point
├── config.py # Configuration management
├── gui.py # Dashboard GUI
├── ai_provider.py # Perplexity API integration
├── memory.py # Conversation memory
├── utils.py # Helper functions
├── requirements.txt # Python dependencies
├── .env # Your secrets (DO NOT COMMIT)
├── data/
│ └── conversations/ # User chat histories
└── logs/
├── eugen.log # Main log
└── api_debug.log # API debug logs
Documentation
- CLAUDE.md: Quick reference guide for Claude Code
- eugen_claude.md: Detailed German documentation with architecture and implementation details
Development
The bot is built with:
- Python 3.9+
- Perplexity Sonar API for AI responses
- Twitch IRC for chat integration
- PySimpleGUI for dashboard
- Async/await for concurrent operations
Troubleshooting
Bot doesn't respond:
- Check that .env has correct OAuth token and API key
- Verify bot is in the correct channel
- Check logs/eugen.log for errors
API errors:
- Verify Perplexity API key is valid
- Check your API credits at perplexity.ai
- Enable DEBUG_MODE=true in .env for detailed logs
IRC connection failed:
- Verify internet connection
- Check firewall settings for port 6667
- Regenerate Twitch OAuth token if expired
License
See LICENSE file for details.
Contributing
Contributions welcome! Please open an issue or pull request.