"""Telegram Bot API 저수준 래퍼."""
import httpx

from ..config import TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, TELEGRAM_WEBHOOK_URL

_BASE = "https://api.telegram.org/bot"


def _enabled() -> bool:
    return bool(TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID)


async def api_call(method: str, payload: dict) -> dict:
    if not _enabled():
        return {"ok": False, "description": "Telegram not configured"}
    async with httpx.AsyncClient(timeout=10.0) as client:
        resp = await client.post(f"{_BASE}{TELEGRAM_BOT_TOKEN}/{method}", json=payload)
        return resp.json()
