Spaces:
Sleeping
Sleeping
Upload handler.py
Browse files- 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 |
-
|
|
|
|
| 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 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
| 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}")
|