import requests import os def send_telegram_notification(message): token = os.getenv('TELEGRAM_BOT_TOKEN') chat_id = os.getenv('TELEGRAM_CHAT_ID') if not token or not chat_id: print("Telegram notification skipped: Token or Chat ID not configured.") return False url = f"https://api.telegram.org/bot{token}/sendMessage" payload = { "chat_id": chat_id, "text": message, "parse_mode": "HTML" } try: response = requests.post(url, json=payload, timeout=5) return response.status_code == 200 except Exception as e: print(f"Error sending Telegram message: {e}") return False