added chat id to .doreboot file
This commit is contained in:
+3
-7
@@ -76,15 +76,11 @@ class TelegramHelper:
|
|||||||
logging.info("Received reboot command. Exiting process...")
|
logging.info("Received reboot command. Exiting process...")
|
||||||
reboot_file_path = "./.doreboot"
|
reboot_file_path = "./.doreboot"
|
||||||
if not os.path.exists(reboot_file_path):
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
def run(self):
|
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 = Application.builder().token(self.telegram_bot_token).build()
|
||||||
|
|
||||||
application.add_handler(CommandHandler("start", self.start))
|
application.add_handler(CommandHandler("start", self.start))
|
||||||
@@ -94,6 +90,6 @@ class TelegramHelper:
|
|||||||
application.add_handler(CommandHandler("reboot", self.reboot))
|
application.add_handler(CommandHandler("reboot", self.reboot))
|
||||||
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_message))
|
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_message))
|
||||||
application.add_handler(CallbackQueryHandler(self.abort_processing, pattern='^abort$'))
|
application.add_handler(CallbackQueryHandler(self.abort_processing, pattern='^abort$'))
|
||||||
|
|
||||||
logging.info("Bot is running...")
|
logging.info("Bot is running...")
|
||||||
application.run_polling()
|
application.run_polling()
|
||||||
|
|||||||
Reference in New Issue
Block a user