From 7783d8fc22ff5bc9b6d4845aed8715a88e2b14bd Mon Sep 17 00:00:00 2001 From: Jonathan Lucas Date: Tue, 20 Aug 2024 13:22:59 -0500 Subject: [PATCH] added chat id to .doreboot file --- telegram_helper.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/telegram_helper.py b/telegram_helper.py index 61d523c..8afd5e3 100644 --- a/telegram_helper.py +++ b/telegram_helper.py @@ -76,15 +76,11 @@ class TelegramHelper: 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() + with open(reboot_file_path, 'w') as f: + f.write(str(update.effective_chat.id)) sys.exit(0) def run(self): - if os.path.exists("./.doreboot"): - # Assuming `send_message_to_user` is a method or function available in the bot context. - await self.bot.send_message_to_user("Reboot Complete") - os.remove("./.doreboot") - application = Application.builder().token(self.telegram_bot_token).build() application.add_handler(CommandHandler("start", self.start)) @@ -94,6 +90,6 @@ class TelegramHelper: application.add_handler(CommandHandler("reboot", self.reboot)) application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_message)) application.add_handler(CallbackQueryHandler(self.abort_processing, pattern='^abort$')) - + logging.info("Bot is running...") application.run_polling()