feat: initialize full-stack architecture with backend routes, database schema, and glassmorphic frontend UI
This commit is contained in:
24
backend/utils/telegram_utils.py
Normal file
24
backend/utils/telegram_utils.py
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
Reference in New Issue
Block a user