Skip to content

Advanced IRC trivia bot powered by Mistral AI. Features multi-category quizzes, real-time scoring, and player statistics. Part of the MansionNET IRC Network Bot Suite.

License

Notifications You must be signed in to change notification settings

MansionNET/QuizBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4ca490e ยท Feb 11, 2025

History

15 Commits
Jan 14, 2025
Feb 11, 2025
Jan 13, 2025
Jan 13, 2025
Jan 13, 2025
Jan 16, 2025
Jan 13, 2025
Jan 13, 2025
Jan 13, 2025
Jan 13, 2025

Repository files navigation

QuizBot for IRC

A sophisticated IRC quiz bot powered by Mistral AI that delivers engaging trivia games with dynamic question generation and rich features.

๐ŸŒ IRC Server Details

Join us on MansionNET IRC to chat with us, test the bot, and play some trivia!

  • Server: irc.inthemansion.com
  • Port: 6697 (SSL)
  • Channel: #opers, #general, #welcome, #devs (and many others)

๐ŸŒŸ Features

  • AI-Powered Questions: Uses Mistral AI to generate unique, engaging questions across multiple categories
  • Dynamic Game System: Run multiple concurrent quiz games in different IRC channels
  • Smart Scoring: Points system based on answer speed and winning streaks
  • Rich Categories: Questions from various domains including geography, history, science, arts, entertainment, sports, and more
  • Player Statistics: Track player performance, streaks, and maintain leaderboards
  • Fallback System: Built-in backup questions ensure continuous operation even if AI service is unavailable

๐Ÿš€ Getting Started

Prerequisites

  • Python 3.10 or higher
  • SQLite3
  • Mistral AI API key
  • IRC server access

Installation

  1. Clone the repository:
git clone https://github.com/mansionNET/QuizBot.git
cd quizbot_mansionnet
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Copy the example environment file:
cp .env.example .env
  1. Edit .env with your configuration:
MISTRAL_API_KEY=your_api_key_here
IRC_SERVER=irc.inthemansion.com
IRC_PORT=6697
IRC_NICKNAME=QuizBot
IRC_CHANNELS=#yourchannel
ADMIN_USERS=admin1,admin2
QUESTIONS_PER_GAME=10
QUESTION_TIMEOUT=30
MIN_QUESTIONS=20

Running the Bot

Start the bot:

python src/main.py

๐ŸŽฎ Game Commands

  • !quiz - Start a new quiz game
  • !help - Show available commands
  • !stats - Display your game statistics
  • !leaderboard - Show top players
  • !stop - Stop the current game (admin only)

๐ŸŽฏ Game Rules

  1. Each game consists of a configurable number of questions (default: 10)
  2. Players have a limited time to answer each question (default: 30 seconds)
  3. Points are awarded based on:
    • Speed of answer (faster = more points)
    • Answer streak (consecutive correct answers multiply points)
  4. Only the first correct answer for each question counts
  5. Multiple answer formats are accepted for flexibility

๐Ÿ› ๏ธ Configuration

Key configuration options in .env:

  • QUESTIONS_PER_GAME: Number of questions per game session
  • QUESTION_TIMEOUT: Seconds allowed for answering each question
  • MIN_QUESTIONS: Minimum questions to keep in database
  • BASE_POINTS: Base points for correct answers
  • SPEED_MULTIPLIER_MAX: Maximum multiplier for quick answers

๐Ÿ“š Question Categories

  • Geography
  • History
  • Science
  • Arts
  • Entertainment
  • Sports
  • Food & Drink
  • Nature

๐Ÿงฉ Technical Architecture

  • IRC Service: Handles IRC connection and message routing
  • Game Manager: Manages game states and player interactions
  • Question Service: Generates and manages questions using Mistral AI
  • Database: SQLite storage for questions and player statistics
  • Utilities: Answer validation, scoring, and text processing

๐Ÿ”ง Development

Project Structure

quizbot_mansionnet/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ models/                   # Data models
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ database.py           # Database connection and queries
โ”‚   โ”‚   โ”œโ”€โ”€ question.py           # Question management
โ”‚   โ”‚   โ””โ”€โ”€ quiz_state.py         # Quiz game state handling
โ”‚   โ”œโ”€โ”€ services/                 # Core services
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ irc_service.py        # IRC connection handling
โ”‚   โ”‚   โ”œโ”€โ”€ mistral_service.py    # AI question generation
โ”‚   โ”‚   โ””โ”€โ”€ question_service.py   # Question management service
โ”‚   โ”œโ”€โ”€ utils/                    # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ answer_normalizer.py  # Answer validation
โ”‚   โ”‚   โ”œโ”€โ”€ scoring.py            # Points calculation
โ”‚   โ”‚   โ”œโ”€โ”€ text_processing.py    # Text manipulation utilities
โ”‚   โ”‚   โ””โ”€โ”€ validators.py         # Input validation
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ bot.py                    # Main bot class
โ”‚   โ”œโ”€โ”€ config.py                 # Configuration handling
โ”‚   โ”œโ”€โ”€ game_manager.py           # Game state management
โ”‚   โ””โ”€โ”€ main.py                   # Entry point
โ”œโ”€โ”€ .env                          # Environment configuration
โ”œโ”€โ”€ requirements.txt              # Python dependencies
โ”œโ”€โ”€ setup.py                      # Package setup

Adding New Features

  1. Fork the repository
  2. Create a feature branch
  3. Add your changes
  4. Write/update tests
  5. Submit a pull request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ™ Acknowledgments

  • Mistral AI for the question generation capabilities
  • IRC community for testing and feedback
  • All contributors and users

๐Ÿ“ž Support

For support, please:

  1. Check existing issues
  2. Create a new issue with detailed description
  3. Join our IRC channel for direct help

About

Advanced IRC trivia bot powered by Mistral AI. Features multi-category quizzes, real-time scoring, and player statistics. Part of the MansionNET IRC Network Bot Suite.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published