"""Hook channel — receives outbound messages from hook-initiated conversations."""

from loguru import logger

from nanobot.bus.events import OutboundMessage
from nanobot.bus.queue import MessageBus


class HookChannel:
    """
    Minimal channel for hook-initiated conversations.

    The hook HTTP server publishes InboundMessages to the bus.
    Responses come back as OutboundMessages routed here.
    send() is a no-op because the HTTP caller gets the response
    via bus correlation, not channel delivery.
    """

    name = "hook"

    def __init__(self, bus: MessageBus):
        self.bus = bus
        self._running = False

    async def start(self) -> None:
        self._running = True
        logger.info("Hook channel started")

    async def stop(self) -> None:
        self._running = False

    async def send(self, msg: OutboundMessage) -> None:
        """No-op — response is returned via bus correlation to the HTTP caller."""
        logger.debug(f"Hook channel received outbound for {msg.chat_id} (no-op)")

    @property
    def is_running(self) -> bool:
        return self._running
