Implement comprehensive rate limiting system and item spawn configuration
Major Features Added: - Complete token bucket rate limiting for IRC commands and web interface - Per-user rate tracking with category-based limits (Basic, Gameplay, Management, Admin, Web) - Admin commands for rate limit management (\!rate_stats, \!rate_user, \!rate_unban, \!rate_reset) - Automatic violation tracking and temporary bans with cleanup - Global item spawn multiplier system with 75% spawn rate reduction - Central admin configuration system (config.py) - One-command bot startup script (start_petbot.sh) Rate Limiting: - Token bucket algorithm with burst capacity and refill rates - Category limits: Basic (20/min), Gameplay (10/min), Management (5/min), Web (60/min) - Graceful violation handling with user-friendly error messages - Admin exemption and override capabilities - Background cleanup of old violations and expired bans Item Spawn System: - Added global_spawn_multiplier to config/items.json for easy adjustment - Reduced all individual spawn rates by 75% (multiplied by 0.25) - Admins can fine-tune both global multiplier and individual item rates - Game engine integration applies multiplier to all spawn calculations Infrastructure: - Single admin user configuration in config.py - Enhanced startup script with dependency management and verification - Updated documentation and help system with rate limiting guide - Comprehensive test suite for rate limiting functionality Security: - Rate limiting protects against command spam and abuse - IP-based tracking for web interface requests - Proper error handling and status codes (429 for rate limits) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f8ac661cd1
commit
915aa00bea
28 changed files with 5730 additions and 57 deletions
32
CLAUDE.md
32
CLAUDE.md
|
|
@ -25,11 +25,23 @@ PetBot is a Discord/IRC Pokemon-style pet collecting bot with web interface. The
|
|||
- Use Read tool for examining specific file content
|
||||
- Use Glob tool for finding files by name patterns
|
||||
|
||||
### 3. Testing and Validation
|
||||
- Always run `python3 -c "import webserver; print('✅ syntax check')"` after webserver changes
|
||||
- Test database operations with simple validation scripts
|
||||
- Check IRC bot functionality with `python3 run_bot_debug.py`
|
||||
- Verify web interface functionality through browser testing
|
||||
### 3. Bot Startup and Testing
|
||||
- **Primary Startup**: `./start_petbot.sh` - One command that handles everything
|
||||
- Automatically creates/activates virtual environment
|
||||
- Installs/updates all dependencies
|
||||
- Verifies core modules
|
||||
- Creates required directories
|
||||
- Launches bot with all features (IRC + web interface + rate limiting)
|
||||
- **Rate Limiting Tests**: `source venv/bin/activate && python test_rate_limiting.py`
|
||||
- **Web Interface**: Available at http://localhost:8080 after startup
|
||||
- **Virtual Environment**: Required due to externally-managed-environment restriction
|
||||
|
||||
### 4. Important: Configuration Management
|
||||
- **Admin User**: Edit `config.py` to change the single admin user (currently: megasconed)
|
||||
- **Item Spawn Rates**: Edit `config/items.json` to adjust global spawn multiplier and individual rates
|
||||
- **Startup Script**: Always update `start_petbot.sh` when adding dependencies
|
||||
- **Central Config**: All major settings are in `config.py` for easy maintenance
|
||||
- **Remember**: This is the user's primary interface - keep it working!
|
||||
|
||||
## Project Structure
|
||||
|
||||
|
|
@ -51,8 +63,14 @@ PetBot is a Discord/IRC Pokemon-style pet collecting bot with web interface. The
|
|||
│ ├── admin.py # Administrative commands
|
||||
│ └── team_builder.py # Team builder module (web-only)
|
||||
├── webserver.py # Web server with unified templates
|
||||
├── run_bot_debug.py # Bot startup and debug mode
|
||||
├── help.html # Static help documentation
|
||||
├── run_bot_with_reconnect.py # Main bot with IRC reconnection and rate limiting
|
||||
├── start_petbot.sh # One-command startup script (handles venv and dependencies)
|
||||
├── config.py # Central configuration (admin user, IRC, rate limiting)
|
||||
├── config/items.json # Item configuration with global spawn multiplier
|
||||
├── test_rate_limiting.py # Comprehensive rate limiting test suite
|
||||
├── requirements.txt # Python package dependencies
|
||||
├── rate_limiting_config.json # Rate limiting configuration reference
|
||||
├── help.html # Static help documentation with rate limiting info
|
||||
├── CHANGELOG.md # Version history and feature tracking
|
||||
└── README.md # Project documentation
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue