Note (2025-07): The Drunk role has been deprecated and removed from gameplay. Any references below are for historical context only and do not reflect current gameplay.
A sophisticated Telegram bot implementing the "Truth Wars" game - an educational multiplayer social deduction experience that teaches media literacy through interactive gameplay. Players vote on headlines to determine if they're real or fake while taking on special roles with unique abilities in a strategic battle between Truth Seekers and Misinformers.
Truth Wars combines social deduction with media literacy education in an engaging 5-round format:
- 5-8 players engage in a fixed 5-round structure (optimized for 45-minute games)
- Trust/Flag voting on carefully curated real and fake headlines
- Dynamic reputation system starting with 3 RP, becoming Ghost Viewer at 0 RP
- Role-based gameplay with strategic abilities:
- Fact Checker (Truth Team) - Gets insider info, can snipe suspected Scammers
- Scammer (Misinformation Team) - Spreads doubt, manipulates votes
- Influencer (Truth Team, 7+ players) - Double-weighted votes (2x voting power)
- Normies (Truth Team) - Standard players, learn through gameplay
- Snipe abilities for strategic shadow banning (Rounds 1-4 only)
- Educational content seamlessly integrated through gameplay mechanics
- Win conditions: First faction to 3 points OR highest combined reputation after 5 rounds
- Real-world headlines from credible news sources
- Carefully crafted fake news with common misinformation patterns
- Detailed explanations after each vote revealing truth and teaching detection techniques
- Media literacy concepts taught through gameplay and post-round explanations
- Progressive difficulty from easy to hard headlines across 5 rounds
- 3 Reputation Points starting system - lose 1 for incorrect votes, gain 1 for correct votes
- Ghost Viewer mechanics - 0 RP players can vote but cannot speak during discussions
- Strategic depth - Shadow banned players lose voice but retain voting power
- Comprehensive tracking - All reputation changes logged with detailed reasoning
- Faction warfare between Truth Seekers and Misinformers
- One-time snipe abilities (Rounds 1-4) create high-stakes tactical moments
- Influencer mechanics - Double-weighted votes can swing close decisions (7+ players)
- Blind rounds - Fact Checker occasionally doesn't get insider information
- [Historical: Educational role rotation (Drunk role) was used in earlier versions]
- Individual statistics - Win rates, accuracy, role performance
- Learning analytics - Media literacy improvement over time
- Game history - Detailed records of all games and decisions
- Leaderboards - Top players by wins, accuracy, and learning progress
truthchecker/
โโโ bot/ # Main bot application
โ โโโ ai/ # AI headline generation & content curation
โ โ โโโ headline_generator.py
โ โโโ database/ # Async SQLAlchemy models & database management
โ โ โโโ models.py # Complete game data models
โ โ โโโ database.py # Database session management
โ โโโ game/ # Core game logic & state management
โ โ โโโ truth_wars_manager.py # Central game orchestrator
โ โ โโโ refined_game_states.py # Phase-based state machine
โ โ โโโ roles.py # Role system & abilities
โ โโโ handlers/ # Telegram command/message handlers
โ โ โโโ command_handlers.py # Basic bot commands
โ โ โโโ truth_wars_handlers.py # Game-specific handlers
โ โ โโโ message_handlers.py # Chat message processing
โ โ โโโ error_handlers.py # Error handling & recovery
โ โโโ utils/ # Shared utilities & configuration
โ โ โโโ config.py # Environment configuration
โ โ โโโ logging_config.py # Structured logging setup
โ โโโ main.py # Bot entry point & application setup
โโโ docs/ # Comprehensive documentation
โ โโโ ARCHITECTURE.md # Technical architecture overview
โ โโโ DATABASE_SCHEMA_REFINED.md # Complete database schema
โ โโโ BOTFATHER_SETUP.md # Bot configuration guide
โ โโโ PROJECT_DOCUMENTATION.md # Development documentation
โ โโโ ROADMAP.md # Future development plans
โ โโโ SETUP_GUIDE.md # Quick setup instructions
โ โโโ TRUTH_WARSV2.md # Game design evolution
โ โโโ TRUTH_WARSV3.md # Current game design
โ โโโ V3_IMPLEMENTATION.md # Implementation details
โโโ tests/ # Comprehensive test suite
โ โโโ test_example.py # Basic functionality tests
โ โโโ test_truthwars_v3.py # Game logic tests
โ โโโ test_dm_mock.py
โ โโโ test_duplicate_and_swap.py
โ โโโ test_state_machine_actions.py
โ โโโ test_state_machine_branches.py
โ โโโ test_state_machine_flow.py
โโโ deploy/ # Deployment configurations
โโโ run_bot.py # Simple launcher script
โโโ requirements.txt # Python dependencies
โโโ game.db # SQLite development database
โโโ README.md # This file
- Python 3.8+ (3.9+ recommended)
- Telegram Bot Token (from @BotFather)
- Group Chat (Truth Wars requires 5-8 players)
-
Clone the repository
git clone https://github.com/Soba101/truthchecker.git cd truthchecker -
Install dependencies
pip install -r requirements.txt
-
Configure environment
-
Start the bot
python run_bot.py
# Required: Get this from @BotFather on Telegram
TELEGRAM_BOT_TOKEN=your_bot_token_here
# Optional: Database configuration (defaults to SQLite)
DATABASE_URL=sqlite+aiosqlite:///game.db
# Optional: Environment settings
ENVIRONMENT=development
LOG_LEVEL=INFO
# Optional: AI/Content settings
OPENAI_API_KEY=your_openai_key_here # For AI headline generation
CONTENT_MODERATION=true/start- Welcome message and bot introduction/help- Complete game guide and instructions/stats- View your personal game statistics and learning progress/leaderboard- See top players by wins, accuracy, and media literacy
/truthwars- Start a new Truth Wars game lobby/status- Check current game status, round info, and player roles/ability- View your current role, abilities, and use special powers/vote- Cast elimination votes during player voting phase (if enabled)
- Trust/Flag Buttons - Vote on headlines during voting phases
- Snipe Targeting - Use special abilities to shadow ban opponents
- Join/Start Game - Lobby management through inline keyboards
- Continue Game - Progress through rounds via button presses
- Bot Framework: python-telegram-bot 21.5+
- Database: SQLite with SQLAlchemy 2.0 (async ORM)
- Configuration: Pydantic with environment variable validation
- Logging: Structlog for structured, contextual logging
- Testing: Pytest with async support and fixtures
- Data Storage: JSON fields for flexible game state and analytics
- Content: Curated real/fake headlines with educational explanations
- โ Full game implementation with optimized 5-round structure
- โ Reputation system with 3 RP starting points and Ghost Viewer mechanics
- โ Trust/Flag voting with weighted votes and accuracy tracking
- โ Complete role system with Fact Checker, Scammer, Influencer, Normie
- โ Snipe mechanics for strategic shadow banning (Rounds 1-4)
- โ Educational content delivery via post-round explanations and gameplay (Drunk role deprecated)
- โ Comprehensive statistics tracking individual and game performance
- โ Database schema with complete relationship mapping and analytics support
- โ Error handling and recovery mechanisms for robust gameplay
- โ Performance optimization for concurrent game management
- ๐ Advanced analytics dashboard for learning insights and improvement tracking
- ๐ Additional headline content with expanded categories and difficulty progression
- ๐ Multi-language support for international accessibility
- ๐ Tournament mode for competitive educational events
- ๐ Admin controls for game moderation and content management
- ๐ Custom headline submission system with community curation
- ๐ Integration with fact-checking APIs for real-time content verification
- ๐ Advanced AI opponent for single-player practice mode
Run the comprehensive test suite:
# Run all tests with coverage
pytest --cov=bot --cov-report=html
# Run specific test files
pytest tests/test_example.py
pytest tests/test_truthwars_v3.py
pytest tests/test_dm_mock.py
pytest tests/test_duplicate_and_swap.py
pytest tests/test_state_machine_actions.py
pytest tests/test_state_machine_branches.py
pytest tests/test_state_machine_flow.py
# Run with verbose output
pytest -v --tb=shortComprehensive documentation is available in the docs/ directory:
- Architecture Overview - Technical system architecture
- Database Schema - Complete data model documentation
- Project Documentation - Development guide and code structure
- Truth Wars v3 Design - Current game mechanics and rules
- Implementation Guide - Technical implementation details
- Design Evolution - Game design history and decisions
- Setup Guide - Step-by-step installation instructions
- BotFather Setup - Telegram bot configuration
- Development Roadmap - Future development plans
This project follows clean code principles and educational best practices:
- Write simple, readable code with clear documentation and comments
- Keep files focused and modular (<200 lines when possible)
- Test thoroughly after every meaningful change with automated tests
- Use clear, consistent naming throughout the codebase
- Include explanatory comments for complex logic and game mechanics
- Fork the repository and create a feature branch
- Write tests for new functionality before implementation
- Implement changes following existing code patterns
- Update documentation to reflect changes
- Run full test suite to ensure no regressions
- Submit pull request with detailed description
- Unit tests for all new functions and classes
- Integration tests for game flow and database operations
- Performance tests for concurrent game handling
- Edge case testing for error conditions and recovery
Truth Wars is designed to teach essential media literacy skills through engaging gameplay:
- Source Verification - How to research and verify news source credibility
- Fact-Checking Techniques - Using multiple sources and verification tools
- Publication Date Awareness - Understanding timing and context of news
- Author Credibility - Evaluating journalist expertise and bias
- Bias Recognition - Identifying language bias, loaded terms, and framing
- Logical Fallacy Detection - Spotting common reasoning errors
- Evidence Assessment - Evaluating quality and relevance of supporting evidence
- Emotional Manipulation - Recognizing appeals to fear, anger, and prejudice
- Sensationalist Headlines - Identifying clickbait and exaggerated claims
- Suspicious Sources - Recognizing fake news websites and unreliable publishers
- Fabricated Content - Detecting doctored images, false quotes, and manufactured stories
- Conspiracy Theories - Understanding common patterns and logical flaws
- Information Seeking - Developing habits of verification and cross-referencing
- Confirmation Bias Awareness - Recognizing and countering personal biases
- Media Ecosystem Understanding - Learning how information spreads and mutates
- Digital Citizenship - Responsible sharing and consumption of online content
- Async architecture for concurrent game management
- State machine implementation for reliable phase transitions
- Comprehensive error handling with graceful degradation
- Performance optimization for large group chats
- Individual progress tracking across multiple game sessions
- Learning effectiveness measurement through accuracy improvement
- Content performance analysis for headline difficulty optimization
- Behavioral pattern recognition for personalized learning paths
- Input validation and sanitization for all user inputs
- Rate limiting to prevent abuse and spam
- Minimal data collection with focus on educational analytics
- Secure token management for bot authentication
MIT License - see LICENSE file for details.
- Setup Issues: Check Setup Guide for detailed instructions
- Bot Configuration: See BotFather Setup for Telegram configuration
- Game Rules: Use
/helpcommand in Telegram for complete game guide - Technical Issues: Check logs for error messages and debugging information
- Bot not responding: Verify token and network connectivity
- Commands showing @username: Configure privacy settings in BotFather
- Database errors: Check file permissions and disk space
- Group chat issues: Ensure bot has proper administrator permissions
- Documentation: Comprehensive guides in the
docs/directory - Error Logs: Enable debug logging for detailed error information
- Community: Join our development discussions and issue tracking
- Support: Submit detailed bug reports with reproduction steps
Truth Wars - Teaching media literacy through engaging social gameplay ๐๐ฐ๐ฎ