Petbot/rate_limiting_config.json
megaproxy 915aa00bea 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>
2025-07-15 20:10:43 +00:00

61 lines
No EOL
2.1 KiB
JSON

{
"rate_limiting": {
"enabled": true,
"description": "Rate limiting configuration for PetBot IRC commands and web interface",
"categories": {
"basic": {
"description": "Basic commands like !help, !ping, !status",
"requests_per_minute": 20,
"burst_capacity": 5,
"cooldown_seconds": 1,
"commands": ["help", "ping", "status", "uptime", "connection_stats"]
},
"gameplay": {
"description": "Gameplay commands like !explore, !catch, !battle",
"requests_per_minute": 10,
"burst_capacity": 3,
"cooldown_seconds": 3,
"commands": ["start", "explore", "catch", "battle", "attack", "moves", "flee", "travel", "weather", "gym"]
},
"management": {
"description": "Pet and inventory management commands",
"requests_per_minute": 5,
"burst_capacity": 2,
"cooldown_seconds": 5,
"commands": ["pets", "activate", "deactivate", "stats", "inventory", "use", "nickname"]
},
"admin": {
"description": "Administrative commands",
"requests_per_minute": 100,
"burst_capacity": 10,
"cooldown_seconds": 0,
"commands": ["backup", "restore", "backups", "backup_stats", "backup_cleanup", "reload", "reconnect", "rate_stats", "rate_user", "rate_unban", "rate_reset"]
},
"web": {
"description": "Web interface requests",
"requests_per_minute": 60,
"burst_capacity": 10,
"cooldown_seconds": 1
}
},
"admin_users": ["admin", "megaproxy", "megasconed"],
"global_limits": {
"max_requests_per_minute": 200,
"max_concurrent_users": 100,
"description": "Global limits across all users and commands"
},
"violation_penalties": {
"warning_threshold": 3,
"temporary_ban_threshold": 10,
"temporary_ban_duration": 300,
"description": "Penalties for rate limit violations (ban duration in seconds)"
},
"monitoring": {
"log_violations": true,
"log_bans": true,
"stats_reporting_interval": 300,
"cleanup_interval": 60,
"description": "Monitoring and logging configuration"
}
}
}