diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py
index b6a6bd1..da4ef86 100644
--- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py
+++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py
@@ -16,6 +16,9 @@
from googleapiclient.http import MediaFileUpload
from tenacity import *
+from telegram import InlineKeyboardMarkup
+from bot.helper.telegram_helper import button_builder
+
from bot import parent_id, DOWNLOAD_DIR, IS_TEAM_DRIVE, INDEX_URL, \
USE_SERVICE_ACCOUNTS, download_dict
from bot.helper.ext_utils.bot_utils import *
@@ -303,7 +306,7 @@ def clone(self, link):
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:
@@ -311,29 +314,32 @@ def clone(self, link):
if meta.get("mimeType") == self.__G_DRIVE_DIR_MIME_TYPE:
dir_id = self.create_directory(meta.get('name'), parent_id)
result = self.cloneFolder(meta.get('name'), meta.get('name'), meta.get('id'), dir_id)
- msg += f'{meta.get("name")}' \
- f' ({get_readable_file_size(self.transferred_size)})'
+ msg += f'Filename : {meta.get("name")}
\nSize : {get_readable_file_size(self.transferred_size)}'
+ buttons = button_builder.ButtonMaker()
+ buttons.buildbutton("⚡Drive Link⚡", self.__G_DRIVE_DIR_BASE_DOWNLOAD_URL.format(dir_id))
if INDEX_URL is not None:
url = requests.utils.requote_uri(f'{INDEX_URL}/{meta.get("name")}/')
- msg += f' | Index URL'
+ buttons.buildbutton("💥Index Link💥", url)
else:
file = self.copyFile(meta.get('id'), parent_id)
- msg += f'{file.get("name")}'
+ msg += f'Filename : {file.get("name")}
'
+ buttons = button_builder.ButtonMaker()
+ buttons.buildbutton("⚡Drive Link⚡", self.__G_DRIVE_BASE_DOWNLOAD_URL.format(file.get("id")))
try:
- msg += f' ({get_readable_file_size(int(meta.get("size")))}) '
+ msg += f'\nSize : {get_readable_file_size(int(meta.get("size")))}
'
except TypeError:
pass
if INDEX_URL is not None:
url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}')
- msg += f' | Index URL'
+ buttons.buildbutton("💥Index Link💥", url)
except Exception as err:
if isinstance(err, RetryError):
LOGGER.info(f"Total Attempts: {err.last_attempt.attempt_number}")
err = err.last_attempt.exception()
err = str(err).replace('>', '').replace('<', '')
LOGGER.error(err)
- return err
- return msg
+ return err, ""
+ return msg, InlineKeyboardMarkup(buttons.build_menu(2))
def cloneFolder(self, name, local_path, folder_id, parent_id):
LOGGER.info(f"Syncing: {local_path}")
diff --git a/bot/modules/clone.py b/bot/modules/clone.py
index 47202ff..32cf998 100644
--- a/bot/modules/clone.py
+++ b/bot/modules/clone.py
@@ -14,9 +14,12 @@ def cloneNode(update,context):
link = args[1]
msg = sendMessage(f"Cloning: {link}
",context.bot,update)
gd = GoogleDriveHelper()
- result = gd.clone(link)
+ result, button = gd.clone(link)
deleteMessage(context.bot,msg)
- sendMessage(result,context.bot,update)
+ if button == "":
+ sendMessage(result,context.bot,update)
+ else:
+ sendMarkup(result,context.bot,update,button)
else:
sendMessage("Provide G-Drive Shareable Link to Clone.",context.bot,update)
diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py
index e86d0b3..981c1de 100644
--- a/bot/modules/mirror.py
+++ b/bot/modules/mirror.py
@@ -1,5 +1,6 @@
import requests
from telegram.ext import CommandHandler, run_async
+from telegram import InlineKeyboardMarkup
from bot import Interval, INDEX_URL
from bot import dispatcher, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, download_dict, download_dict_lock
@@ -18,6 +19,7 @@
from bot.helper.telegram_helper.bot_commands import BotCommands
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper.message_utils import *
+from bot.helper.telegram_helper import button_builder
import pathlib
import os
import subprocess
@@ -136,22 +138,24 @@ def onUploadProgress(self):
def onUploadComplete(self, link: str):
with download_dict_lock:
- msg = f'{download_dict[self.uid].name()} ({download_dict[self.uid].size()})'
+ msg = f'Filename : {download_dict[self.uid].name()}
\nSize : {download_dict[self.uid].size()}
'
+ buttons = button_builder.ButtonMaker()
+ buttons.buildbutton("⚡Drive Link⚡", link)
LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}')
if INDEX_URL is not None:
share_url = requests.utils.requote_uri(f'{INDEX_URL}/{download_dict[self.uid].name()}')
if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'):
share_url += '/'
- msg += f'\n\n Shareable link: here'
+ buttons.buildbutton("💥Index Link💥", share_url)
if self.tag is not None:
- msg += f'\ncc: @{self.tag}'
+ msg += f'\n\nHey @{self.tag}, your file is uploaded'
try:
fs_utils.clean_download(download_dict[self.uid].path())
except FileNotFoundError:
pass
del download_dict[self.uid]
count = len(download_dict)
- sendMessage(msg, self.bot, self.update)
+ sendMarkup(msg, self.bot, self.update, InlineKeyboardMarkup(buttons.build_menu(2)))
if count == 0:
self.clean()
else: