diff --git a/bot/__main__.py b/bot/__main__.py
index 78dae064..f0f1f7af 100644
--- a/bot/__main__.py
+++ b/bot/__main__.py
@@ -86,9 +86,9 @@ def restart(update, context):
• /{BotCommands.CancelCommand} <gid>: Cancel a task
-• /{BotCommands.StatusCommand}: Get a status of all tasks
+• /{BotCommands.StatusCommand}: Get status of all tasks
-• /{BotCommands.ListKeysCommand}: Get a list of keys for the destination drives
+• /{BotCommands.ListKeysCommand}: Get the list of destination drives keys
• /{BotCommands.PingCommand}: Ping the bot
@@ -114,7 +114,7 @@ def restart(update, context):
• /{BotCommands.UnauthorizeCommand}: Unauthorize an user or a chat for using the bot
-• /{BotCommands.UsersCommand}: Get a list of authorized chats
+• /{BotCommands.UsersCommand}: Get the list of authorized users
• /{BotCommands.ShellCommand} <cmd>: Run commands in terminal
diff --git a/bot/helper/download_utils/gd_downloader.py b/bot/helper/download_utils/gd_downloader.py
index 4eda100f..567013f3 100644
--- a/bot/helper/download_utils/gd_downloader.py
+++ b/bot/helper/download_utils/gd_downloader.py
@@ -7,7 +7,7 @@
from bot.helper.telegram_helper.message_utils import sendMessage, deleteMessage, sendStatusMessage
from bot.helper.ext_utils.bot_utils import get_readable_file_size
-def add_gd_download(link, path, listener, is_appdrive, appdict, is_gdtot):
+def add_gd_download(link, path, listener, customname, is_appdrive, appdict, is_gdtot):
msg = sendMessage(f"Checking: {link}
", listener.bot, listener.message)
LOGGER.info(f"Checking: {link}")
gd = GoogleDriveHelper()
@@ -15,6 +15,8 @@ def add_gd_download(link, path, listener, is_appdrive, appdict, is_gdtot):
deleteMessage(listener.bot, msg)
if res != "":
return sendMessage(res, listener.bot, listener.message)
+ if customname:
+ name = customname
if COMPRESS_LIMIT is not None:
if size > COMPRESS_LIMIT * 1024**3:
msg2 = f"Name: {name}
"
diff --git a/bot/helper/drive_utils/gdriveTools.py b/bot/helper/drive_utils/gdriveTools.py
index 3fafec56..827c6b9a 100644
--- a/bot/helper/drive_utils/gdriveTools.py
+++ b/bot/helper/drive_utils/gdriveTools.py
@@ -221,7 +221,7 @@ def helper(self, link):
return self.helper(link)
msg = "File not found"
else:
- msg = str(err)
+ msg = err
return msg, "", "", ""
return "", size, name, files
@@ -239,16 +239,17 @@ def deleteFile(self, link: str):
supportsAllDrives=IS_TEAM_DRIVE).execute()
msg = "Permanently deleted"
except HttpError as err:
- if "File not found" in str(err):
+ err = str(err).replace('>', '').replace('<', '')
+ if "File not found" in err:
msg = "File not found"
- elif "insufficientFilePermissions" in str(err):
+ elif "insufficientFilePermissions" in err:
token_service = self.__alt_authorize()
if token_service is not None:
self.__service = token_service
return self.deleteFile(link)
msg = "Insufficient file permissions"
else:
- msg = str(err)
+ msg = err
LOGGER.error(msg)
return msg
@@ -291,17 +292,16 @@ def setPermission(self, link, access):
msg = "Set permission to Anyone with the link
"
except HttpError as err:
err = str(err).replace('>', '').replace('<', '')
- LOGGER.error(err)
- if "File not found" in str(err):
+ if "File not found" in err:
msg = "File not found"
- elif "insufficientFilePermissions" in str(err):
+ elif "insufficientFilePermissions" in err:
token_service = self.__alt_authorize()
if token_service is not None:
self.__service = token_service
return self.setPermission(link, access)
msg = "Insufficient file permissions"
else:
- msg = str(err)
+ msg = err
return msg
@retry(wait=wait_exponential(multiplier=2, min=3, max=6),
@@ -438,7 +438,7 @@ def clone(self, link, key):
return self.clone(link, key)
msg = "File not found"
else:
- msg = str(err)
+ msg = err
return msg
def count(self, link):
@@ -479,7 +479,7 @@ def count(self, link):
return self.count(link)
msg = "File not found"
else:
- msg = str(err)
+ msg = err
return msg
def _progress(self):
@@ -677,10 +677,10 @@ def download(self, link):
try:
meta = self.__getFileMetadata(file_id)
if meta.get("mimeType") == self.__G_DRIVE_DIR_MIME_TYPE:
- self.__download_folder(file_id, self.__path, meta.get('name'))
+ self.__download_folder(file_id, self.__path, self.name)
else:
os.makedirs(self.__path)
- self.__download_file(file_id, self.__path, meta.get('name'), meta.get('mimeType'))
+ self.__download_file(file_id, self.__path, self.name, meta.get('mimeType'))
except Exception as err:
if isinstance(err, RetryError):
LOGGER.info(f"Total attempts: {err.last_attempt.attempt_number}")
@@ -749,7 +749,7 @@ def __receive_callback(self, request_id, response, exception):
# request_id = order number of request = shared drive index (1 based)
if exception is not None:
exception = str(exception).replace('>', '').replace('<', '')
- LOGGER.error(str(exception))
+ LOGGER.error(exception)
else:
if response['files']:
self.response[request_id] = response
diff --git a/bot/modules/compress.py b/bot/modules/compress.py
index 964470d2..e79d56d5 100644
--- a/bot/modules/compress.py
+++ b/bot/modules/compress.py
@@ -185,7 +185,7 @@ def onUploadError(self, error):
def _compress(bot, message, is_archive=False, is_extract=False, pswd=None):
mesg = message.text.split('\n')
message_args = mesg[0].split(maxsplit=1)
- reply_to = message.reply_to_message
+ name_arg = mesg[0].split('|', maxsplit=1)
is_appdrive = False
is_gdtot = False
appdict = ''
@@ -195,6 +195,12 @@ def _compress(bot, message, is_archive=False, is_extract=False, pswd=None):
link = ''
else:
link = ''
+ if len(name_arg) > 1:
+ name = name_arg[1]
+ name = name.split(' pswd:')[0]
+ name = name.strip()
+ else:
+ name = ''
link = re.split(r"pswd:|\|", link)[0]
link = link.strip()
pswd_arg = mesg[0].split(' pswd: ')
@@ -202,6 +208,7 @@ def _compress(bot, message, is_archive=False, is_extract=False, pswd=None):
pswd = pswd_arg[1]
else:
pswd = None
+ reply_to = message.reply_to_message
if reply_to is not None:
link = reply_to.text.split(maxsplit=1)[0].strip()
is_appdrive = is_appdrive_link(link)
@@ -222,10 +229,11 @@ def _compress(bot, message, is_archive=False, is_extract=False, pswd=None):
return sendMessage(str(e), bot, message)
listener = CompressListener(bot, message, is_archive, is_extract, pswd)
if is_gdrive_link(link):
- threading.Thread(target=add_gd_download, args=(link, f'{DOWNLOAD_DIR}{listener.uid}', listener, is_appdrive, appdict, is_gdtot)).start()
+ threading.Thread(target=add_gd_download, args=(link, f'{DOWNLOAD_DIR}{listener.uid}', listener, name, is_appdrive, appdict, is_gdtot)).start()
else:
help_msg = 'Instructions\nSend a link along with command'
help_msg += '\n\nSupported Sites\n• Google Drive\n• AppDrive\n• GDToT'
+ help_msg += '\n\nSet Custom Name\nAdd "|customname
" after the link'
help_msg += '\n\nSet Password\nAdd "pswd: xxx
" after the link'
sendMessage(help_msg, bot, message)