def start(update, context): start_string = f''' This bot can mirror all your links to Google drive! Type /{BotCommands.HelpCommand} to get a list of available commands ''' buttons = button_build.ButtonMaker() buttons.buildbutton("Website", "https://filmszilla.com") buttons.buildbutton("Channel", "https://t.me/FilmsZilla") reply_markup = InlineKeyboardMarkup(buttons.build_menu(2)) update.effective_message.reply_photo(IMAGE_URL, start_string, parse_mode=ParseMode.MARKDOWN, reply_markup=reply_markup)
def start(update, context): start_string = f''' This bot can mirror all your links to Google drive! Type /{BotCommands.HelpCommand} to get a list of available commands ''' buttons = button_build.ButtonMaker() buttons.buildbutton("Repo", "https://github.com/breakdowns/slam-mirrorbot") buttons.buildbutton("Support Group", "https://t.me/SlamMirrorSupport") reply_markup = InlineKeyboardMarkup(buttons.build_menu(2)) update.effective_message.reply_photo(IMAGE_URL, start_string, parse_mode=ParseMode.MARKDOWN, reply_markup=reply_markup)
def start(update, context): start_string = f''' Bot Mirror Google Drive GRATISS!!!! Ketik /{BotCommands.HelpCommand} Untuk melihat perintah yang bisa digunakan ''' buttons = button_build.ButtonMaker() buttons.buildbutton("Repo", "https://github.com/breakdowns/slam-mirrorbot") buttons.buildbutton("Support Group", "https://t.me/SlamMirrorSupport") reply_markup = InlineKeyboardMarkup(buttons.build_menu(2)) update.effective_message.reply_photo(IMAGE_URL, start_string, parse_mode=ParseMode.MARKDOWN, reply_markup=reply_markup)
def _plugin_buttons(user_id): buttons = button_build.ButtonMaker() if not PLUGINS: client = _srch_client() sites = client.search_plugins() for name in sites: PLUGINS.append(name['name']) for siteName in PLUGINS: buttons.sbutton(siteName.capitalize(), f"torser {user_id} {siteName} plugin") buttons.sbutton('All', f"torser {user_id} all plugin") buttons.sbutton("Cancel", f"torser {user_id} cancel") button = InlineKeyboardMarkup(buttons.build_menu(2)) return button
def list_buttons(update, context): user_id = update.message.from_user.id try: key = update.message.text.split(" ", maxsplit=1)[1] except IndexError: return sendMessage('Send a search key along with command', context.bot, update) buttons = button_build.ButtonMaker() buttons.sbutton("Drive Root", f"types {user_id} root") buttons.sbutton("Recursive", f"types {user_id} recu") buttons.sbutton("Cancel", f"types {user_id} cancel") button = InlineKeyboardMarkup(buttons.build_menu(2)) sendMarkup('Choose option to list.', context.bot, update, button)
def get_readable_message(): with download_dict_lock: msg = "" start = 0 if STATUS_LIMIT is not None: dick_no = len(download_dict) global pages pages = math.ceil(dick_no / STATUS_LIMIT) if PAGE_NO > pages and pages != 0: globals()['COUNT'] -= STATUS_LIMIT globals()['PAGE_NO'] -= 1 start = COUNT for index, download in enumerate(list(download_dict.values())[start:], start=1): msg += f"<b>Filename:</b> <code>{download.name()}</code>" msg += f"\n<b>Status:</b> <i>{download.status()}</i>" if download.status() not in [ MirrorStatus.STATUS_ARCHIVING, MirrorStatus.STATUS_EXTRACTING, MirrorStatus.STATUS_SPLITTING, ]: msg += f"\n<code>{get_progress_bar_string(download)} {download.progress()}</code>" if download.status() == MirrorStatus.STATUS_CLONING: msg += f"\n<b>Cloned:</b> <code>{get_readable_file_size(download.processed_bytes())}</code> of <code>{download.size()}</code>" elif download.status() == MirrorStatus.STATUS_UPLOADING: msg += f"\n<b>Uploaded:</b> <code>{get_readable_file_size(download.processed_bytes())}</code> of <code>{download.size()}</code>" else: msg += f"\n<b>Downloaded:</b> <code>{get_readable_file_size(download.processed_bytes())}</code> of <code>{download.size()}</code>" msg += f"\n<b>Speed:</b> <code>{download.speed()}</code> <b>ETA:</b> <code>{download.eta()}</code>" try: msg += f"\n<b>Seeders:</b> <code>{download.aria_download().num_seeders}</code>" \ f" | <b>Peers:</b> <code>{download.aria_download().connections}</code>" except: pass try: msg += f"\n<b>Seeders:</b> <code>{download.torrent_info().num_seeds}</code>" \ f" | <b>Leechers:</b> <code>{download.torrent_info().num_leechs}</code>" except: pass msg += f"\n<b>To Cancel:</b> <code>/{BotCommands.CancelMirror} {download.gid()}</code>" msg += "\n\n" if STATUS_LIMIT is not None and index == STATUS_LIMIT: break if STATUS_LIMIT is not None and dick_no > STATUS_LIMIT: msg += f"<b>Page:</b> <code>{PAGE_NO}</code>/<code>{pages}</code> | <b>Tasks:</b> <code>{dick_no}</code>\n" buttons = button_build.ButtonMaker() buttons.sbutton("Previous", "pre") buttons.sbutton("Next", "nex") button = InlineKeyboardMarkup(buttons.build_menu(2)) return msg, button return msg, ""
def get_readable_message(): with download_dict_lock: msg = "" INDEX = 0 if STATUS_LIMIT is not None: dick_no = len(download_dict) global pages pages = math.ceil(dick_no / STATUS_LIMIT) if PAGE_NO > pages and pages != 0: globals()['COUNT'] -= STATUS_LIMIT globals()['PAGE_NO'] -= 1 for download in list(download_dict.values()): INDEX += 1 if INDEX > COUNT: msg += f"<b>Filename:</b> <code>{download.name()}</code>" msg += f"\n<b>Status:</b> <i>{download.status()}</i>" if download.status( ) != MirrorStatus.STATUS_ARCHIVING and download.status( ) != MirrorStatus.STATUS_EXTRACTING: msg += f"\n<code>{get_progress_bar_string(download)} {download.progress()}</code>" if download.status() == MirrorStatus.STATUS_DOWNLOADING: msg += f"\n<b>Downloaded:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}" elif download.status() == MirrorStatus.STATUS_CLONING: msg += f"\n<b>Cloned:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}" else: msg += f"\n<b>Uploaded:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}" msg += f"\n<b>Speed:</b> {download.speed()}" \ f", <b>ETA:</b> {download.eta()} " # if hasattr(download, 'is_torrent'): try: msg += f"\n<b>Seeders:</b> {download.aria_download().num_seeders}" \ f" | <b>Peers:</b> {download.aria_download().connections}" except: pass msg += f'\n<b>User:</b> <a href="tg://user?id={download.message.from_user.id}">{download.message.from_user.first_name}</a>' msg += f"\n<b>To Stop:</b> <code>/{BotCommands.CancelMirror} {download.gid()}</code>" msg += "\n\n" if STATUS_LIMIT is not None: if INDEX >= COUNT + STATUS_LIMIT: break if STATUS_LIMIT is not None: if INDEX > COUNT + STATUS_LIMIT: return None, None if dick_no > STATUS_LIMIT: msg += f"Page: {PAGE_NO}/{pages} | Tasks: {dick_no}\n" buttons = button_build.ButtonMaker() buttons.sbutton("Previous", "pre") buttons.sbutton("Next", "nex") button = InlineKeyboardMarkup(buttons.build_menu(2)) return msg, button return msg, ""
def drive_list(self, fileName): msg = "" # 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=20, fields='files(id, name, mimeType, size)', orderBy='modifiedTime desc').execute() if response["files"]: msg += f'<h4>Results : {fileName}</h4><br>SPX LEECHERS<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. msg += f"⁍<code>{file.get('name')}<br>(folder📁)</code><br>" \ f"<b><a href='https://drive.google.com/drive/folders/{file.get('id')}'>Drive Link</a></b>" if INDEX_URL is not None: url = requests.utils.requote_uri( f'{INDEX_URL}/{file.get("name")}/') msg += f' <b>| <a href="{url}">Index Link</a></b>' else: msg += f"⁍<code>{file.get('name')}<br>({get_readable_file_size(int(file.get('size')))})📄</code><br>" \ f"<b><a href='https://drive.google.com/uc?id={file.get('id')}&export=download'>Drive Link</a></b>" if INDEX_URL is not None: url = requests.utils.requote_uri( f'{INDEX_URL}/{file.get("name")}') msg += f' <b>| <a href="{url}">Index Link</a></b>' msg += '<br><br>' response = Telegraph(access_token=telegraph_token).create_page( title='SPX', author_name='SPX', author_url='https://t.me/PrivateDrivebot', html_content=msg)['path'] msg = f"<b>Search Results For {fileName} 👇</b>" buttons = button_build.ButtonMaker() buttons.buildbutton("HERE", f"https://telegra.ph/{response}") return msg, InlineKeyboardMarkup(buttons.build_menu(1)) else: return '', ''
def clone(self, link): self.transferred_size = 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.__service.files().get(supportsAllDrives=True, fileId=file_id, fields="name,id,mimeType,size").execute() except Exception as e: return f"{str(e).replace('>', '').replace('<', '')}" if meta.get("mimeType") == self.__G_DRIVE_DIR_MIME_TYPE: dir_id = self.create_directory(meta.get('name'), parent_id) try: result = self.cloneFolder(meta.get('name'), meta.get('name'), meta.get('id'), dir_id) msg += f'<b>Filename : </b><code>{meta.get("name")}</code>\n<b>Size : </b>{get_readable_file_size(self.transferred_size)}' buttons = button_build.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")}/') buttons.buildbutton("💥Index Link💥", url) else: file = self.copyFile(meta.get('id'), parent_id) msg += f'<b>Filename : </b><code>{file.get("name")}</code>' buttons = button_build.ButtonMaker() buttons.buildbutton("⚡Drive Link⚡", self.__G_DRIVE_BASE_DOWNLOAD_URL.format(file.get("id"))) try: msg += f'\n<b>Size : </b><code>{get_readable_file_size(int(meta.get("size")))}</code>' except TypeError: pass if INDEX_URL is not None: url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}') buttons.buildbutton("💥Index Link💥", url)
def _audio_subbuttons(task_id, msg, playlist=False): buttons = button_build.ButtonMaker() audio_qualities = [64, 128, 320] for q in audio_qualities: if playlist: i = 's' audio_format = f"ba/b-{q} t" else: i = '' audio_format = f"ba/b-{q}" buttons.sbutton(f"{q}K-mp3", f"qu {task_id} {audio_format}") buttons.sbutton("Back", f"qu {task_id} back") buttons.sbutton("Cancel", f"qu {task_id} cancel") SUBBUTTONS = InlineKeyboardMarkup(buttons.build_menu(2)) editMessage(f"Choose Audio{i} Bitrate:", msg, SUBBUTTONS)
def start(update, context): start_string = f''' This bot can mirror all your links to Google Drive! Type /{BotCommands.HelpCommand} to get a list of available commands ''' buttons = button_build.ButtonMaker() buttons.buildbutton("Repo", "https://github.com/SlamDevs/slam-mirrorbot") buttons.buildbutton("Channel", "https://t.me/SlamMirrorUpdates") reply_markup = InlineKeyboardMarkup(buttons.build_menu(2)) if CustomFilters.authorized_user(update) or CustomFilters.authorized_chat(update): if update.message.chat.type == "private" : sendMarkup(start_string, context.bot, update, reply_markup) else : sendMarkup(start_string, context.bot, update, reply_markup) else : sendMarkup(f"Oops! not a Authorized user.\nPlease deploy your own <b>slam-mirrorbot</b>.", context.bot, update, reply_markup)
def _search(key, site, message, tool): LOGGER.info(f"Searching: {key} from {site}") if tool == 'api': api = f"{SEARCH_API_LINK}/api/{site}/{key}" try: resp = rget(api) search_results = resp.json() if site == "all": search_results = list( itertools.chain.from_iterable(search_results)) if isinstance(search_results, list): msg = f"<b>Found {min(len(search_results), SEARCH_LIMIT)}</b>" msg += f" <b>result for <i>{key}</i>\nTorrent Site:- <i>{SITES.get(site)}</i></b>" else: return editMessage( f"No result found for <i>{key}</i>\nTorrent Site:- <i>{SITES.get(site)}</i>", message) except Exception as e: editMessage(str(e), message) else: client = get_client() search = client.search_start(pattern=str(key), plugins=str(site), category='all') search_id = search.id while True: result_status = client.search_status(search_id=search_id) status = result_status[0].status if status != 'Running': break dict_search_results = client.search_results(search_id=search_id) search_results = dict_search_results.results total_results = dict_search_results.total if total_results != 0: msg = f"<b>Found {min(total_results, SEARCH_LIMIT)}</b>" msg += f" <b>result for <i>{key}</i>\nTorrent Site:- <i>{site.capitalize()}</i></b>" else: return editMessage( f"No result found for <i>{key}</i>\nTorrent Site:- <i>{site.capitalize()}</i>", message) link = _getResult(search_results, key, message, tool) buttons = button_build.ButtonMaker() buttons.buildbutton("🔎 VIEW", link) button = InlineKeyboardMarkup(buttons.build_menu(1)) editMessage(msg, message, button) if tool != 'api': client.search_delete(search_id=search_id)
def start(update, context): start_string = f''' This bot can mirror all your links to Google Drive! Type /{BotCommands.HelpCommand} to get a list of available commands ''' buttons = button_build.ButtonMaker() buttons.buildbutton("Repo", "https://github.com/breakdowns/slam-mirrorbot") buttons.buildbutton("Support Group", "https://t.me/SlamMirrorSupport") reply_markup = InlineKeyboardMarkup(buttons.build_menu(2)) LOGGER.info('UID: {} - UN: {} - MSG: {}'.format(update.message.chat.id, update.message.chat.username, update.message.text)) if CustomFilters.authorized_user(update) or CustomFilters.authorized_chat(update): if update.message.chat.type == "private" : sendMessage(f"Hey I'm Alive 🙂", context.bot, update) else : update.effective_message.reply_photo(IMAGE_URL, start_string, parse_mode=ParseMode.MARKDOWN, reply_markup=reply_markup) else : sendMessage(f"Oops! not a Authorized user.", context.bot, update)
def onUploadComplete(self, link: str, size): with download_dict_lock: msg = f'<b>Filename: </b><code>{download_dict[self.uid].name()}</code>\n<b>Size: </b><code>{size}</code>' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, link)).text 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}' vshare_url = f'{INDEX_URL}/{url_path}?a=view' 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 = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, share_url)).text buttons.buildbutton("⚡Index Download Link⚡ ⫷[ʘϾḂ]⫸", siurl) else: buttons.buildbutton("⚡Index Download Link⚡ ⫷[ʘϾḂ]⫸", share_url) buttons.buildbutton("⚡Index Download Link⚡ ⫷[ʘϾḂ]⫸", vshare_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 self.message.from_user.username: uname = f"@classbackupbot" else: uname = f"@classbackupbot" if uname is not None: msg += f'\n\n Credit Goes TO ⫷[ʘϾḂ]⫸' 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 start(update, context): start_string = f''' This bot can mirror all your links to Google Drive! Type /{BotCommands.HelpCommand} to get a list of available commands ''' buttons = button_build.ButtonMaker() buttons.buildbutton("Repo", "https://github.com/ayushteke/slam_aria_mirror_bot") buttons.buildbutton("Channel", "https://t.me/AT_BOTs") reply_markup = InlineKeyboardMarkup(buttons.build_menu(2)) LOGGER.info('UID: {} - UN: {} - MSG: {}'.format(update.message.chat.id, update.message.chat.username, update.message.text)) uptime = get_readable_time((time.time() - botStartTime)) if CustomFilters.authorized_user(update) or CustomFilters.authorized_chat(update): if update.message.chat.type == "private" : sendMessage(f"Hey I'm Alive 🙂\nSince: <code>{uptime}</code>", context.bot, update) else : sendMarkup(IMAGE_URL, start_string, context.bot, update, reply_markup) else : sendMarkup(f"Oops! You are not allowed to use me.</b>.", context.bot, update, reply_markup)
def start(update, context): start_string = f''' This bot can mirror all your links to Google Drive! Type /{BotCommands.HelpCommand} to get a list of available commands ''' buttons = button_build.ButtonMaker() buttons.buildbutton("Repo", "https://github.com/breakdowns/slam-mirrorbot") buttons.buildbutton("Support Group", "https://t.me/SlamMirrorSupport") reply_markup = InlineKeyboardMarkup(buttons.build_menu(2)) LOGGER.info('UID: {} - UN: {} - MSG: {}'.format(update.message.chat.id, update.message.chat.username, update.message.text)) uptime = get_readable_time((time.time() - botStartTime)) if CustomFilters.authorized_user(update) or CustomFilters.authorized_chat(update): if update.message.chat.type == "private" : sendMessage(f"Hey I'm Alive 🙂\nSince: <code>{uptime}</code>", context.bot, update) else : sendMarkup(start_string, context.bot, update, reply_markup) else : sendMessage(f"Oops! not a Authorized user.", context.bot, update)
def onUploadComplete(self, link: str, size): with download_dict_lock: msg = f'<b>🚀 FileName: </b><code>{download_dict[self.uid].name()}</code>\n<b>🧪 Size: </b><code>{size}</code>\n\n<i>Do not share the Index Link Outside This Group!</i>' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, link)).text 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 = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, share_url)).text buttons.buildbutton("⚡Index Link⚡", siurl) else: buttons.buildbutton("⚡Index Link⚡", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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): with download_dict_lock: msg = f'<b>📂 File Name : {download_dict[self.uid].name()}</b>\n<b>📥 Total Size : {download_dict[self.uid].size()}</b>' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, link)).text buttons.buildbutton("⚡Google Drive⚡", surl) else: buttons.buildbutton("⚡Google Drive⚡", 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 += '/' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, share_url)).text buttons.buildbutton("💥Drive Index💥", siurl) else: buttons.buildbutton("💥Drive Index💥", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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\n<b>Uploader :- {uname}</b> ✨' 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): with download_dict_lock: msg = f'<b>➩ 🌀 File Name :</b> <code>{download_dict[self.uid].name()}</code>\n\n<b>➩ 💾 Total Size : </b><code>{size}</code>' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, link)).text buttons.buildbutton("🌍 𝗚-𝗗𝗥𝗜𝗩𝗘 𝗟𝗜𝗡𝗞 🌍", surl) else: buttons.buildbutton("🌍 𝗚-𝗗𝗥𝗜𝗩𝗘 𝗟𝗜𝗡𝗞 🌍", 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 += '/' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, share_url)).text buttons.buildbutton("🔒 𝗜𝗡𝗗𝗘𝗫 𝗟𝗜𝗡𝗞 🔒", siurl) else: buttons.buildbutton("🔒 𝗜𝗡𝗗𝗘𝗫 𝗟𝗜𝗡𝗞 🔒", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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\n<b>➩ 👤 Uploader :</b> {uname}\n\n<b>#Uploaded To Team Drive ✅</b>\n\n<b>➩ </b>\n\n<b>⚠ 𝗗𝗢 𝗡𝗢𝗧 <u>𝗦𝗛𝗔𝗥𝗘</u> 𝗜𝗡𝗗𝗘𝗫 𝗟𝗜𝗡𝗞 𝗣𝗨𝗕𝗟𝗜𝗖𝗟𝗬 ⚠</b>' 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): with download_dict_lock: msg = f'📁 𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲 : <code>{download_dict[self.uid].name()}</code>\n\n<b>📀 Total Size : </b> {download_dict[self.uid].size()}' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, link)).text buttons.buildbutton("🌎 𝐃𝐫𝐢𝐯𝐞 𝐋𝐢𝐧𝐤", surl) else: buttons.buildbutton("🌎 𝐃𝐫𝐢𝐯𝐞 𝐋𝐢𝐧𝐤", 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 += '/' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, share_url)).text buttons.buildbutton("💡 𝐈𝐧𝐝𝐞𝐱 𝐋𝐢𝐧𝐤", siurl) else: buttons.buildbutton("💡 𝐈𝐧𝐝𝐞𝐱 𝐋𝐢𝐧𝐤", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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\n<b>👤 Uploader: </b>👉 {uname}\n\n▫️#Uploaded To Team Drive ✓ \n\n⛔ 𝘿𝙤 𝙣𝙤𝙩 𝙨𝙝𝙖𝙧𝙚 𝙄𝙣𝙙𝙚𝙭 𝙇𝙞𝙣𝙠🙂 \n\n🛡️𝗣𝗼𝘄𝗲𝗿𝗲𝗱 𝗕𝘆: <b>@shukryshuk</b>' 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): with download_dict_lock: msg = f'<b>Fɪʟᴇɴᴀᴍᴇ : </b><code>{download_dict[self.uid].name()}</code>\n<b>🙈Sɪᴢᴇ : </b><code>{size}</code>' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, link)).text buttons.buildbutton("🤕Dʀɪᴠᴇ Lɪɴᴋ🤕", surl) else: buttons.buildbutton("🤕Dʀɪᴠᴇ Lɪɴᴋ🤕", 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 += '/' if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, share_url)).text buttons.buildbutton("⚡️Iɴᴅᴇx Lɪɴᴋ⚡️", siurl) else: buttons.buildbutton("⚡️Iɴᴅᴇx Lɪɴᴋ⚡️", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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\n<b>🗣️Hᴇʏ</b> ⁍{uname}⁌, <b>Yᴏᴜʀ Fɪʟᴇ Is 🪂Mɪʀʀᴏʀᴇᴅ & Uᴘʟᴏᴀᴅᴇᴅ </b>' 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): with download_dict_lock: msg = f'<b>📁 Filename : </b><code>{download_dict[self.uid].name()}</code>\n<b>💾 Size : </b><code>{download_dict[self.uid].size()}</code>' buttons = button_build.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 += '/' buttons.buildbutton("💥Index Link💥", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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): with download_dict_lock: msg = f'<b>○ ✳️ Filename : </b><code>{download_dict[self.uid].name()}</code>\n\n<b>○ 💽 Total Size : </b><code>{download_dict[self.uid].size()}</code>' buttons = button_build.ButtonMaker() buttons.buildbutton("♻️G-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 += '/' buttons.buildbutton("⚡INDEX LINK⚡", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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\n<b>○ 👥 Uploader :</b> {uname}\n\n<b>⚠️NOTE::Do not share the index link elsewhere!If you share, you will be banned</b>\n\n<b>#Uploaded to Drive Done✅</b>\n\n<b>○ 🛡️ Powered By: @MDH_HINDI</b>' 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): with download_dict_lock: msg = f'<b>○ 🌀 Filename : </b><code>{download_dict[self.uid].name()}</code>\n\n<b>○ 💾 Total Size : </b><code>{download_dict[self.uid].size()}</code>' buttons = button_build.ButtonMaker() buttons.buildbutton("🌍 𝗚-𝗗𝗥𝗜𝗩𝗘 𝗨𝗥𝗟", 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 += '/' buttons.buildbutton("🏷️ 𝗜𝗡𝗗𝗘𝗫 𝗨𝗥𝗟 🏷️", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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\n<b>○👥 Uploader:</b>👉 {uname}\n\n🔹#Uploaded To Team Drive ✔️\n\n⛔ 𝗗𝗢 𝗡𝗢𝗧 𝗦𝗛𝗔𝗥𝗘 𝗧𝗛𝗘 𝗜𝗡𝗗𝗘𝗫 𝗟𝗜𝗡𝗞 𝗔𝗡𝗬𝗪𝗛𝗘𝗥𝗘 𝗘𝗟𝗦𝗘!\n\n<b>🛡️𝗣𝗼𝘄𝗲𝗿𝗲𝗱 𝗕𝘆:: @MDH_HINDI</b>' 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): with download_dict_lock: msg = f'<u>𝗣𝗼𝘄𝗲𝗿𝗲𝗱 𝗕𝘆</u> <a href="https://t.me/premiumcoursesdrive">📚 Courses Drive 📚</a>\n\n𝗙𝗶𝗹𝗲𝗻𝗮𝗺𝗲🗂 : <code>{download_dict[self.uid].name()}</code>\n𝗦𝗶𝘇𝗲 ⚖️ : <code>{download_dict[self.uid].size()}</code>\n\nOnly Use TeamDrive Link if you have Access.\nDon\'t request access through this link' buttons = button_build.ButtonMaker() buttons.buildbutton("📚 Course 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 += '/' buttons.buildbutton("✳️Index Link✳️", share_url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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 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\n𝗨𝗽𝗹𝗼𝗮𝗱𝗲𝗿 : {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 torser(update, context): user_id = update.message.from_user.id try: key = update.message.text.split(" ", maxsplit=1)[1] except IndexError: return sendMessage("Send a search key along with command", context.bot, update) if SEARCH_API_LINK is not None and SEARCH_PLUGINS is not None: buttons = button_build.ButtonMaker() buttons.sbutton('Api', f"torser {user_id} api") buttons.sbutton('Plugins', f"torser {user_id} plugin") buttons.sbutton("Cancel", f"torser {user_id} cancel") button = InlineKeyboardMarkup(buttons.build_menu(2)) sendMarkup('Choose tool to search:', context.bot, update, button) elif SEARCH_API_LINK is not None and SEARCH_PLUGINS is None: button = _api_buttons(user_id) sendMarkup('Choose site to search:', context.bot, update, button) elif SEARCH_API_LINK is None and SEARCH_PLUGINS is not None: button = _plugin_buttons(user_id) sendMarkup('Choose site to search:', context.bot, update, button) else: return sendMessage("No API link or search PLUGINS added for this function", context.bot, update)
def leechSet(update, context): user_id = update.message.from_user.id path = f"Thumbnails/{user_id}.jpg" msg = f"Leech Type for {user_id} user is " if (user_id in AS_DOC_USERS or user_id not in AS_MEDIA_USERS and AS_DOCUMENT): msg += "DOCUMENT" else: msg += "MEDIA" msg += "\nCustom Thumbnail " msg += "exists" if os.path.exists(path) else "not exists" buttons = button_build.ButtonMaker() buttons.sbutton("As Document", f"doc {user_id}") buttons.sbutton("As Media", f"med {user_id}") buttons.sbutton("Delete Thumbnail", f"thumb {user_id}") if AUTO_DELETE_MESSAGE_DURATION == -1: buttons.sbutton("Close", f"closeset {user_id}") button = InlineKeyboardMarkup(buttons.build_menu(2)) choose_msg = sendMarkup(msg, context.bot, update, button) threading.Thread(target=auto_delete_message, args=(context.bot, update.message, choose_msg)).start()
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='modifiedTime desc').execute() content_count = 0 if response["files"]: msg += f'<h4>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 = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text msg += f"<b><a href={sfurl}>⚡Google Drive</a></b>" else: msg += f"<b><a href={furl}>⚡Google Drive⚡</a></b>" if INDEX_URL is not None: url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}/') if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text msg += f' <b>| <a href="{siurl}">💥Index Link💥</a></b>' else: msg += f' <b>| <a href="{url}">💥Index Link💥</a></b>' 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 = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, furl)).text msg += f"<b><a href={sfurl}>⚡Google Drive⚡</a></b>" else: msg += f"<b><a href={furl}>⚡Google Drive⚡</a></b>" if INDEX_URL is not None: url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}') if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text msg += f' <b>| <a href="{siurl}">💥Index Link💥</a></b>' else: msg += f' <b>| <a href="{url}">💥Index 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 = 'Telegraph Search', author_name='Telegraph', author_url='https://telegra.ph', html_content=content )['path']) self.num_of_path = len(self.path) if self.num_of_path > 1: self.edit_telegraph() msg = f"<b>🔎 Search Results For <i>{fileName}</i></b> \n<b>📚 Found {len(response['files'])} Results</b>" buttons = button_build.ButtonMaker() buttons.buildbutton("Here", f"https://telegra.ph/{self.path[0]}") return msg, InlineKeyboardMarkup(buttons.build_menu(1)) else : return '', ''
def clone(self, link): self.transferred_size = 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) result = self.cloneFolder(meta.get('name'), meta.get('name'), meta.get('id'), dir_id) msg += f'<b>📄 File Name : </b><code>{meta.get("name")}</code>\n<b>📥 Size : {get_readable_file_size(self.transferred_size)}</b>' durl = self.__G_DRIVE_DIR_BASE_DOWNLOAD_URL.format(dir_id) buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, durl)).text buttons.buildbutton("⚡Google Drive⚡", surl) else: buttons.buildbutton("⚡Google Drive⚡", durl) if INDEX_URL is not None: url = requests.utils.requote_uri(f'{INDEX_URL}/{meta.get("name")}/') if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text buttons.buildbutton("💥Index Link💥", siurl) else: buttons.buildbutton("💥Index Link💥", url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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}") else: file = self.copyFile(meta.get('id'), parent_id) msg += f'<b>📄 File Name :</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 = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, durl)).text buttons.buildbutton("⚡Google Drive⚡", surl) else: buttons.buildbutton("⚡Google Drive⚡", durl) try: msg += f'\n<b>📥 Size : {get_readable_file_size(int(meta.get("size")))}</b>' except TypeError: pass if INDEX_URL is not None: url = requests.utils.requote_uri(f'{INDEX_URL}/{file.get("name")}') if SHORTENER is not None and SHORTENER_API is not None: siurl = requests.get('https://{}/api?api={}&url={}&format=text'.format(SHORTENER, SHORTENER_API, url)).text buttons.buildbutton("💥Index Link💥", siurl) else: buttons.buildbutton("💥Index Link💥", url) if BUTTON_THREE_NAME is not None and BUTTON_THREE_URL is not None: buttons.buildbutton(f"{BUTTON_THREE_NAME}", f"{BUTTON_THREE_URL}") 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}") 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, 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))