"""Gateway 抽象基类 - 多通道统一接口。"""

from abc import ABC, abstractmethod
from typing import Any, Callable, Optional


class BaseGateway(ABC):
    """消息通道网关基类。

    所有通道（Telegram、NapCat/QQ、未来其他）统一实现此接口。
    消息回调签名: async (user_id: str, content: str, channel: str) -> None
    """

    name: str = ""

    def __init__(self) -> None:
        self._message_handler: Optional[Callable[[str, str, str], Any]] = None

    def on_message(self, handler: Callable[[str, str, str], Any]) -> None:
        """注册消息回调。"""
        self._message_handler = handler

    @abstractmethod
    async def start(self) -> None:
        """启动网关（连接、轮询等）。"""

    @abstractmethod
    async def stop(self) -> None:
        """停止网关。"""

    @abstractmethod
    async def send_message(self, user_id: str, text: str) -> None:
        """向指定用户发送消息。"""
