From a6e3482878932d3cb23ad16e6ba695f6615d106c Mon Sep 17 00:00:00 2001 From: Hafitz Setya <71178188+breakdowns@users.noreply.github.com> Date: Mon, 1 Mar 2021 10:28:03 +0700 Subject: [PATCH] Update list.py --- bot/modules/list.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/bot/modules/list.py b/bot/modules/list.py index 24a641c..151c53f 100644 --- a/bot/modules/list.py +++ b/bot/modules/list.py @@ -8,17 +8,20 @@ from bot.helper.telegram_helper.bot_commands import BotCommands @run_async def list_drive(update,context): - message = update.message.text - search = message.split(' ',maxsplit=1)[1] - LOGGER.info(f"Searching: {search}") - gdrive = GoogleDriveHelper(None) - msg = gdrive.drive_list(search) - if msg: - reply_message = sendMessage(msg, context.bot, update) - else: - reply_message = sendMessage('No result found', context.bot, update) + try: + search = update.message.text.split(' ',maxsplit=1)[1] + LOGGER.info(f"Searching: {search}") + reply = sendMessage('Searching..... Please wait!', context.bot, update) + gdrive = GoogleDriveHelper(None) + msg, button = gdrive.drive_list(search) - threading.Thread(target=auto_delete_message, args=(context.bot, update.message, reply_message)).start() + if msg: + editMessage(msg, reply) + else: + editMessage('No result found', reply) + + except IndexError: + sendMessage('Send a search key along with command', context.bot, update) list_handler = CommandHandler(BotCommands.ListCommand, list_drive,filters=CustomFilters.authorized_chat | CustomFilters.authorized_user)