def cloneNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] msg = sendMessage(f"Cloning: <code>{link}</code>", context.bot, update) gd = GoogleDriveHelper() result = gd.clone(link) deleteMessage(context.bot, msg) sendMessage(result, context.bot, update) else: sendMessage("Provide G-Drive Shareable Link to Clone.", context.bot, update)
def mirror_status(update, context): message = get_readable_message() if len(message) == 0: message = "No active downloads" reply_message = sendMessage(message, context.bot, update) threading.Thread(target=auto_delete_message, args=(bot, update.message, reply_message)).start() return index = update.effective_chat.id with status_reply_dict_lock: if index in status_reply_dict.keys(): deleteMessage(bot, status_reply_dict[index]) del status_reply_dict[index] sendStatusMessage(update, context.bot) deleteMessage(context.bot, update.message)
def cloneNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] gd = GoogleDriveHelper() if CLONE_LIMIT is not None or STOP_DUPLICATE_CLONE: res, clonesize, name = gd.clonehelper(link) if res != "": sendMessage(res, context.bot, update) return if STOP_DUPLICATE_CLONE: LOGGER.info(f"š Checking File/Folder if already in Drive...") smsg, button = gd.drive_list(name) if smsg: msg3 = "File/Folder is already available in Drive.\nHere are the search results:" sendMarkup(msg3, context.bot, update, button) return if CLONE_LIMIT is not None: LOGGER.info(f"Checking File/Folder Size...") limit = CLONE_LIMIT limit = limit.split(' ', maxsplit=1) limitint = int(limit[0]) msg2 = f'Failed, Clone limit is {CLONE_LIMIT}.\nYour File/Folder size is {get_readable_file_size(clonesize)}.' if 'G' in limit[1] or 'g' in limit[1]: if clonesize > limitint * 1024**3: sendMessage(msg2, context.bot, update) return elif 'T' in limit[1] or 't' in limit[1]: if clonesize > limitint * 1024**4: sendMessage(msg2, context.bot, update) return msg = sendMessage(f"š Cloning : <code>{link}</code>", context.bot, update) result, button = gd.clone(link) 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'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>' if uname is not None: cc = f'\n\nš¤ šš¹š¼š»š²šæ : {uname}\n\nš„ š£šæš¶š¶š¶š¶šš¼ š š¶šæšæš¼šæ šš¼š»š\n\nš„ ššæš¼šš½ : @PriiiiyoMirror\n\nā«ļø#Uploaded To Team Drive ā \n\nš« šš¼ š”š¼š š¦šµš®šæš² šš»š±š²š šš¶š»šø \n\nā š£š¼šš²šæš²š± šš : @PriiiiyoBOTs' sendMarkup(result + cc, context.bot, update, button) else: sendMessage('Provide G-Drive Shareable Link to Clone.', context.bot, update)
def countNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] msg = sendMessage(f"Counting: <code>{link}</code>", context.bot, update) gd = GoogleDriveHelper() result = gd.count(link) deleteMessage(context.bot, msg) if update.message.from_user.username: uname = f'@{update.message.from_user.username}' else: uname = f'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>' 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)
def countNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] msg = sendMessage(f"š Counting : <code>{link}</code>", context.bot, update) gd = GoogleDriveHelper() result = gd.count(link) deleteMessage(context.bot, msg) if update.message.from_user.username: uname = f'@{update.message.from_user.username}' else: uname = f'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>' if uname is not None: cc = f'\n\nš¤ šš¼šš»šš²šæ : {uname}\n\nš„ š£šæš¶š¶š¶š¶šš¼ š š¶šæšæš¼šæ šš¼š»š\n\nš„ ššæš¼šš½ : @PriiiiyoMirror\n\nā«ļø#Uploaded To Team Drive ā \n\nš« šš¼ š”š¼š š¦šµš®šæš² šš»š±š²š šš¶š»šø \n\nā š£š¼šš²šæš²š± šš : @PriiiiyoBOTs' sendMessage(result + cc, context.bot, update) else: sendMessage("Provide G-Drive Shareable Link to Count.", context.bot, update)
def mirror_status(update, context): with download_dict_lock: if len(download_dict) == 0: currentTime = get_readable_time(time() - botStartTime) total, used, free, _ = disk_usage('.') free = get_readable_file_size(free) message = 'No Active Downloads !\n___________________________' message += f"\n<b>CPU:</b> {cpu_percent()}% | <b>FREE:</b> {free}" \ f"\n<b>RAM:</b> {virtual_memory().percent}% | <b>UPTIME:</b> {currentTime}" reply_message = sendMessage(message, context.bot, update) Thread(target=auto_delete_message, args=(context.bot, update.message, reply_message)).start() return index = update.effective_chat.id with status_reply_dict_lock: if index in status_reply_dict.keys(): deleteMessage(context.bot, status_reply_dict[index]) del status_reply_dict[index] sendStatusMessage(update, context.bot) deleteMessage(context.bot, update.message)
def countNode(update, context): args = update.message.text.split(" ", maxsplit=1) reply_to = update.message.reply_to_message link = '' if len(args) > 1: link = args[1] if update.message.from_user.username: tag = f"@{update.message.from_user.username}" else: tag = update.message.from_user.mention_html( update.message.from_user.first_name) if reply_to is not None: if len(link) == 0: link = reply_to.text if reply_to.from_user.username: tag = f"@{reply_to.from_user.username}" else: tag = reply_to.from_user.mention_html( reply_to.from_user.first_name) gdtot_link = is_gdtot_link(link) if gdtot_link: try: link = gdtot(link) except DirectDownloadLinkException as e: return sendMessage(str(e), context.bot, update) if is_gdrive_link(link): msg = sendMessage(f"Counting: <code>{link}</code>", context.bot, update) gd = GoogleDriveHelper() result = gd.count(link) deleteMessage(context.bot, msg) cc = f'\n\n<b>cc: </b>{tag}' sendMessage(result + cc, context.bot, update) if gdtot_link: gd.deletefile(link) else: sendMessage( 'Send Gdrive link along with command or by replying to the link by command', context.bot, update)
def cloneNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] gd = GoogleDriveHelper() if CLONE_LIMIT is not None or STOP_DUPLICATE_CLONE: msg1 = sendMessage(f"Checking Your Link...", context.bot, update) res, clonesize, name = gd.clonehelper(link) if res != "": deleteMessage(context.bot, msg1) sendMessage(res, context.bot, update) return if STOP_DUPLICATE_CLONE: smsg, button = gd.drive_list(name) if smsg: deleteMessage(context.bot, msg1) msg3 = "<b>File/Folder is already available in Drive</b>.\n<b>Here are the search results:</b>" sendMarkup(msg3, context.bot, update, button) return if CLONE_LIMIT is not None: limit = CLONE_LIMIT limit = limit.split(' ', maxsplit=1) limitint = int(limit[0]) msg2 = f'Failed, Clone limit is {CLONE_LIMIT}.\nYour File/Folder size is {get_readable_file_size(clonesize)}.' if 'GB' in limit or 'gb' in limit: if clonesize > limitint * 1024**3: deleteMessage(context.bot, msg1) sendMessage(msg2, context.bot, update) return else: deleteMessage(context.bot, msg1) elif 'TB' in limit or 'tb' in limit: if clonesize > limitint * 1024**4: deleteMessage(context.bot, msg1) sendMessage(msg2, context.bot, update) return else: deleteMessage(context.bot, msg1) msg = sendMessage(f"Cloning: <code>{link}</code>", context.bot, update) result, button = gd.clone(link) 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'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>' if uname is not None: cc = f'\n\ncc: {uname}' sendMarkup(result + cc, context.bot, update, button) else: sendMessage('Provide G-Drive Shareable Link to Clone.', context.bot, update)
def cloneNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] 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: <code>{link}</code>", context.bot, update) result, button = gd.clone(link) 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'<a href="tg://user?id={update.message.from_user.id}">{update.message.from_user.first_name}</a>' 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)
def cloneNode(update, context): args = update.message.text.split(" ", maxsplit=1) reply_to = update.message.reply_to_message if len(args) > 1: link = args[1] if update.message.from_user.username: tag = f"@{update.message.from_user.username}" else: tag = update.message.from_user.mention_html( update.message.from_user.first_name) elif reply_to is not None: link = reply_to.text if reply_to.from_user.username: tag = f"@{reply_to.from_user.username}" else: tag = reply_to.from_user.mention_html( reply_to.from_user.first_name) else: link = '' gdtot_link = is_gdtot_link(link) if gdtot_link: try: msg = sendMessage(f"Processing: <code>{link}</code>", context.bot, update) link = gdtot(link) deleteMessage(context.bot, msg) except DirectDownloadLinkException as e: deleteMessage(context.bot, msg) return sendMessage(str(e), context.bot, update) if is_gdrive_link(link): gd = GoogleDriveHelper() res, size, name, files = gd.helper(link) if res != "": return sendMessage(res, context.bot, update) if STOP_DUPLICATE: LOGGER.info('Checking File/Folder if already in Drive...') smsg, button = gd.drive_list(name, True, True) if smsg: msg3 = "File/Folder is already available in Drive.\nHere are the search results:" sendMarkup(msg3, context.bot, update, button) if gdtot_link: gd.deletefile(link) return if CLONE_LIMIT is not None: LOGGER.info('Checking File/Folder Size...') if size > CLONE_LIMIT * 1024**3: msg2 = f'Failed, Clone limit is {CLONE_LIMIT}GB.\nYour File/Folder size is {get_readable_file_size(size)}.' return sendMessage(msg2, context.bot, update) if files <= 10: msg = sendMessage(f"Cloning: <code>{link}</code>", context.bot, update) result, button = gd.clone(link) deleteMessage(context.bot, msg) else: drive = GoogleDriveHelper(name) gid = ''.join(random.SystemRandom().choices(string.ascii_letters + string.digits, k=12)) clone_status = CloneStatus(drive, size, update, gid) with download_dict_lock: download_dict[update.message.message_id] = clone_status sendStatusMessage(update, context.bot) result, button = drive.clone(link) with download_dict_lock: del download_dict[update.message.message_id] count = len(download_dict) try: if count == 0: Interval[0].cancel() del Interval[0] delete_all_messages() else: update_all_messages() except IndexError: pass cc = f'\n\n<b>cc: </b>{tag}' if button in ["cancelled", ""]: sendMessage(f"{tag} {result}", context.bot, update) else: sendMarkup(result + cc, context.bot, update, button) if gdtot_link: gd.deletefile(link) else: sendMessage( 'Send Gdrive or gdtot link along with command or by replying to the link by command', context.bot, update)
def add_qb_torrent(link, path, listener, select): client = get_client() pincode = "" try: if ospath.exists(link): is_file = True ext_hash = _get_hash_file(link) else: is_file = False ext_hash = _get_hash_magnet(link) tor_info = client.torrents_info(torrent_hashes=ext_hash) if len(tor_info) > 0: sendMessage("This Torrent is already in list.", listener.bot, listener.update) client.auth_log_out() return if is_file: op = client.torrents_add(torrent_files=[link], save_path=path) osremove(link) else: op = client.torrents_add(link, save_path=path) sleep(0.3) if op.lower() == "ok.": meta_time = time() tor_info = client.torrents_info(torrent_hashes=ext_hash) if len(tor_info) == 0: while True: if time() - meta_time >= 30: ermsg = "The Torrent was not added. Report when you see this error" sendMessage(ermsg, listener.bot, listener.update) client.torrents_delete(torrent_hashes=ext_hash, delete_files=True) client.auth_log_out() return tor_info = client.torrents_info(torrent_hashes=ext_hash) if len(tor_info) > 0: break else: sendMessage("This is an unsupported/invalid link.", listener.bot, listener.update) client.torrents_delete(torrent_hashes=ext_hash, delete_files=True) client.auth_log_out() return tor_info = tor_info[0] ext_hash = tor_info.hash gid = ''.join(random.SystemRandom().choices(string.ascii_letters + string.digits, k=14)) with download_dict_lock: download_dict[listener.uid] = QbDownloadStatus( listener, client, gid, ext_hash, select) LOGGER.info( f"QbitDownload started: {tor_info.name} - Hash: {ext_hash}") Thread(target=_qb_listener, args=(listener, client, gid, ext_hash, select, meta_time, path)).start() if BASE_URL is not None and select: if not is_file: metamsg = "Downloading Metadata, wait then you can select files or mirror torrent file" meta = sendMessage(metamsg, listener.bot, listener.update) while True: tor_info = client.torrents_info(torrent_hashes=ext_hash) if len(tor_info) == 0: deleteMessage(listener.bot, meta) return try: tor_info = tor_info[0] if tor_info.state in ["metaDL", "checkingResumeData"]: sleep(1) else: deleteMessage(listener.bot, meta) break except: deleteMessage(listener.bot, meta) return sleep(0.5) client.torrents_pause(torrent_hashes=ext_hash) for n in str(ext_hash): if n.isdigit(): pincode += str(n) if len(pincode) == 4: break buttons = button_build.ButtonMaker() if WEB_PINCODE: buttons.buildbutton("Select Files", f"{BASE_URL}/app/files/{ext_hash}") buttons.sbutton("Pincode", f"pin {gid} {pincode}") else: buttons.buildbutton( "Select Files", f"{BASE_URL}/app/files/{ext_hash}?pin_code={pincode}") buttons.sbutton("Done Selecting", f"done {gid} {ext_hash}") QBBUTTONS = InlineKeyboardMarkup(buttons.build_menu(2)) msg = "Your download paused. Choose files then press Done Selecting button to start downloading." sendMarkup(msg, listener.bot, listener.update, QBBUTTONS) else: sendStatusMessage(listener.update, listener.bot) except Exception as e: sendMessage(str(e), listener.bot, listener.update) client.auth_log_out()