v3.8 (#15)
- Added overall DL, UL speed in /status - Added CPU, DISK, RAM usage in /status - Show peers and seeders
This commit is contained in:
parent
f78358537b
commit
0fd996955c
|
|
@ -93,17 +93,23 @@ def get_readable_message():
|
|||
with download_dict_lock:
|
||||
msg = ""
|
||||
for download in list(download_dict.values()):
|
||||
msg += f"<i>{download.name()}</i> - "
|
||||
msg += download.status()
|
||||
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> of " \
|
||||
f"{download.size()}" \
|
||||
f" at {download.speed()}, ETA: {download.eta()} "
|
||||
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()}"
|
||||
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()}, \n<b>ETA:</b> {download.eta()} "
|
||||
# if hasattr(download, 'is_torrent'):
|
||||
try:
|
||||
msg += f"\n<b>Info :- Seeders:</b> {download.aria_download().num_seeders}" \
|
||||
f" & <b>Peers :</b> {download.aria_download().connections}"
|
||||
except:
|
||||
pass
|
||||
if download.status() == MirrorStatus.STATUS_DOWNLOADING:
|
||||
if hasattr(download, 'is_torrent'):
|
||||
msg += f"| P: {download.aria_download().connections} " \
|
||||
f"| S: {download.aria_download().num_seeders}"
|
||||
msg += f"\nGID: <code>{download.gid()}</code>"
|
||||
msg += f"\n<b>GID</b>: <code>{download.gid()}</code>"
|
||||
msg += "\n\n"
|
||||
return msg
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
from telegram import InlineKeyboardMarkup
|
||||
from telegram.message import Message
|
||||
from telegram.update import Update
|
||||
import psutil
|
||||
import time
|
||||
from bot import AUTO_DELETE_MESSAGE_DURATION, LOGGER, bot, \
|
||||
status_reply_dict, status_reply_dict_lock
|
||||
from bot.helper.ext_utils.bot_utils import get_readable_message
|
||||
status_reply_dict, status_reply_dict_lock, download_dict, download_dict_lock
|
||||
from bot.helper.ext_utils.bot_utils import get_readable_message, get_readable_file_size, MirrorStatus
|
||||
from telegram.error import TimedOut, BadRequest
|
||||
from bot import bot
|
||||
|
||||
|
||||
def sendMessage(text: str, bot, update: Update):
|
||||
|
|
@ -68,6 +68,27 @@ def delete_all_messages():
|
|||
|
||||
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:
|
||||
|
|
@ -83,6 +104,27 @@ def update_all_messages():
|
|||
|
||||
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 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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue