import httpx import asyncio import os import sys async def send_telegram_message(message): TELEGRAM_BOT_TOKEN = os.environ.get("T_bot") TELEGRAM_CHAT_ID = os.environ.get("nroChat") if not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID: raise Exception("Telegram bot token or chat ID not set") url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" params = { "chat_id": TELEGRAM_CHAT_ID, "text": message } async with httpx.AsyncClient() as client: response = await client.post(url, params=params) if response.status_code != 200: raise Exception(f"Error sending message: {response.text}") if __name__ == '__main__': if len(sys.argv) > 1: message = sys.argv[1] asyncio.run(send_telegram_message(message))