Refactor bot with 17 issue fixes: logging, caching, error handling, security

- Add RotatingFileHandler for log rotation (fixes #21)
- Add MetricsCollector for command/error tracking (fixes #20)
- Add discord.py cooldown decorator on /ask (fixes #19)
- Add ConfigValidator for startup config checks (fixes #17)
- Add /status health check command for admins (fixes #16)
- Add autocomplete for /minecraft usernames (fixes #15)
- Add AuditLogger with batched queue + periodic flush (fixes #14)
- Add MediaManager with lazy-load cache (fixes #13)
- Add UsernameCache with TTL for Mojang API (fixes #12)
- Extract magic numbers to named constants (fixes #11)
- DRY kill/punch/hug/revive into send_interaction_media (fixes #10)
- Add handle_command_errors decorator for consistent error handling (fixes #9)
- Add sanitize_input() for /ask question input (fixes #8)
- Move Ollama URL to OLLAMA_URL env var (fixes #7)
- Only log commands, not all message content (fixes #6)
- Wrap RCON in async executor with timeout (fixes #5)
- Reuse shared aiohttp.ClientSession on CustomBot (fixes #4)
- Validate RCON/Pelican/Ollama config on startup (fixes #3)
- Replace ask_cooldowns dict with CooldownManager + auto-cleanup (fixes #2)

Note: #18 (MariaDB) deferred - requires database infrastructure setup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-10 20:11:22 -05:00
parent 39cf654603
commit 838198648e

786
bot.py

File diff suppressed because it is too large Load Diff