Update bot.py
Browse files
bot.py
CHANGED
|
@@ -14,8 +14,6 @@ logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s", level=lo
|
|
| 14 |
|
| 15 |
# Get environment variables
|
| 16 |
TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
|
| 17 |
-
print(f"Telegram Token: {TOKEN[:5]}********")
|
| 18 |
-
|
| 19 |
if not TOKEN:
|
| 20 |
raise ValueError("Missing Telegram token. Please set TELEGRAM_BOT_TOKEN in environment variables.")
|
| 21 |
|
|
@@ -72,5 +70,16 @@ async def main():
|
|
| 72 |
await application.run_polling()
|
| 73 |
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
if __name__ == "__main__":
|
| 76 |
asyncio.run(main())
|
|
|
|
| 14 |
|
| 15 |
# Get environment variables
|
| 16 |
TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
|
|
|
|
|
|
|
| 17 |
if not TOKEN:
|
| 18 |
raise ValueError("Missing Telegram token. Please set TELEGRAM_BOT_TOKEN in environment variables.")
|
| 19 |
|
|
|
|
| 70 |
await application.run_polling()
|
| 71 |
|
| 72 |
|
| 73 |
+
async def test_telegram_connection():
|
| 74 |
+
try:
|
| 75 |
+
async with httpx.AsyncClient() as client:
|
| 76 |
+
response = await client.get("https://api.telegram.org")
|
| 77 |
+
print(f"Telegram API Status: {response.status_code}")
|
| 78 |
+
except Exception as e:
|
| 79 |
+
print(f"Error connecting to Telegram API: {e}")
|
| 80 |
+
|
| 81 |
+
asyncio.run(test_telegram_connection())
|
| 82 |
+
|
| 83 |
+
|
| 84 |
if __name__ == "__main__":
|
| 85 |
asyncio.run(main())
|