Merge pull request #107 from bucolucas/add-doreboot-check

Add .doreboot file check and message sending functionality
This commit is contained in:
2024-08-20 14:09:51 -05:00
committed by GitHub
+10 -2
View File
@@ -80,6 +80,14 @@ class TelegramHelper:
f.write(str(update.effective_chat.id))
sys.exit(0)
async def check_doreboot_file(self, application: Application):
reboot_file_path = "./.doreboot"
if os.path.exists(reboot_file_path):
with open(reboot_file_path, 'r') as f:
chat_id = f.read().strip()
await application.bot.send_message(chat_id=chat_id, text="The application has finished initializing.")
os.remove(reboot_file_path)
def run(self):
application = Application.builder().token(self.telegram_bot_token).build()
@@ -93,7 +101,7 @@ class TelegramHelper:
logging.info("Bot is running...")
if os.path.exists("./.doreboot"):
os.remove("./.doreboot")
# Check for .doreboot file and send message if it exists
application.create_task(self.check_doreboot_file(application))
application.run_polling()