Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,7 +29,7 @@ async def error_handler(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
| 29 |
)
|
| 30 |
|
| 31 |
# Set up and run the Telegram bot
|
| 32 |
-
async def
|
| 33 |
if not TELEGRAM_BOT_TOKEN:
|
| 34 |
print("Telegram bot token not found. Please set TELEGRAM_BOT_TOKEN in the Space secrets.")
|
| 35 |
return
|
|
@@ -57,10 +57,6 @@ async def setup_and_run_bot():
|
|
| 57 |
print("Starting Telegram bot...")
|
| 58 |
await application.run_polling(allowed_updates=Update.ALL_TYPES)
|
| 59 |
|
| 60 |
-
# Run the bot
|
| 61 |
if __name__ == "__main__":
|
| 62 |
-
|
| 63 |
-
try:
|
| 64 |
-
loop.run_until_complete(setup_and_run_bot())
|
| 65 |
-
finally:
|
| 66 |
-
loop.close()
|
|
|
|
| 29 |
)
|
| 30 |
|
| 31 |
# Set up and run the Telegram bot
|
| 32 |
+
async def main():
|
| 33 |
if not TELEGRAM_BOT_TOKEN:
|
| 34 |
print("Telegram bot token not found. Please set TELEGRAM_BOT_TOKEN in the Space secrets.")
|
| 35 |
return
|
|
|
|
| 57 |
print("Starting Telegram bot...")
|
| 58 |
await application.run_polling(allowed_updates=Update.ALL_TYPES)
|
| 59 |
|
| 60 |
+
# Run the bot
|
| 61 |
if __name__ == "__main__":
|
| 62 |
+
asyncio.run(main())
|
|
|
|
|
|
|
|
|
|
|
|