🎮 Features implemented: - Pokemon-style pet collection and battles - Multi-location exploration system - Dynamic weather with background updates - Achievement system with location unlocks - Web dashboard for player stats - Modular command system - Async database with SQLite - PM flood prevention - Persistent player data 🌤️ Weather System: - 6 weather types with spawn modifiers - 30min-3hour dynamic durations - Background task for automatic updates - Location-specific weather patterns 🐛 Recent Bug Fixes: - Database persistence on restart - Player page SQLite row conversion - Achievement count calculations - Travel requirement messages - Battle move color coding - Locations page display 🔧 Generated with Claude Code 🤖 Co-Authored-By: Claude <noreply@anthropic.com>
43 lines
No EOL
1.3 KiB
Python
43 lines
No EOL
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Base module class for PetBot command modules"""
|
|
|
|
import asyncio
|
|
from abc import ABC, abstractmethod
|
|
|
|
class BaseModule(ABC):
|
|
"""Base class for all PetBot modules"""
|
|
|
|
def __init__(self, bot, database, game_engine):
|
|
self.bot = bot
|
|
self.database = database
|
|
self.game_engine = game_engine
|
|
|
|
@abstractmethod
|
|
def get_commands(self):
|
|
"""Return list of commands this module handles"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def handle_command(self, channel, nickname, command, args):
|
|
"""Handle a command for this module"""
|
|
pass
|
|
|
|
def send_message(self, target, message):
|
|
"""Send message through the bot"""
|
|
self.bot.send_message(target, message)
|
|
|
|
def send_pm(self, nickname, message):
|
|
"""Send private message to user"""
|
|
self.bot.send_message(nickname, message)
|
|
|
|
async def get_player(self, nickname):
|
|
"""Get player from database"""
|
|
return await self.database.get_player(nickname)
|
|
|
|
async def require_player(self, channel, nickname):
|
|
"""Get player or send start message if not found"""
|
|
player = await self.get_player(nickname)
|
|
if not player:
|
|
self.send_message(channel, f"{nickname}: Use !start to begin your journey first!")
|
|
return None
|
|
return player |