def clone(self, link): self.is_cloning = True self.start_time = time.time() self.total_files = 0 self.total_folders = 0 try: file_id = self.getIdFromUrl(link) except (KeyError,IndexError): msg = "Google Drive ID could not be found in the provided link" return msg msg = "" LOGGER.info(f"File ID: {file_id}") try: meta = self.getFileMetadata(file_id) if meta.get("mimeType") == self.__G_DRIVE_DIR_MIME_TYPE: dir_id = self.create_directory(meta.get('name'), parent_id) self.cloneFolder(meta.get('name'), meta.get('name'), meta.get('id'), dir_id) durl = self.__G_DRIVE_DIR_BASE_DOWNLOAD_URL.format(dir_id) if self.is_cancelled: LOGGER.info("Deleting cloned data from Drive...") msg = self.deletefile(durl) LOGGER.info(f"{msg}") return "your clone has been stopped and cloned data has been deleted!", "cancelled" msg += f'<b>Filename: </b><code>{meta.get("name")}</code>\n<b>Size: </b><code>{get_readable_file_size(self.transferred_size)}</code>' msg += '\n<b>Type: </b><code>Folder</code>' msg += f'\n<b>SubFolders: </b><code>{self.total_folders}</code>' msg += f'\n<b>Files: </b><code>{self.total_files}</code>' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = short_url(durl) buttons.buildbutton("☁️ Drive Link", surl) else: buttons.buildbutton("☁️ Drive Link", durl) if INDEX_URL is not None: url_path = requests.utils.quote(f'{meta.get("name")}') url = f'{INDEX_URL}/{url_path}/' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(url) buttons.buildbutton("⚡ Index Link", siurl) else: buttons.buildbutton("⚡ Index Link", url) else: file = self.copyFile(meta.get('id'), parent_id) msg += f'<b>Filename: </b><code>{file.get("name")}</code>' durl = self.__G_DRIVE_BASE_DOWNLOAD_URL.format(file.get("id")) buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = short_url(durl) buttons.buildbutton("☁️ Drive Link", surl) else: buttons.buildbutton("☁️ Drive Link", durl) try: typ = file.get('mimeType') except: typ = 'File' try: msg += f'\n<b>Size: </b><code>{get_readable_file_size(int(meta.get("size")))}</code>' msg += f'\n<b>Type: </b><code>{typ}</code>' except TypeError: pass if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}' urls = f'{INDEX_URL}/{url_path}?a=view' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(url) buttons.buildbutton("⚡ Index Link", siurl) if VIEW_LINK: siurls = short_url(urls) buttons.buildbutton("🌐 View Link", siurls) else: buttons.buildbutton("⚡ Index Link", url) if VIEW_LINK: buttons.buildbutton("🌐 View Link", urls) if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None: buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}") if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None: buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}") if BUTTON_SIX_NAME is not None and BUTTON_SIX_URL is not None: buttons.buildbutton(f"{BUTTON_SIX_NAME}", f"{BUTTON_SIX_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) if "User rate limit exceeded" in str(err): msg = "User rate limit exceeded." elif "File not found" in str(err): token_service = self.alt_authorize() if token_service is not None: self.__service = token_service return self.clone(link) msg = "File not found." else: msg = f"Error.\n{err}" return msg, "" return msg, InlineKeyboardMarkup(buttons.build_menu(2))
def drive_list(self, fileName, stopDup=False, noMulti=False): self.stopDup = stopDup msg = "" if not stopDup: fileName = self.escapes(str(fileName)) content_count = 0 all_contents_count = 0 Title = False if len(DRIVES_IDS) > 1: token_service = self.alt_authorize() if token_service is not None: self.__service = token_service for index, parent_id in enumerate(DRIVES_IDS): if RECURSIVE_SEARCH and len(parent_id) > 23: continue response = self.drive_query(parent_id, fileName) if not response["files"] and noMulti: break elif not response["files"]: continue if not Title: msg += f'<h4>Search Result For: {fileName}</h4><br><br>' Title = True if len(DRIVES_NAMES) > 1 and DRIVES_NAMES[index] is not None: msg += f"╾────────────╼<br><b>{DRIVES_NAMES[index]}</b><br>╾────────────╼<br>" for file in response.get('files', []): if file.get('mimeType') == "application/vnd.google-apps.folder": furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"📁 <code>{file.get('name')}<br>(folder)</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = short_url(furl) msg += f"<b><a href={sfurl}>Drive Link</a></b>" else: msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URLS[index] is not None: if RECURSIVE_SEARCH: url_path = "/".join([requests.utils.quote(n, safe='') for n in self.get_recursive_list(file, parent_id)]) else: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URLS[index]}/{url_path}/' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(url) msg += f' <b>| <a href="{siurl}">Index Link</a></b>' else: msg += f' <b>| <a href="{url}">Index Link</a></b>' elif file.get('mimeType') == 'application/vnd.google-apps.shortcut': msg += f"⁍<a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" \ f"</a> (shortcut)" # Excluded index link as indexes cant download or open these shortcuts else: furl = f"http://twdrivelinks.tk/drive/?id={file.get('id')}" msg += f"🎬 <code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = short_url(furl) msg += f"<b><a href={sfurl}>📥Watch/Download📥</a></b>" else: msg += f"<b><a href={furl}>📥Watch/Download📥</a></b>" if INDEX_URLS[index] is not None: if RECURSIVE_SEARCH: url_path = "/".join( requests.utils.quote(n, safe='') for n in self.get_recursive_list(file, parent_id) ) else: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URLS[index]}/{url_path}' urls = f'{INDEX_URLS[index]}/{url_path}?a=view' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(url) msg += f' <b>| <a href="{siurl}">Index Link</a></b>' if VIEW_LINK: siurls = short_url(urls) msg += f' <b>| <a href="{siurls}">View Link</a></b>' else: msg += f' <b>| <a href="{url}">Index Link</a></b>' if VIEW_LINK: msg += f' <b>| <a href="{urls}">View Link</a></b>' msg += '<br><br>' content_count += 1 all_contents_count += 1 if content_count == TELEGRAPHLIMIT : self.telegraph_content.append(msg) msg = "" content_count = 0 if noMulti: break if msg != '': self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "", None for content in self.telegraph_content : self.path.append(Telegraph(access_token=telegraph_token).create_page( title = 'toonswood-links', author_name='ToonsWood', author_url='https://www.toonswood.cot', html_content=content )['path']) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>Found <code>{all_contents_count}</code> results for <code>{fileName}</code></b>" buttons = button_build.ButtonMaker() buttons.buildbutton("🔎 VIEW", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1))
def drive_list(self, fileName, stopDup=False, noMulti=False, isRecursive=True, itemType=""): msg = "" fileName = self.__escapes(str(fileName)) contents_count = 0 Title = False if len(DRIVES_IDS) > 1: token_service = self.__alt_authorize() if token_service is not None: self.__service = token_service for index, parent_id in enumerate(DRIVES_IDS): if isRecursive and len(parent_id) > 23: isRecur = False else: isRecur = isRecursive response = self.__drive_query(parent_id, fileName, stopDup, isRecur, itemType) if not response["files"] and noMulti: break elif not response["files"]: continue if not Title: msg += f'<h4>Search Result For {fileName}</h4>' Title = True if len(DRIVES_NAMES) > 1 and DRIVES_NAMES[index] is not None: msg += f"╾────────────╼<br><b>{DRIVES_NAMES[index]}</b><br>╾────────────╼<br>" for file in response.get('files', []): mime_type = file.get('mimeType') if mime_type == "application/vnd.google-apps.folder": furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"📁 <code>{file.get('name')}<br>(folder)</code><br>" furl = short_url(furl) msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URLS[index] is not None: if isRecur: url_path = "/".join([ rquote(n, safe='') for n in self.__get_recursive_list( file, parent_id) ]) else: url_path = rquote(f'{file.get("name")}') url = f'{INDEX_URLS[index]}/{url_path}/' url = short_url(url) msg += f' <b>| <a href="{url}">Index Link</a></b>' elif mime_type == 'application/vnd.google-apps.shortcut': msg += f"⁍<a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" \ f"</a> (shortcut)" # Excluded index link as indexes cant download or open these shortcuts else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" msg += f"📄 <code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size', 0)))})</code><br>" furl = short_url(furl) msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URLS[index] is not None: if isRecur: url_path = "/".join( rquote(n, safe='') for n in self.__get_recursive_list( file, parent_id)) else: url_path = rquote(f'{file.get("name")}') url = f'{INDEX_URLS[index]}/{url_path}' url = short_url(url) msg += f' <b>| <a href="{url}">Index Link</a></b>' if VIEW_LINK: urls = f'{INDEX_URLS[index]}/{url_path}?a=view' urls = short_url(urls) msg += f' <b>| <a href="{urls}">View Link</a></b>' msg += '<br><br>' contents_count += 1 if len(msg.encode('utf-8')) > 39000: self.telegraph_content.append(msg) msg = "" if noMulti: break if msg != '': self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "", None for content in self.telegraph_content: self.path.append( telegraph.create_page(title='Mirror-Leech-Bot Drive Search', content=content)["path"]) time.sleep(0.5) self.num_of_path = len(self.path) if self.num_of_path > 1: self.__edit_telegraph() msg = f"<b>Found {contents_count} result for <i>{fileName}</i></b>" buttons = ButtonMaker() buttons.buildbutton("🔎 VIEW", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1))
def onUploadComplete(self, link: str, size, files, folders, typ): if self.isLeech: if self.isQbit and QB_SEED: pass else: with download_dict_lock: try: clean_download(download_dict[self.uid].path()) except FileNotFoundError: pass del download_dict[self.uid] dcount = len(download_dict) if dcount == 0: self.clean() else: update_all_messages() count = len(files) msg = f'<b>Name: </b><code>{link}</code>\n\n' msg += f'<b>Size: </b>{get_readable_file_size(size)}\n' msg += f'<b>Total Files: </b>{count}' if typ != 0: msg += f'\n<b>Corrupted Files: </b>{typ}' if self.message.chat.type == 'private': sendMessage(msg, self.bot, self.update) else: chat_id = str(self.message.chat.id)[4:] msg += f'\n<b>cc: </b>{self.tag}\n\n' fmsg = '' for index, item in enumerate(list(files), start=1): msg_id = files[item] link = f"https://t.me/c/{chat_id}/{msg_id}" fmsg += f"{index}. <a href='{link}'>{item}</a>\n" if len(fmsg.encode('utf-8') + msg.encode('utf-8')) > 4000: sleep(2) sendMessage(msg + fmsg, self.bot, self.update) fmsg = '' if fmsg != '': sleep(2) sendMessage(msg + fmsg, self.bot, self.update) return with download_dict_lock: msg = f'<b>Name: </b><code>{download_dict[self.uid].name()}</code>\n\n<b>Size: </b>{size}' msg += f'\n\n<b>Type: </b>{typ}' if ospath.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'): msg += f'\n<b>SubFolders: </b>{folders}' msg += f'\n<b>Files: </b>{files}' buttons = ButtonMaker() link = short_url(link) buttons.buildbutton("☁️ Drive Link", link) LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}') if INDEX_URL is not None: url_path = requests.utils.quote(f'{download_dict[self.uid].name()}') share_url = f'{INDEX_URL}/{url_path}' if ospath.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'): share_url += '/' share_url = short_url(share_url) buttons.buildbutton("⚡ Index Link", share_url) else: share_url = short_url(share_url) buttons.buildbutton("⚡ Index Link", share_url) if VIEW_LINK: share_urls = f'{INDEX_URL}/{url_path}?a=view' share_urls = short_url(share_urls) buttons.buildbutton("🌐 View Link", share_urls) if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None: buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}") if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None: buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}") if BUTTON_SIX_NAME is not None and BUTTON_SIX_URL is not None: buttons.buildbutton(f"{BUTTON_SIX_NAME}", f"{BUTTON_SIX_URL}") msg += f'\n\n<b>cc: </b>{self.tag}' if self.isQbit and QB_SEED: return sendMarkup(msg, self.bot, self.update, InlineKeyboardMarkup(buttons.build_menu(2))) else: with download_dict_lock: try: clean_download(download_dict[self.uid].path()) except FileNotFoundError: pass del download_dict[self.uid] count = len(download_dict) sendMarkup(msg, self.bot, self.update, InlineKeyboardMarkup(buttons.build_menu(2))) if count == 0: self.clean() else: update_all_messages()
def onUploadComplete(self, link: str, size, files, folders, typ): with download_dict_lock: msg = f'<b>Filename: </b><code>{download_dict[self.uid].name()}</code>\n<b>Size: </b><code>{size}</code>' if os.path.isdir( f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}' ): msg += '\n<b>Type: </b><code>Folder</code>' msg += f'\n<b>SubFolders: </b><code>{folders}</code>' msg += f'\n<b>Files: </b><code>{files}</code>' else: msg += f'\n<b>Type: </b><code>{typ}</code>' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = short_url(link) buttons.buildbutton("☁️ Drive Link", surl) else: buttons.buildbutton("☁️ Drive Link", link) LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}') if INDEX_URL is not None: url_path = requests.utils.quote( f'{download_dict[self.uid].name()}') share_url = f'{INDEX_URL}/{url_path}' if os.path.isdir( f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}' ): share_url += '/' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(share_url) buttons.buildbutton("⚡ Index Link", siurl) else: buttons.buildbutton("⚡ Index Link", share_url) else: share_urls = f'{INDEX_URL}/{url_path}?a=view' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(share_url) buttons.buildbutton("⚡ Index Link", siurl) if VIEW_LINK: siurls = short_url(share_urls) buttons.buildbutton("🌐 View Link", siurls) else: buttons.buildbutton("⚡ Index Link", share_url) if VIEW_LINK: buttons.buildbutton("🌐 View Link", share_urls) if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None: buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}") if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None: buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}") if BUTTON_SIX_NAME is not None and BUTTON_SIX_URL is not None: buttons.buildbutton(f"{BUTTON_SIX_NAME}", f"{BUTTON_SIX_URL}") if self.message.from_user.username: uname = f"@{self.message.from_user.username}" else: uname = f'<a href="tg://user?id={self.message.from_user.id}">{self.message.from_user.first_name}</a>' if uname is not None: msg += f'\n\ncc: {uname}' try: fs_utils.clean_download(download_dict[self.uid].path()) except FileNotFoundError: pass del download_dict[self.uid] count = len(download_dict) sendMarkup(msg, self.bot, self.update, InlineKeyboardMarkup(buttons.build_menu(2))) if count == 0: self.clean() else: update_all_messages()
def onUploadComplete(self, link: str, size, files, folders, typ): if self.isLeech: if self.message.from_user.username: uname = f"@{self.message.from_user.username}" else: uname = f'<a href="tg://user?id={self.message.from_user.id}">{self.message.from_user.first_name}</a>' count = len(files) if self.message.chat.type == 'private': msg = f'<b>Name:</b> <code>{link}</code>\n' msg += f'<b>Total Files:</b> {count}' sendMessage(msg, self.bot, self.update) else: chat_id = str(self.message.chat.id)[4:] msg = f"<b>Name:</b> <a href='https://t.me/c/{chat_id}/{self.uid}'>{link}</a>\n" msg += f'<b>Total Files:</b> {count}\n' msg += f'cc: {uname}\n\n' fmsg = '' for index, item in enumerate(list(files), start=1): msg_id = files[item] link = f"https://t.me/c/{chat_id}/{msg_id}" fmsg += f"{index}. <a href='{link}'>{item}</a>\n" if len(fmsg) > 3900: sendMessage(msg + fmsg, self.bot, self.update) fmsg = '' if fmsg != '': sendMessage(msg + fmsg, self.bot, self.update) with download_dict_lock: try: fs_utils.clean_download(download_dict[self.uid].path()) except FileNotFoundError: pass del download_dict[self.uid] count = len(download_dict) if count == 0: self.clean() else: update_all_messages() return with download_dict_lock: msg = f'<b>Filename: </b><code>{download_dict[self.uid].name()}</code>\n<b>Size: </b><code>{size}</code>' if os.path.isdir( f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}' ): msg += '\n<b>Type: </b><code>Folder</code>' msg += f'\n<b>SubFolders: </b><code>{folders}</code>' msg += f'\n<b>Files: </b><code>{files}</code>' else: msg += f'\n<b>Type: </b><code>{typ}</code>' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = short_url(link) buttons.buildbutton("☁️ Drive Link", surl) else: buttons.buildbutton("☁️ Drive Link", link) LOGGER.info(f'Done Uploading {download_dict[self.uid].name()}') if INDEX_URL is not None: url_path = requests.utils.quote( f'{download_dict[self.uid].name()}') share_url = f'{INDEX_URL}/{url_path}' if os.path.isdir( f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}' ): share_url += '/' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(share_url) buttons.buildbutton("⚡ Index Link", siurl) else: buttons.buildbutton("⚡ Index Link", share_url) else: share_urls = f'{INDEX_URL}/{url_path}?a=view' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(share_url) buttons.buildbutton("⚡ Index Link", siurl) if VIEW_LINK: siurls = short_url(share_urls) buttons.buildbutton("🌐 View Link", siurls) else: buttons.buildbutton("⚡ Index Link", share_url) if VIEW_LINK: buttons.buildbutton("🌐 View Link", share_urls) if BUTTON_FOUR_NAME is not None and BUTTON_FOUR_URL is not None: buttons.buildbutton(f"{BUTTON_FOUR_NAME}", f"{BUTTON_FOUR_URL}") if BUTTON_FIVE_NAME is not None and BUTTON_FIVE_URL is not None: buttons.buildbutton(f"{BUTTON_FIVE_NAME}", f"{BUTTON_FIVE_URL}") if BUTTON_SIX_NAME is not None and BUTTON_SIX_URL is not None: buttons.buildbutton(f"{BUTTON_SIX_NAME}", f"{BUTTON_SIX_URL}") if self.message.from_user.username: uname = f"@{self.message.from_user.username}" else: uname = f'<a href="tg://user?id={self.message.from_user.id}">{self.message.from_user.first_name}</a>' if uname is not None: msg += f'\n\ncc: {uname}' try: fs_utils.clean_download(download_dict[self.uid].path()) except FileNotFoundError: pass del download_dict[self.uid] count = len(download_dict) sendMarkup(msg, self.bot, self.update, InlineKeyboardMarkup(buttons.build_menu(2))) if count == 0: self.clean() else: update_all_messages()
def drive_list(self, fileName): msg = "" fileName = self.escapes(str(fileName)) # Create Search Query for API request. query = f"'{parent_id}' in parents and (name contains '{fileName}')" response = self.__service.files().list( supportsTeamDrives=True, includeTeamDriveItems=True, q=query, spaces='drive', pageSize=200, fields='files(id, name, mimeType, size)', orderBy='name asc').execute() content_count = 0 if response["files"]: msg += f'<h4>{len(response["files"])} Results: {fileName}</h4><br><br>' for file in response.get('files', []): if file.get( 'mimeType' ) == "application/vnd.google-apps.folder": # Detect Whether Current Entity is a Folder or File. furl = f"https://drive.google.com/drive/folders/{file.get('id')}" msg += f"📁 <code>{file.get('name')}<br>(folder)</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = short_url(furl) msg += f"<b><a href={sfurl}>Drive Link</a></b>" else: msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}/' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(url) msg += f' <b>| <a href="{siurl}">Index Link</a></b>' else: msg += f' <b>| <a href="{url}">Index Link</a></b>' elif file.get( 'mimeType') == 'application/vnd.google-apps.shortcut': msg += f"⁍<a href='https://drive.google.com/drive/folders/{file.get('id')}'>{file.get('name')}" \ f"</a> (shortcut)" # Excluded index link as indexes cant download or open these shortcuts else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" msg += f"📄 <code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})</code><br>" if SHORTENER is not None and SHORTENER_API is not None: sfurl = short_url(furl) msg += f"<b><a href={sfurl}>Drive Link</a></b>" else: msg += f"<b><a href={furl}>Drive Link</a></b>" if INDEX_URL is not None: url_path = requests.utils.quote(f'{file.get("name")}') url = f'{INDEX_URL}/{url_path}' urls = f'{INDEX_URL}/{url_path}?a=view' if SHORTENER is not None and SHORTENER_API is not None: siurl = short_url(url) msg += f' <b>| <a href="{siurl}">Index Link</a></b>' if VIEW_LINK: siurls = short_url(urls) msg += f' <b>| <a href="{siurls}">View Link</a></b>' else: msg += f' <b>| <a href="{url}">Index Link</a></b>' if VIEW_LINK: msg += f' <b>| <a href="{urls}">View Link</a></b>' msg += '<br><br>' content_count += 1 if content_count == TELEGRAPHLIMIT: self.telegraph_content.append(msg) msg = "" content_count = 0 if msg != '': self.telegraph_content.append(msg) if len(self.telegraph_content) == 0: return "No Result Found ❌", None for content in self.telegraph_content: self.path.append( Telegraph(access_token=telegraph_token).create_page( title='Slam Mirrorbot Search', author_name='Slam Mirrorbot', author_url='https://github.com/SlamDevs/slam-mirrorbot', html_content=content)['path']) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>Found <code>{len(response['files'])}</code> results for <code>{fileName}</code></b>" buttons = button_build.ButtonMaker() buttons.buildbutton("🔎 VIEW", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1)) else: return '', ''