added chat id to .doreboot file

This commit is contained in:
2024-08-20 13:22:59 -05:00
parent 9ac450473f
commit 7783d8fc22
+3 -7
View File
@@ -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()