def mirror_status(update: Update, context): message = get_readable_message() if len(message) == 0: message = "No active downloads" sendMessage(message, context, update) return index = update.effective_chat.id with status_reply_dict_lock: if index in status_reply_dict.keys(): deleteMessage(context, status_reply_dict[index]) del status_reply_dict[index] kill_thread = False while len(message) != 0: message = get_readable_message() with status_reply_dict_lock: if index in status_reply_dict.keys(): if len(message) == 0: message = "No active downloads" editMessage(message, context, status_reply_dict[index]) break try: editMessage(message, context, status_reply_dict[index]) except BadRequest: break else: # If the loop returns here 2nd time, it means the message # has been replaced by a new message due to a second /status command in the chat. # So we kill the thread by simply breaking the loop if kill_thread: break status_reply_dict[index] = sendMessage(message, context, update) kill_thread = True sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
def sendStatusMessage(msg, bot): progress = get_readable_message() progress += f"🐸🐸🐸🐸🐸🐸🐸🐸" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 for download in list(download_dict.values()): speedy = download.speed() if download.status() == MirrorStatus.STATUS_DOWNLOADING: if 'KiB/s' in speedy: dlspeed_bytes += float(speedy.split('K')[0]) * 1024 elif 'MiB/s' in speedy: dlspeed_bytes += float(speedy.split('M')[0]) * 1048576 if download.status() == MirrorStatus.STATUS_UPLOADING: if 'KB/s' in speedy: uldl_bytes += float(speedy.split('K')[0]) * 1024 elif 'MB/s' in speedy: uldl_bytes += float(speedy.split('M')[0]) * 1048576 #dlspeed = get_readable_file_size(dlspeed_bytes) #ulspeed = get_readable_file_size(uldl_bytes) #progress += f"\n<b>DL: </b>{dlspeed}ps 🔻| <b>UL: </b>{ulspeed}ps 🔺\n" with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as e: LOGGER.error(str(e)) del status_reply_dict[msg.message.chat.id] pass if len(progress) == 0: progress = "Starting DL" message = sendMessage(progress, bot, msg) status_reply_dict[msg.message.chat.id] = message
def sendStatusMessage(msg, bot): currentTime = get_readable_time((time.time() - botStartTime)) total, used, free = shutil.disk_usage('.') total = get_readable_file_size(total) used = get_readable_file_size(used) free = get_readable_file_size(free) progress = get_readable_message() progress += f"𝗖𝗣𝗨 📟: {psutil.cpu_percent()}%" \ f" 𝗗𝗜𝗦𝗞💿: {psutil.disk_usage('/').percent}%" \ f" 𝗥𝗔𝗠 💾: {psutil.virtual_memory().percent}%" \ f"\n𝗕𝗼𝘁 𝗨𝗽𝘁𝗶𝗺𝗲 : {currentTime} | 𝗙𝗿𝗲𝗲 🤯: {free}" with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as e: LOGGER.error(str(e)) del status_reply_dict[msg.message.chat.id] pass if len(progress) == 0: progress = "Starting DL" message = sendMessage(progress, bot, msg) status_reply_dict[msg.message.chat.id] = message
def update_all_messages(): msg = get_readable_message() msg += f"<b>✥════ @TGFilmZone ════✥</b>" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 for download in list(download_dict.values()): speedy = download.speed() if download.status() == MirrorStatus.STATUS_DOWNLOADING: if 'KiB/s' in speedy: dlspeed_bytes += float(speedy.split('K')[0]) * 1024 elif 'MiB/s' in speedy: dlspeed_bytes += float(speedy.split('M')[0]) * 1048576 if download.status() == MirrorStatus.STATUS_UPLOADING: if 'KB/s' in speedy: uldl_bytes += float(speedy.split('K')[0]) * 1024 elif 'MB/s' in speedy: uldl_bytes += float(speedy.split('M')[0]) * 1048576 #dlspeed = get_readable_file_size(dlspeed_bytes) #ulspeed = get_readable_file_size(uldl_bytes) #msg += f"\n<b>DL:</b> {dlspeed}ps 🔻| <b>UL:</b> {ulspeed}ps 🔺\n" with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[ chat_id] and msg != status_reply_dict[chat_id].text: if len(msg) == 0: msg = "Starting DL" try: editMessage(msg, status_reply_dict[chat_id]) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def _mirror(update, context, isTar=False): message_args = update.message.text.split(' ') try: link = message_args[1] except IndexError: link = '' LOGGER.info(link) link = link.strip() if len(link) == 0: if update.message.reply_to_message is not None: document = update.message.reply_to_message.document if document is not None and document.mime_type == "application/x-bittorrent": link = document.get_file().file_path else: sendMessage('Only torrent files can be mirrored from telegram', context, update) return if not bot_utils.is_url(link) and not bot_utils.is_magnet(link): sendMessage('No download source provided', context, update) return reply_msg = sendMessage('Starting Download', context, update) index = update.effective_chat.id with status_reply_dict_lock: if index in status_reply_dict.keys(): try: deleteMessage(context, status_reply_dict[index]) except BadRequest: pass status_reply_dict[index] = reply_msg listener = MirrorListener(context, update, reply_msg, isTar) aria = download_tools.DownloadHelper(listener) t = threading.Thread(target=aria.add_download, args=(link, )) t.start()
def sendStatusMessage(msg, bot): progress = get_readable_message() progress += f"<b>CPU:</b> {psutil.cpu_percent()}%\n" \ f"<b>RAM:</b> {psutil.virtual_memory().percent}%\n" \ f"<b>DISK:</b> {psutil.disk_usage('/').percent}%\n" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 for download in list(download_dict.values()): speedy = download.speed() if download.status() == MirrorStatus.STATUS_DOWNLOADING: if 'KiB/s' in speedy: dlspeed_bytes += float(speedy.split('K')[0]) * 1024 elif 'MiB/s' in speedy: dlspeed_bytes += float(speedy.split('M')[0]) * 1048576 if download.status() == MirrorStatus.STATUS_UPLOADING: if 'KB/s' in speedy: uldl_bytes += float(speedy.split('K')[0]) * 1024 elif 'MB/s' in speedy: uldl_bytes += float(speedy.split('M')[0]) * 1048576 dlspeed = get_readable_file_size(dlspeed_bytes) ulspeed = get_readable_file_size(uldl_bytes) progress += f"\n<b>DL: </b>{dlspeed}ps 🔻| <b>UL: </b>{ulspeed}ps 🔺\n" with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as e: LOGGER.error(str(e)) del status_reply_dict[msg.message.chat.id] message = sendMessage(progress, bot, msg) status_reply_dict[msg.message.chat.id] = message
def update_all_messages(): msg = get_readable_message() msg += f"<b>CPU:</b> {psutil.cpu_percent()}%\n" \ f"<b>RAM:</b> {psutil.virtual_memory().percent}%\n" \ f"<b>DISK:</b> {psutil.disk_usage('/').percent}%\n" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 for download in list(download_dict.values()): speedy = download.speed() if download.status() == MirrorStatus.STATUS_DOWNLOADING: if 'KiB/s' in speedy: dlspeed_bytes += float(speedy.split('K')[0]) * 1024 elif 'MiB/s' in speedy: dlspeed_bytes += float(speedy.split('M')[0]) * 1048576 if download.status() == MirrorStatus.STATUS_UPLOADING: if 'KB/s' in speedy: uldl_bytes += float(speedy.split('K')[0]) * 1024 elif 'MB/s' in speedy: uldl_bytes += float(speedy.split('M')[0]) * 1048576 dlspeed = get_readable_file_size(dlspeed_bytes) ulspeed = get_readable_file_size(uldl_bytes) msg += f"\n<b>DL:</b> {dlspeed}ps 🔻| <b>UL:</b> {ulspeed}ps 🔺\n" with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[ chat_id] and msg != status_reply_dict[chat_id].text: if len(msg) == 0: msg = "Starting DL" try: editMessage(msg, status_reply_dict[chat_id]) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def update_all_messages(): msg = get_readable_message() msg += f"<b>🖥️CPU:</b> {psutil.cpu_percent()}%" \ f" <b>📀Penyimpanan:</b> {psutil.disk_usage('/').percent}%" \ f" <b>📝RAM:</b> {psutil.virtual_memory().percent}%" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 for download in list(download_dict.values()): speedy = download.speed() if download.status() == MirrorStatus.STATUS_DOWNLOADING: if 'KiloByte/s' in speedy: dlspeed_bytes += float(speedy.split('K')[0]) * 1024 elif 'MegaByte/s' in speedy: dlspeed_bytes += float(speedy.split('M')[0]) * 1048576 if download.status() == MirrorStatus.STATUS_UPLOADING: if 'KiloByte/s' in speedy: uldl_bytes += float(speedy.split('K')[0]) * 1024 elif 'MegaByte/s' in speedy: uldl_bytes += float(speedy.split('M')[0]) * 1048576 dlspeed = get_readable_file_size(dlspeed_bytes) ulspeed = get_readable_file_size(uldl_bytes) msg += f"\n<b>Kecepatan Downlod:</b>{dlspeed}ps ⏬| <b>Kecepatan Upload:</b>{ulspeed}ps ⏫\n" with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[ chat_id] and msg != status_reply_dict[chat_id].text: if len(msg) == 0: msg = "Bentar lagi download" try: editMessage(msg, status_reply_dict[chat_id]) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def update_all_messages(): msg = get_readable_message() msg += f"<b>𝐂𝐏𝐔:</b> {psutil.cpu_percent()}%" \ f" <b>𝐃𝐈𝐒𝐊:</b> {psutil.disk_usage('/').percent}%" \ f" <b>𝐑𝐀𝐌:</b> {psutil.virtual_memory().percent}%" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 for download in list(download_dict.values()): speedy = download.speed() if download.status() == MirrorStatus.STATUS_DOWNLOADING: if 'KiB/s' in speedy: dlspeed_bytes += float(speedy.split('K')[0]) * 1024 elif 'MiB/s' in speedy: dlspeed_bytes += float(speedy.split('M')[0]) * 1048576 if download.status() == MirrorStatus.STATUS_UPLOADING: if 'KB/s' in speedy: uldl_bytes += float(speedy.split('K')[0]) * 1024 elif 'MB/s' in speedy: uldl_bytes += float(speedy.split('M')[0]) * 1048576 dlspeed = get_readable_file_size(dlspeed_bytes) ulspeed = get_readable_file_size(uldl_bytes) msg += f"\n<b>𝐃𝐋:</b>{dlspeed}ps 🔻| <b>𝐔𝐋:</b>{ulspeed}ps 🔺\n" with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[ chat_id] and msg != status_reply_dict[chat_id].text: if len(msg) == 0: msg = "🚉𝐒𝐭𝐚𝐫𝐭𝐢𝐧𝐠 𝐃𝐨𝐰𝐧𝐥𝐨𝐚𝐝..." try: editMessage(msg, status_reply_dict[chat_id]) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def update_all_messages(): msg = get_readable_message() with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if msg != status_reply_dict[chat_id].text: try: editMessage(msg, status_reply_dict[chat_id]) except BadRequest as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def update_all_messages(): msg, buttons = get_readable_message() with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[ chat_id] and msg != status_reply_dict[chat_id].text: if buttons == "": editMessage(msg, status_reply_dict[chat_id]) else: editMessage(msg, status_reply_dict[chat_id], buttons) status_reply_dict[chat_id].text = msg
def update_all_messages(): msg = get_readable_message() with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[chat_id] and msg != status_reply_dict[chat_id].text: if len(msg) == 0: msg = "Starting DL" try: editMessage(msg, status_reply_dict[chat_id]) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def update_all_messages(): msg = get_readable_message() msg += f"<b>CPU:</b> {psutil.cpu_percent()}%" \ f" <b>DISK:</b> {psutil.disk_usage('/').percent}%" \ f" <b>RAM:</b> {psutil.virtual_memory().percent}%" with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[chat_id] and msg != status_reply_dict[chat_id].text: try: editMessage(msg, status_reply_dict[chat_id]) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def sendStatusMessage(msg, bot): progress = get_readable_message() with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as _error: LOGGER.error(str(_error)) del status_reply_dict[msg.message.chat.id] message = sendMessage(progress, bot, msg) status_reply_dict[msg.message.chat.id] = message
def mirror_status(update, context): with download_dict_lock: if len(download_dict) == 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 mirror_status(update,context): message = get_readable_message() if len(message) == 0: message = "⛽𝐍𝐨 𝐀𝐜𝐭𝐢𝐯𝐞 𝐃𝐨𝐰𝐧𝐥𝐨𝐚𝐝𝐬 𝐅𝐨𝐮𝐧𝐝" 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 mirror_status(update,context): message = get_readable_message() if len(message) == 0: message = "Không có tác vụ tải xuống nào đang hoạt động!" 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 mirror_status(update,context): message = get_readable_message() if len(message) == 0: message = "Lagi sepi ga ada download an nihh.." 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 mirror_status(client: Client, update: Message): message = get_readable_message() if len(message) == 0: message = "No active downloads" reply_message = sendMessage(message, client, update) threading.Thread(target=auto_delete_message, args=(client, update, reply_message)).start() return index = update.chat.id with status_reply_dict_lock: if index in status_reply_dict.keys(): deleteMessage(status_reply_dict[index]) del status_reply_dict[index] sendStatusMessage(update, client) deleteMessage(update)
def mirror_status(update, context): message = get_readable_message() if len(message) == 0: message = "ЮЉхЮњљ ЮњѓЮњёЮњЋЮњіЮњЌЮњє ЮЉФЮњљЮњўЮњЈЮњЇЮњљЮњѓЮњЁЮњћ ЮЉфЮњќЮњЊЮњЊЮњєЮњЈЮњЋЮњЇЮњџ Ъци" 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 mirror_status(update, context): message = get_readable_message() if len(message) == 0: message = "❌𝙽𝚘 𝚊𝚌𝚝𝚒𝚟𝚎 𝚍𝚘𝚠𝚗𝚕𝚘𝚊𝚍𝚜❌" 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 sendStatusMessage(msg, bot): progress = get_readable_message() with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as e: LOGGER.error(str(e)) del status_reply_dict[msg.message.chat.id] pass if len(progress) == 0: progress = "Starting DL" message = sendMessage(progress, bot, msg) status_reply_dict[msg.message.chat.id] = message
def update_all_messages(): msg = get_readable_message() msg += f"<b>📉 Performance Usage 📈</b>\n\n" \ f"<b>🖥️ CPU : {psutil.cpu_percent()}%</b>\n" \ f"<b>🗃️ DISK : {psutil.disk_usage('/').percent}%</b>\n" \ f"<b>🎛️ RAM : {psutil.virtual_memory().percent}%</b>" with download_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[chat_id] and msg != status_reply_dict[chat_id].text: if len(msg) == 0: msg = "Starting Download 📥" try: editMessage(msg, status_reply_dict[chat_id]) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def sendStatusMessage(msg, bot): if len(Interval) == 0: Interval.append( setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages)) total, used, free = shutil.disk_usage('.') free = get_readable_file_size(free) currentTime = get_readable_time(time.time() - botStartTime) progress, buttons = get_readable_message() if progress is None: progress, buttons = get_readable_message() progress += f"<b>CPU:</b> <code>{psutil.cpu_percent()}%</code>" \ f" <b>RAM:</b> <code>{psutil.virtual_memory().percent}%</code>" \ f" <b>DISK:</b> <code>{psutil.disk_usage('/').percent}%</code>" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 for download in list(download_dict.values()): speedy = download.speed() if download.status() == MirrorStatus.STATUS_DOWNLOADING: if 'K' in speedy: dlspeed_bytes += float(speedy.split('K')[0]) * 1024 elif 'M' in speedy: dlspeed_bytes += float(speedy.split('M')[0]) * 1048576 if download.status() == MirrorStatus.STATUS_UPLOADING: if 'KB/s' in speedy: uldl_bytes += float(speedy.split('K')[0]) * 1024 elif 'MB/s' in speedy: uldl_bytes += float(speedy.split('M')[0]) * 1048576 dlspeed = get_readable_file_size(dlspeed_bytes) ulspeed = get_readable_file_size(uldl_bytes) progress += f"\n<b>FREE:</b> <code>{free}</code> | <b>UPTIME:</b> <code>{currentTime}</code>\n<b>DL:</b> <code>{dlspeed}/s</code> 🔻 | <b>UL:</b> <code>{ulspeed}/s</code> 🔺\n" with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as e: LOGGER.error(str(e)) del status_reply_dict[msg.message.chat.id] pass if buttons == "": message = sendMessage(progress, bot, msg) else: message = sendMarkup(progress, bot, msg, buttons) status_reply_dict[msg.message.chat.id] = message
def sendStatusMessage(msg, bot): progress = get_readable_message() progress += f"<b>CPU:</b> {psutil.cpu_percent()}%" \ f" <b>DISK:</b> {psutil.disk_usage('/').percent}%" \ f" <b>RAM:</b> {psutil.virtual_memory().percent}%" with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as e: LOGGER.error(str(e)) del status_reply_dict[msg.message.chat.id] pass message = sendMessage(progress, bot, msg) status_reply_dict[msg.message.chat.id] = message
def sendStatusMessage(msg, bot): if len(Interval) == 0: Interval.append( setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages)) progress, buttons = get_readable_message() with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as e: LOGGER.error(str(e)) del status_reply_dict[msg.message.chat.id] if buttons == "": message = sendMessage(progress, bot, msg) else: message = sendMarkup(progress, bot, msg, buttons) status_reply_dict[msg.message.chat.id] = message
def update_all_messages(): msg = get_readable_message() msg += f"<b>CPU:</b> {psutil.cpu_percent()}%" \ f" <b>DISK:</b> {psutil.disk_usage('/').percent}%" \ f" <b>RAM:</b> {psutil.virtual_memory().percent}%" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 for download in list(download_dict.values()): speedy = download.speed() if download.status() == MirrorStatus.STATUS_DOWNLOADING: if 'KiB/s' in speedy: dlspeed_bytes += float(speedy.split('K')[0]) * 1024 elif 'MiB/s' in speedy: dlspeed_bytes += float(speedy.split('M')[0]) * 1048576 if download.status() == MirrorStatus.STATUS_UPLOADING: if 'KB/s' in speedy: uldl_bytes += float(speedy.split('K')[0]) * 1024 elif 'MB/s' in speedy: uldl_bytes += float(speedy.split('M')[0]) * 1048576 dlspeed = get_readable_file_size(dlspeed_bytes) ulspeed = get_readable_file_size(uldl_bytes) msg += f"\n<b>DL:</b> {dlspeed}ps 🔻| <b>UL:</b> {ulspeed}ps 🔺\n" with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[ chat_id] and msg != status_reply_dict[chat_id].text: if len(msg) == 0: msg = "Starting DL" try: keyboard = [[ InlineKeyboardButton("🔄 REFRESH 🔄", callback_data=str(ONE)), InlineKeyboardButton("❌ CLOSE ❌", callback_data=str(TWO)), ]] editMessage(msg, status_reply_dict[chat_id], reply_markup=InlineKeyboardMarkup(keyboard)) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def update_all_messages(): currentTime = get_readable_time((time.time() - botStartTime)) total, used, free = shutil.disk_usage('.') total = get_readable_file_size(total) used = get_readable_file_size(used) free = get_readable_file_size(free) msg = get_readable_message() msg += f"𝗖𝗣𝗨 : {psutil.cpu_percent()}%" \ f" 𝗗𝗜𝗦𝗞 : {psutil.disk_usage('/').percent}%" \ f" 𝗥𝗔𝗠 : {psutil.virtual_memory().percent}%" \ f"\n𝗕𝗼𝘁 𝗨𝗽𝘁𝗶𝗺𝗲 : {currentTime} | 𝗙𝗿𝗲𝗲🤯: {free}" with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[ chat_id] and msg != status_reply_dict[chat_id].text: try: editMessage(msg, status_reply_dict[chat_id]) except Exception as e: LOGGER.error(str(e)) status_reply_dict[chat_id].text = msg
def sendStatusMessage(msg, bot): progress = get_readable_message() progress += f"<b>📉 Performance Usage 📈</b>\n\n" \ f"<b>🖥️ CPU : {psutil.cpu_percent()}%</b>\n" \ f"<b>🗃️ DISK : {psutil.disk_usage('/').percent}%</b>\n" \ f"<b>🎛️ RAM : {psutil.virtual_memory().percent}%</b>" with download_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: message = status_reply_dict[msg.message.chat.id] deleteMessage(bot, message) del status_reply_dict[msg.message.chat.id] except Exception as e: LOGGER.error(str(e)) del status_reply_dict[msg.message.chat.id] pass if len(progress) == 0: progress = "Starting Download 📥" message = sendMessage(progress, bot, msg) status_reply_dict[msg.message.chat.id] = message
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)