21 lines
694 B
Python
21 lines
694 B
Python
# notification_manager.py
|
|
import requests
|
|
|
|
def send_telegram_notification(bot_token: str, chat_id: str, message: str) -> dict:
|
|
"""
|
|
텔레그램 봇을 통해 메시지를 전송합니다.
|
|
|
|
:param bot_token: 텔레그램 봇 토큰
|
|
:param chat_id: 메시지를 받을 채팅 ID
|
|
:param message: 전송할 메시지
|
|
:return: API 응답 (JSON)
|
|
"""
|
|
url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
|
|
payload = {"chat_id": chat_id, "text": message}
|
|
try:
|
|
response = requests.post(url, data=payload)
|
|
return response.json()
|
|
except Exception as e:
|
|
print("Telegram notification error:", e)
|
|
return {"error": str(e)}
|