Add /reboot command to exit with status code 355

This commit is contained in:
2024-08-20 12:37:35 -05:00
parent 7d651bbbc0
commit 96530e50fb
+7
View File
@@ -1,5 +1,6 @@
import os
import logging
import sys
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes, CallbackQueryHandler
@@ -70,6 +71,11 @@ class TelegramHelper:
result = await self.bot.abort_processing(user_id)
await query.edit_message_text(text=result)
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)
def run(self):
application = Application.builder().token(self.telegram_bot_token).build()
@@ -77,6 +83,7 @@ class TelegramHelper:
application.add_handler(CommandHandler("clear", self.clear))
application.add_handler(CommandHandler("switch", self.switch))
application.add_handler(CommandHandler("status", self.status))
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$'))