def clean(self): try: Interval[0].cancel() del Interval[0] delete_all_messages() except IndexError: pass
def cancel_all(update, context): with download_dict_lock: count = 0 for dlDetails in list(download_dict.values()): if dlDetails.status() == MirrorStatus.STATUS_DOWNLOADING \ or dlDetails.status() == MirrorStatus.STATUS_WAITING \ or dlDetails.status().startswith(MirrorStatus.STATUS_RETRYING): dlDetails.download().cancel_download() count += 1 delete_all_messages() sendMessage(f'Cancelled {count} downloads!', context.bot, update)
def cancel_all(update, context): with download_dict_lock: count = 0 for dlDetails in list(download_dict.values()): if dlDetails.status() in [ MirrorStatus.STATUS_DOWNLOADING, MirrorStatus.STATUS_WAITING, ]: dlDetails.download().cancel_download() count += 1 delete_all_messages() sendMessage(f"Cancelled {count} downloads!", 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)