Added auto-restart capability
This commit is contained in:
+7
-3
@@ -73,8 +73,11 @@ class TelegramHelper:
|
||||
|
||||
async def reboot(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
await update.message.reply_text("Rebooting the bot...")
|
||||
logging.info("Received reboot command. Exiting with status code 355.")
|
||||
sys.exit(355)
|
||||
logging.info("Received reboot command. Exiting process...")
|
||||
reboot_file_path = "./.doreboot"
|
||||
if not os.path.exists(reboot_file_path):
|
||||
open(reboot_file_path, 'w').close()
|
||||
sys.exit(0)
|
||||
|
||||
def run(self):
|
||||
application = Application.builder().token(self.telegram_bot_token).build()
|
||||
@@ -88,4 +91,5 @@ class TelegramHelper:
|
||||
application.add_handler(CallbackQueryHandler(self.abort_processing, pattern='^abort$'))
|
||||
|
||||
logging.info("Bot is running...")
|
||||
application.run_polling()
|
||||
application.run_polling()
|
||||
|
||||
Reference in New Issue
Block a user