From cd8b49c8449f2b7edd3610d2c482b7d2efe5a8eb Mon Sep 17 00:00:00 2001 From: Levi <57452819+l3v11@users.noreply.github.com> Date: Wed, 21 Dec 2022 17:18:58 +0600 Subject: [PATCH] Add exception handling for invalid Drive Key --- README.md | 11 ++++++++--- bot/modules/clone.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 098089d7..c7a3e912 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ SearchX is a multipurpose Telegram bot written in Python for Google Drive - Set data permission in Google Drive - Size Limit support for Clone, Compression and Extraction tasks - Destination change support for Clone tasks -- MongoDB support for storing the list of authorized users +- MongoDB database support +- Bookmark support for storing Destination Drive IDs into database +- Support for storing the list of authorized users into database - Index Link support - Multi-token telegraph support - Multi-page telegraph page results @@ -62,8 +64,11 @@ cancel - Cancel a task status - Get status of all tasks share - Set data permission in Google Drive del - Delete data from Google Drive -authorize - Grant authorization of an user -unauthorize - Revoke authorization of an user +addbm - Add bookmark of a destination drive +rembm - Remove bookmark of a destination drive +bookmarks - Get the list of bookmarked destination drives +auth - Grant authorization of an user +unauth - Revoke authorization of an user users - Get the list of authorized users shell - Execute shell commands eval - Evaluate Python expressions diff --git a/bot/modules/clone.py b/bot/modules/clone.py index e06c3919..f44ddd0d 100644 --- a/bot/modules/clone.py +++ b/bot/modules/clone.py @@ -25,14 +25,20 @@ def cloneNode(update, context): link = args[1].strip() try: key = args[2].strip() - dest_id = BOOKMARKS[key] + try: + dest_id = BOOKMARKS[key] + except KeyError: + return sendMessage("Invalid Drive Key", context.bot, update.message) except IndexError: pass if reply_to: link = reply_to.text.split(maxsplit=1)[0].strip() try: key = args[1].strip() - dest_id = BOOKMARKS[key] + try: + dest_id = BOOKMARKS[key] + except KeyError: + return sendMessage("Invalid Drive Key", context.bot, update.message) except IndexError: pass is_gdtot = is_gdtot_link(link)