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>
4.4 KiB
4.4 KiB
PetBot Quick Start Guide
Prerequisites Installation
Method 1: Automatic Installation (Recommended)
Run the automatic installation script:
# Make the script executable
chmod +x install_prerequisites.sh
# Run the installation
./install_prerequisites.sh
Or use the Python version:
python3 install_prerequisites.py
Method 2: Manual Installation
If you prefer manual installation:
# Install required packages
pip3 install -r requirements.txt
# Or install individually
pip3 install irc>=20.3.0 aiosqlite>=0.19.0 python-dotenv>=1.0.0
# Create required directories
mkdir -p data backups logs
System Requirements
- Python: 3.7 or higher
- pip: Python package installer
- Operating System: Linux, macOS, or Windows with Python support
Quick Start
1. Install Prerequisites
./install_prerequisites.sh
2. Test Basic Functionality
# Test backup system
python3 test_backup_simple.py
# Test IRC reconnection system
python3 test_reconnection.py
3. Run the Bot
Option A: Debug Mode (Original)
python3 run_bot_debug.py
Option B: With Auto-Reconnect (Recommended)
python3 run_bot_with_reconnect.py
4. Access Web Interface
Open your browser and go to:
- Local: http://localhost:8080
- Production: http://petz.rdx4.com (if configured)
Configuration
IRC Settings
Edit the configuration in the bot files:
config = {
"server": "irc.libera.chat",
"port": 6667,
"nickname": "PetBot",
"channel": "#petz",
"command_prefix": "!"
}
Database
The bot uses SQLite database stored in data/petbot.db. No additional setup required.
Available Commands
Basic Commands
!help- Show available commands!start- Begin your pet journey!stats- View your stats!pets- View your pets
Connection Monitoring
!status- Show bot connection status!uptime- Show bot uptime!ping- Test bot responsiveness
Admin Commands
!backup- Create database backup!restore <filename>- Restore database!reload- Reload bot modules!reconnect- Force IRC reconnection
Troubleshooting
Common Issues
- ModuleNotFoundError: Run the prerequisites installer
- Permission Denied: Make sure scripts are executable (
chmod +x) - Database Errors: Check that
data/directory exists and is writable - IRC Connection Issues: Check network connectivity and IRC server status
Getting Help
- Check the error logs in console output
- Review
CLAUDE.mdfor development guidelines - Check
issues.txtfor known security issues - Review
TODO.mdfor current project status
Log Files
Logs are displayed in the console. For persistent logging, redirect output:
python3 run_bot_with_reconnect.py > logs/bot.log 2>&1
Development
Running Tests
# Test backup system
python3 test_backup_simple.py
# Test reconnection system
python3 test_reconnection.py
Code Structure
PetBot/
├── src/ # Core system
│ ├── database.py # Database operations
│ ├── game_engine.py # Game logic
│ ├── bot.py # IRC bot core
│ ├── irc_connection_manager.py # Connection handling
│ └── backup_manager.py # Backup system
├── modules/ # Command modules
├── config/ # Configuration files
├── webserver.py # Web interface
└── run_bot_*.py # Bot runners
Adding New Commands
- Create a new method in appropriate module
- Add command to
get_commands()list - Test thoroughly
- Update documentation
Security
⚠️ Important: Review issues.txt for security vulnerabilities before production deployment.
Key security considerations:
- Run behind HTTPS reverse proxy
- Review XSS vulnerabilities in web interface
- Implement proper authentication
- Keep dependencies updated
Next Steps
- ✅ Run prerequisites installer
- ✅ Test basic functionality
- ✅ Start the bot
- ✅ Access web interface
- 📋 Review security issues
- 🔧 Configure for production
- 🚀 Deploy and monitor
Support
For issues or questions:
- Check this guide and documentation
- Review error messages and logs
- Test with the provided test scripts
- Check network connectivity and dependencies
Happy bot hosting! 🐾