A feature-rich Telegram bot for hosting interactive quiz games with images. Players guess the correct answers to earn points, with support for hints, leaderboards, and administrative controls.
- Image-based quiz questions with text answers
- Point scoring system (5 points per correct answer)
- Hint system with point penalties
- Automatic game progression
- Real-time leaderboard tracking
- Player registration system
- Individual score tracking
- Detailed player statistics
- Customizable hint system
- Interactive game commands
- Game start/stop functionality
- Score reset capabilities
- Next question control
- Participant management
- Pinned message management
- Asynchronous operation
- File-based persistence
- Error handling and logging
- Environment variable configuration
- Modular code structure
- Python 3.8+
- Telegram Bot Token
- Required Python packages:
- python-telegram-bot
- python-dotenv
- httpx
- asyncio
- Clone the repository:
git clone https://github.com/ryuchi311/Telegram-Quiz-Image-Game-Bot.git
cd Telegram-Quiz-Image-Game-Bot
- Install dependencies:
pip install -r requirements.txt- Create a
.envfile with your configuration:
TELEGRAM_BOT_TOKEN=your_bot_token_here
ADMIN_IDS=comma,separated,admin,ids
ONLINE_TIMEOUT=300- Set up the directory structure:
PyGuessgame/
├── Pydata/
│ ├── tokenimage/ # Store quiz images here
│ ├── tokenimage.json # Image metadata
│ └── guessjoin.txt # Player data
├── guessbot.log
└── pyguessinggame.py
python pyguessinggame.py/startpalaro- Start the game bot/join_participate- Join the game/gamerules- View game rules/scores- View current scores/hint- Get a hint (with point penalty)
/start_game- Start a new game session/end_game- End the current game/next_game- Move to next question/reset_scores- Reset all scores
- Players must register using
/join_participate - Each correct answer awards 5 points
- Using hints reduces potential points by 1
- Maximum 4 hints per puzzle
- First correct answer wins points
- Automatic 60-second delay between questions
QuizGameclass: Core game logic and state managementQuizBotclass: Telegram bot implementation and command handling- File-based persistence for player data and game state
- Asynchronous event handling using
python-telegram-bot
- Player data stored in JSON format
- Image metadata in separate JSON file
- Logging system for debugging and monitoring
- Comprehensive error logging
- Graceful failure recovery
- User-friendly error messages
- Admin notification for critical errors
- Admin-only commands protection
- Environment variable configuration
- Safe file handling
- Input validation
- Error logging
The bot maintains detailed logs in guessbot.log:
- Game events
- Error tracking
- Player actions
- Administrative actions
- System status
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
-
Bot not responding
- Check bot token
- Verify internet connection
- Check logs for errors
-
Image loading fails
- Verify image path
- Check file permissions
- Ensure correct file format
-
Admin commands not working
- Verify admin IDs in .env
- Check username spelling
- Ensure proper command format
- python-telegram-bot==20.7
- python-dotenv==1.0.0
- httpx==0.25.2
- asyncio==3.4.3
- Place images in
Pydata/tokenimage/ - Update
tokenimage.json - Follow naming convention
- Edit point values in constants
- Adjust hint penalties
- Customize time delays
- Modify message formats
- Multiple game modes
- Team play support
- Custom hint types
- Achievement system
- Statistics dashboard
- Internationalization