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>
206 lines
No EOL
4.4 KiB
Markdown
206 lines
No EOL
4.4 KiB
Markdown
# PetBot Quick Start Guide
|
|
|
|
## Prerequisites Installation
|
|
|
|
### Method 1: Automatic Installation (Recommended)
|
|
|
|
Run the automatic installation script:
|
|
|
|
```bash
|
|
# Make the script executable
|
|
chmod +x install_prerequisites.sh
|
|
|
|
# Run the installation
|
|
./install_prerequisites.sh
|
|
```
|
|
|
|
Or use the Python version:
|
|
|
|
```bash
|
|
python3 install_prerequisites.py
|
|
```
|
|
|
|
### Method 2: Manual Installation
|
|
|
|
If you prefer manual installation:
|
|
|
|
```bash
|
|
# 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
|
|
|
|
```bash
|
|
./install_prerequisites.sh
|
|
```
|
|
|
|
### 2. Test Basic Functionality
|
|
|
|
```bash
|
|
# 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)
|
|
```bash
|
|
python3 run_bot_debug.py
|
|
```
|
|
|
|
#### Option B: With Auto-Reconnect (Recommended)
|
|
```bash
|
|
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:
|
|
|
|
```python
|
|
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
|
|
|
|
1. **ModuleNotFoundError**: Run the prerequisites installer
|
|
2. **Permission Denied**: Make sure scripts are executable (`chmod +x`)
|
|
3. **Database Errors**: Check that `data/` directory exists and is writable
|
|
4. **IRC Connection Issues**: Check network connectivity and IRC server status
|
|
|
|
### Getting Help
|
|
|
|
1. Check the error logs in console output
|
|
2. Review `CLAUDE.md` for development guidelines
|
|
3. Check `issues.txt` for known security issues
|
|
4. Review `TODO.md` for current project status
|
|
|
|
### Log Files
|
|
|
|
Logs are displayed in the console. For persistent logging, redirect output:
|
|
|
|
```bash
|
|
python3 run_bot_with_reconnect.py > logs/bot.log 2>&1
|
|
```
|
|
|
|
## Development
|
|
|
|
### Running Tests
|
|
|
|
```bash
|
|
# 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
|
|
|
|
1. Create a new method in appropriate module
|
|
2. Add command to `get_commands()` list
|
|
3. Test thoroughly
|
|
4. 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
|
|
|
|
1. ✅ Run prerequisites installer
|
|
2. ✅ Test basic functionality
|
|
3. ✅ Start the bot
|
|
4. ✅ Access web interface
|
|
5. 📋 Review security issues
|
|
6. 🔧 Configure for production
|
|
7. 🚀 Deploy and monitor
|
|
|
|
## Support
|
|
|
|
For issues or questions:
|
|
1. Check this guide and documentation
|
|
2. Review error messages and logs
|
|
3. Test with the provided test scripts
|
|
4. Check network connectivity and dependencies
|
|
|
|
Happy bot hosting! 🐾 |