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:
megaproxy 2025-07-15 20:10:43 +00:00
parent f8ac661cd1
commit 915aa00bea
28 changed files with 5730 additions and 57 deletions

View file

@ -1,4 +1,9 @@
{
"_config": {
"global_spawn_multiplier": 1.0,
"description": "Global multiplier for all item spawn rates. Set to 0.5 for half spawns, 2.0 for double spawns, etc.",
"admin_note": "Edit this value to globally adjust all item spawn rates. Individual item spawn_rate values can still be fine-tuned."
},
"healing_items": [
{
"id": 1,
@ -9,7 +14,7 @@
"effect": "heal",
"effect_value": 20,
"locations": ["all"],
"spawn_rate": 0.15
"spawn_rate": 0.0375
},
{
"id": 2,
@ -20,7 +25,7 @@
"effect": "heal",
"effect_value": 50,
"locations": ["all"],
"spawn_rate": 0.08
"spawn_rate": 0.02
},
{
"id": 3,
@ -31,7 +36,7 @@
"effect": "full_heal",
"effect_value": 100,
"locations": ["all"],
"spawn_rate": 0.03
"spawn_rate": 0.0075
},
{
"id": 4,
@ -42,7 +47,7 @@
"effect": "heal_status",
"effect_value": 15,
"locations": ["mystic_forest", "enchanted_grove"],
"spawn_rate": 0.12
"spawn_rate": 0.03
}
],
"battle_items": [
@ -55,7 +60,7 @@
"effect": "attack_boost",
"effect_value": 25,
"locations": ["all"],
"spawn_rate": 0.10
"spawn_rate": 0.025
},
{
"id": 6,
@ -66,7 +71,7 @@
"effect": "defense_boost",
"effect_value": 20,
"locations": ["crystal_caves", "frozen_peaks"],
"spawn_rate": 0.08
"spawn_rate": 0.02
},
{
"id": 7,
@ -77,7 +82,7 @@
"effect": "speed_boost",
"effect_value": 100,
"locations": ["all"],
"spawn_rate": 0.05
"spawn_rate": 0.0125
}
],
"rare_items": [
@ -90,7 +95,7 @@
"effect": "none",
"effect_value": 0,
"locations": ["volcanic_chamber"],
"spawn_rate": 0.02
"spawn_rate": 0.005
},
{
"id": 9,
@ -101,7 +106,7 @@
"effect": "none",
"effect_value": 0,
"locations": ["crystal_caves"],
"spawn_rate": 0.02
"spawn_rate": 0.005
},
{
"id": 10,
@ -112,7 +117,7 @@
"effect": "lucky_boost",
"effect_value": 50,
"locations": ["all"],
"spawn_rate": 0.01
"spawn_rate": 0.0025
},
{
"id": 11,
@ -123,7 +128,7 @@
"effect": "none",
"effect_value": 0,
"locations": ["forgotten_ruins"],
"spawn_rate": 0.01
"spawn_rate": 0.0025
}
],
"location_items": [
@ -136,7 +141,7 @@
"effect": "sell_value",
"effect_value": 100,
"locations": ["crystal_caves"],
"spawn_rate": 0.12
"spawn_rate": 0.03
},
{
"id": 13,
@ -147,7 +152,7 @@
"effect": "sell_value",
"effect_value": 200,
"locations": ["mystic_forest", "enchanted_grove"],
"spawn_rate": 0.06
"spawn_rate": 0.015
},
{
"id": 14,
@ -158,7 +163,7 @@
"effect": "sell_value",
"effect_value": 150,
"locations": ["volcanic_chamber"],
"spawn_rate": 0.10
"spawn_rate": 0.025
},
{
"id": 15,
@ -169,7 +174,7 @@
"effect": "sell_value",
"effect_value": 250,
"locations": ["frozen_peaks"],
"spawn_rate": 0.05
"spawn_rate": 0.0125
},
{
"id": 16,
@ -180,7 +185,7 @@
"effect": "sell_value",
"effect_value": 500,
"locations": ["forgotten_ruins"],
"spawn_rate": 0.03
"spawn_rate": 0.0075
}
],
"rarity_info": {