#!/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 @staticmethod def normalize_input(user_input): """Normalize user input by converting to lowercase for case-insensitive command processing""" if isinstance(user_input, str): return user_input.lower() elif isinstance(user_input, list): return [item.lower() if isinstance(item, str) else item for item in user_input] return user_input @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