Merge pull request #204 from bucolucas/fix-event-loop-telegram
Fix: No current event loop in thread 'MainThread' in telegram_helper.py
This commit is contained in:
+1
-8
@@ -226,7 +226,7 @@ class TelegramHelper:
|
||||
await browse_command(update, context, self.bot)
|
||||
|
||||
def run(self):
|
||||
application = Application.builder().token(self.telegram_bot_token).build()
|
||||
application = Application.builder().token(self.telegram_bot_token).post_init(self.check_doreboot_file).build()
|
||||
|
||||
application.add_handler(CommandHandler("start", self.start))
|
||||
application.add_handler(CommandHandler("clear", self.clear))
|
||||
@@ -239,11 +239,4 @@ class TelegramHelper:
|
||||
application.add_handler(CallbackQueryHandler(button_callback, pattern='^(browse|file):'))
|
||||
|
||||
logging.info("Bot is running...")
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
if loop.is_running(): # pragma: no cover
|
||||
loop.create_task(self.check_doreboot_file(application))
|
||||
else: # pragma: no cover
|
||||
asyncio.run(self.check_doreboot_file(application))
|
||||
|
||||
application.run_polling()
|
||||
|
||||
Reference in New Issue
Block a user