Add /browse command and button callback handlers to TelegramHelper
This commit is contained in:
@@ -6,6 +6,7 @@ import time
|
||||
import git
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes, CallbackQueryHandler
|
||||
from browse_command import browse_command, button_callback
|
||||
|
||||
class TelegramHelper:
|
||||
def __init__(self, bot):
|
||||
@@ -108,6 +109,9 @@ class TelegramHelper:
|
||||
logging.error(f"Error checking for new commits: {str(e)}")
|
||||
await asyncio.sleep(60) # Check every 60 seconds
|
||||
|
||||
async def browse(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
await browse_command(update, context)
|
||||
|
||||
def run(self):
|
||||
application = Application.builder().token(self.telegram_bot_token).build()
|
||||
|
||||
@@ -116,8 +120,10 @@ class TelegramHelper:
|
||||
application.add_handler(CommandHandler("switch", self.switch))
|
||||
application.add_handler(CommandHandler("status", self.status))
|
||||
application.add_handler(CommandHandler("reboot", self.reboot))
|
||||
application.add_handler(CommandHandler("browse", self.browse))
|
||||
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_message))
|
||||
application.add_handler(CallbackQueryHandler(self.abort_processing, pattern='^abort$'))
|
||||
application.add_handler(CallbackQueryHandler(button_callback, pattern='^(browse|file):'))
|
||||
|
||||
logging.info("Bot is running...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user