"""
Telegram Bot — Send Message Demo
=================================
A minimal, ready-to-run example of sending a message with a Telegram bot.

Get a bot token (free, no signup form):
    1. In Telegram, open a chat with @BotFather.
    2. Send /newbot and follow the prompts; BotFather replies with your
       bot token.
    3. Get your chat ID: message your new bot, then open
       https://api.telegram.org/bot<TOKEN>/getUpdates and read
       result[].message.chat.id (or message @userinfobot).

Setup:
    pip install requests
    export TELEGRAM_BOT_TOKEN="123456:ABC..."
    export TELEGRAM_CHAT_ID="..."     # the chat/channel to send to

Run:
    python telegram_demo.py
"""

import os
import requests


def send_message(text: str) -> dict:
    """Send a message via a Telegram bot and return the API response."""
    token = os.environ.get("TELEGRAM_BOT_TOKEN")
    response = requests.post(
        f"https://api.telegram.org/bot{token}/sendMessage",
        json={"chat_id": os.environ.get("TELEGRAM_CHAT_ID"), "text": text},
    )
    response.raise_for_status()
    return response.json()


if __name__ == "__main__":
    result = send_message("Hello from krueng.ai 👋")
    print(f"OK: {result['ok']}")
