Merge pull request #100 from bucolucas/add-reboot-command
Add /reboot command to exit with status code 355
This commit is contained in:
@@ -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$'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user