diff --git a/bot/__init__.py b/bot/__init__.py
index 2a1181a..de3244f 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -182,6 +182,12 @@ try:
INDEX_URL = None
except KeyError:
INDEX_URL = None
+try:
+ CLONE_LIMIT = getConfig('CLONE_LIMIT')
+ if len(CLONE_LIMIT) == 0:
+ CLONE_LIMIT = None
+except KeyError:
+ CLONE_LIMIT = None
try:
BUTTON_FOUR_NAME = getConfig('BUTTON_FOUR_NAME')
BUTTON_FOUR_URL = getConfig('BUTTON_FOUR_URL')
diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py
index f63479d..9052579 100644
--- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py
+++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py
@@ -619,7 +619,7 @@ class GoogleDriveHelper:
file_id = self.getIdFromUrl(link)
except (KeyError,IndexError):
msg = "Google drive ID could not be found in the provided link"
- return msg
+ return msg, ""
msg = ""
LOGGER.info(f"File ID: {file_id}")
try:
@@ -634,6 +634,7 @@ class GoogleDriveHelper:
msg += f'\nType: Folder'
msg += f'\nSubFolders: {self.total_folders}'
msg += f'\nFiles: {self.total_files}'
+ clonesizelimit = self.total_bytes
else:
msg += f'Filename: {name}'
try:
@@ -646,6 +647,7 @@ class GoogleDriveHelper:
msg += f'\nSize: {get_readable_file_size(self.total_bytes)}'
msg += f'\nType: {typee}'
msg += f'\nFiles: {self.total_files}'
+ clonesizelimit = self.total_bytes
except TypeError:
pass
except Exception as err:
@@ -654,8 +656,12 @@ class GoogleDriveHelper:
err = err.last_attempt.exception()
err = str(err).replace('>', '').replace('<', '')
LOGGER.error(err)
- return err
- return msg
+ if "File not found" in str(err):
+ msg = "File not found."
+ else:
+ msg = f"Error.\n{err}"
+ return msg, ""
+ return msg, clonesizelimit
def gDrive_file(self, **kwargs):
try:
diff --git a/bot/modules/clone.py b/bot/modules/clone.py
index cc4126d..2006fba 100644
--- a/bot/modules/clone.py
+++ b/bot/modules/clone.py
@@ -1,33 +1,58 @@
-from telegram.ext import CommandHandler
+from telegram.ext import CommandHandler, run_async
from bot.helper.mirror_utils.upload_utils.gdriveTools import GoogleDriveHelper
-from bot.helper.telegram_helper.message_utils import *
+from bot.helper.telegram_helper.message_utils import sendMarkup, deleteMessage, sendMessage
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper.bot_commands import BotCommands
-from bot.helper.ext_utils.bot_utils import new_thread
-from bot import dispatcher
+from bot import dispatcher, CLONE_LIMIT
-@new_thread
+@run_async
def cloneNode(update, context):
args = update.message.text.split(" ", maxsplit=1)
- if update.message.from_user.username:
- uname = f"@{update.message.from_user.username}"
- else:
- uname = f'{update.message.from_user.first_name}'
- if uname is not None:
- cc = f'\n\ncc: {uname}'
if len(args) > 1:
link = args[1]
- msg = sendMessage(f"Cloning: {link}", context.bot, update)
gd = GoogleDriveHelper()
+ if CLONE_LIMIT is not None:
+ mssg = sendMessage(f"Checking The Size...", context.bot, update)
+ limit = CLONE_LIMIT
+ limit = limit.split(' ', maxsplit=1)
+ limitint = int(limit[0])
+ res, clonesizelimit = gd.count(link)
+ if clonesizelimit != "":
+ msgg = f'Failed, clone limit is {CLONE_LIMIT}'
+ if 'GB' in limit or 'gb' in limit:
+ if clonesizelimit > limitint * 1024**3:
+ deleteMessage(context.bot, mssg)
+ sendMessage(msgg, context.bot, update)
+ return
+ else:
+ deleteMessage(context.bot, mssg)
+ elif 'TB' in limit or 'tb' in limit:
+ if clonesizelimit > limitint * 1024**4:
+ deleteMessage(context.bot, mssg)
+ sendMessage(msgg, context.bot, update)
+ return
+ else:
+ deleteMessage(context.bot, mssg)
+ else:
+ deleteMessage(context.bot, mssg)
+ sendMessage(res, context.bot, update)
+ return
+ msg = sendMessage(f"Cloning: {link}", context.bot, update)
result, button = gd.clone(link)
- deleteMessage(context.bot,msg)
+ deleteMessage(context.bot, msg)
if button == "":
sendMessage(result, context.bot, update)
else:
+ if update.message.from_user.username:
+ uname = f'@{update.message.from_user.username}'
+ else:
+ uname = f'{update.message.from_user.first_name}'
+ if uname is not None:
+ cc = f'\n\n#cc: {uname}'
sendMarkup(result + cc, context.bot, update, button)
else:
- sendMessage("Provide G-Drive Shareable Link to Clone.", context.bot, update)
+ sendMessage('Provide G-Drive Shareable Link to Clone.', context.bot, update)
clone_handler = CommandHandler(BotCommands.CloneCommand, cloneNode, filters=CustomFilters.authorized_chat | CustomFilters.authorized_user)
dispatcher.add_handler(clone_handler)
diff --git a/bot/modules/count.py b/bot/modules/count.py
index 76d942f..ae92734 100644
--- a/bot/modules/count.py
+++ b/bot/modules/count.py
@@ -9,18 +9,18 @@ from bot import dispatcher
@run_async
def countNode(update, context):
args = update.message.text.split(" ", maxsplit=1)
- if update.message.from_user.username:
- uname = f"@{update.message.from_user.username}"
- else:
- uname = f'{update.message.from_user.first_name}'
- if uname is not None:
- cc = f'\n\ncc: {uname}'
if len(args) > 1:
link = args[1]
msg = sendMessage(f"Counting: {link}", context.bot, update)
gd = GoogleDriveHelper()
- result = gd.count(link)
+ result, empty = gd.count(link)
deleteMessage(context.bot, msg)
+ if update.message.from_user.username:
+ uname = f'@{update.message.from_user.username}'
+ else:
+ uname = f'{update.message.from_user.first_name}'
+ if uname is not None:
+ cc = f'\n\ncc: {uname}'
sendMessage(result + cc, context.bot, update)
else:
sendMessage("Provide G-Drive Shareable Link to Count.", context.bot, update)
diff --git a/config_sample.env b/config_sample.env
index 734e901..ca936e7 100644
--- a/config_sample.env
+++ b/config_sample.env
@@ -25,6 +25,7 @@ BLOCK_MEGA_LINKS = ""
STOP_DUPLICATE_MIRROR = ""
SHORTENER = ""
SHORTENER_API = ""
+CLONE_LIMIT = "" #leave space between number and unit (tb or gb only)
IMAGE_URL = "https://telegra.ph/file/db03910496f06094f1f7a.jpg"
# Change ENABLE_FILESIZE_LIMIT = True if you want to use MAX_TORRENT_SIZE
ENABLE_FILESIZE_LIMIT = false