Itsjustamit commited on
Commit
a2e57d4
·
verified ·
1 Parent(s): e4bb15d

Upload handler.py

Browse files
Files changed (1) hide show
  1. app/telegram/handler.py +7 -3
app/telegram/handler.py CHANGED
@@ -100,12 +100,16 @@ class TelegramHandler:
100
 
101
  def _send_message(self, chat_id: int, text: str) -> None:
102
  if not self.bot_token:
 
103
  return
104
  try:
105
- requests.post(
 
106
  f"https://api.telegram.org/bot{self.bot_token}/sendMessage",
107
  json={"chat_id": chat_id, "text": text, "parse_mode": "HTML"},
108
  timeout=20,
109
  )
110
- except requests.RequestException:
111
- return
 
 
 
100
 
101
  def _send_message(self, chat_id: int, text: str) -> None:
102
  if not self.bot_token:
103
+ print("ERROR: BOT_TOKEN is totally empty or missing in environment variables!")
104
  return
105
  try:
106
+ print(f"Attempting to send message to {chat_id}...")
107
+ response = requests.post(
108
  f"https://api.telegram.org/bot{self.bot_token}/sendMessage",
109
  json={"chat_id": chat_id, "text": text, "parse_mode": "HTML"},
110
  timeout=20,
111
  )
112
+ print(f"Telegram API Response: HTTP {response.status_code} - {response.text}")
113
+ response.raise_for_status()
114
+ except requests.RequestException as e:
115
+ print(f"Telegram Request Failed: {e}")