from __future__ import annotations

import html
import logging

from src.config import settings

logger = logging.getLogger(__name__)


def send(bot, title: str, body: str = "") -> None:
    if not settings.log_channel_id:
        return
    text = f"<b>{html.escape(title)}</b>"
    if body:
        text += f"\n\n{html.escape(body)}"
    try:
        bot.send_message(settings.log_channel_id, text, parse_mode="HTML")
    except Exception:
        logger.exception("Gagal mengirim log ke channel")
