meshai/meshai/commands/base.py
Ubuntu 94d27a634e Remove dead code from living files
Delete unused CommandResult class from commands/base.py and unused
format_dm_response method from responder.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 00:27:49 +00:00

52 lines
1.3 KiB
Python

"""Base classes for command handlers."""
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from ..config import Config
from ..connector import MeshConnector
from ..history import ConversationHistory
@dataclass
class CommandContext:
"""Context passed to command handlers."""
sender_id: str # Node ID of sender
sender_name: str # Display name of sender
channel: int # Channel message was received on
is_dm: bool # True if direct message
position: Optional[tuple[float, float]] # Sender's GPS position (lat, lon)
# References to shared resources
config: "Config"
connector: "MeshConnector"
history: "ConversationHistory"
class CommandHandler(ABC):
"""Base class for bang command handlers."""
# Command name (without !)
name: str = ""
# Brief description for !help
description: str = ""
# Usage example
usage: str = ""
@abstractmethod
async def execute(self, args: str, context: CommandContext) -> str:
"""Execute the command.
Args:
args: Arguments passed after the command (may be empty)
context: Command execution context
Returns:
Response string to send back
"""
pass