From 1b8d3a75bd4578105f0c85bb37819398a5f876be Mon Sep 17 00:00:00 2001 From: Mehedi Hasan Shojib <yesiamshojib@gmail.com> Date: Mon, 20 Jan 2025 14:25:58 +0600 Subject: [PATCH] fix: Token generation issues caused by the command suffix. ## Summary by Sourcery Bug Fixes: - Fixed token generation issues caused by the command suffix. Enhancements: - Remove the "refresh status" and "overview status" buttons, simplifying the status interface. --------- Co-authored-by: Mirror Hunter <dpmirror@proton.me> --- bot/helper/aeon_utils/shorteners.py | 3 + bot/helper/ext_utils/status_utils.py | 8 +-- bot/helper/telegram_helper/bot_commands.py | 2 +- bot/modules/status.py | 82 +--------------------- update.py | 4 +- 5 files changed, 11 insertions(+), 88 deletions(-) diff --git a/bot/helper/aeon_utils/shorteners.py b/bot/helper/aeon_utils/shorteners.py index f98c3e936..87706f9da 100644 --- a/bot/helper/aeon_utils/shorteners.py +++ b/bot/helper/aeon_utils/shorteners.py @@ -9,6 +9,9 @@ async def short(long_url): + if not shorteners_list: + return long_url + async with ClientSession() as session: for _attempt in range(4): shortener_info = choice(shorteners_list) diff --git a/bot/helper/ext_utils/status_utils.py b/bot/helper/ext_utils/status_utils.py index 3d939b16c..29fa50df9 100644 --- a/bot/helper/ext_utils/status_utils.py +++ b/bot/helper/ext_utils/status_utils.py @@ -243,10 +243,9 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step= if status == "All": return None, None msg = f"No Active {status} Tasks!\n\n" - buttons = ButtonMaker() - if not is_user: - buttons.data_button("📜", f"status {sid} ov", position="header") + buttons = None if len(tasks) > STATUS_LIMIT: + buttons = ButtonMaker() msg += f"<b>Page:</b> {page_no}/{pages} | <b>Tasks:</b> {tasks_no} | <b>Step:</b> {page_step}\n" buttons.data_button("<<", f"status {sid} pre", position="header") buttons.data_button(">>", f"status {sid} nex", position="header") @@ -257,8 +256,7 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step= for label, status_value in list(STATUSES.items()): if status_value != status: buttons.data_button(label, f"status {sid} st {status_value}") - buttons.data_button("♻️", f"status {sid} ref", position="header") - button = buttons.build_menu(8) + button = buttons.build_menu(8) if buttons else None msg += f"<b>CPU:</b> {cpu_percent()}% | <b>FREE:</b> {get_readable_file_size(disk_usage(Config.DOWNLOAD_DIR).free)}" msg += f"\n<b>RAM:</b> {virtual_memory().percent}% | <b>UPTIME:</b> {get_readable_time(time() - bot_start_time)}" return msg, button diff --git a/bot/helper/telegram_helper/bot_commands.py b/bot/helper/telegram_helper/bot_commands.py index 818d3dbac..fcefbbe03 100644 --- a/bot/helper/telegram_helper/bot_commands.py +++ b/bot/helper/telegram_helper/bot_commands.py @@ -5,7 +5,7 @@ class BotCommands: - StartCommand = f"start{i}" + StartCommand = "start" MirrorCommand = [f"mirror{i}", f"m{i}"] YtdlCommand = [f"ytdl{i}", f"y{i}"] LeechCommand = [f"leech{i}", f"l{i}"] diff --git a/bot/modules/status.py b/bot/modules/status.py index 6c5c5a890..fec35d6d0 100644 --- a/bot/modules/status.py +++ b/bot/modules/status.py @@ -4,19 +4,15 @@ from bot import bot_start_time, intervals, status_dict, task_dict, task_dict_lock from bot.core.config_manager import Config -from bot.helper.ext_utils.bot_utils import new_task, sync_to_async +from bot.helper.ext_utils.bot_utils import new_task from bot.helper.ext_utils.status_utils import ( - MirrorStatus, get_readable_file_size, get_readable_time, - speed_string_to_bytes, ) from bot.helper.telegram_helper.bot_commands import BotCommands -from bot.helper.telegram_helper.button_build import ButtonMaker from bot.helper.telegram_helper.message_utils import ( auto_delete_message, delete_message, - edit_message, send_message, send_status_message, update_status_message, @@ -55,10 +51,7 @@ async def task_status(_, message): async def status_pages(_, query): data = query.data.split() key = int(data[1]) - if data[2] == "ref": - await query.answer() - await update_status_message(key, force=True) - elif data[2] in ["nex", "pre"]: + if data[2] in ["nex", "pre"]: await query.answer() async with task_dict_lock: if data[2] == "nex": @@ -74,74 +67,3 @@ async def status_pages(_, query): async with task_dict_lock: status_dict[key]["status"] = data[3] await update_status_message(key, force=True) - elif data[2] == "ov": - message = query.message - tasks = { - "Download": 0, - "Upload": 0, - "Seed": 0, - "Archive": 0, - "Extract": 0, - "Split": 0, - "QueueDl": 0, - "QueueUp": 0, - "Clone": 0, - "CheckUp": 0, - "Pause": 0, - "SamVid": 0, - "ConvertMedia": 0, - "FFmpeg": 0, - } - dl_speed = 0 - up_speed = 0 - seed_speed = 0 - async with task_dict_lock: - for download in task_dict.values(): - match await sync_to_async(download.status): - case MirrorStatus.STATUS_DOWNLOAD: - tasks["Download"] += 1 - dl_speed += speed_string_to_bytes(download.speed()) - case MirrorStatus.STATUS_UPLOAD: - tasks["Upload"] += 1 - up_speed += speed_string_to_bytes(download.speed()) - case MirrorStatus.STATUS_SEED: - tasks["Seed"] += 1 - seed_speed += speed_string_to_bytes(download.seed_speed()) - case MirrorStatus.STATUS_ARCHIVE: - tasks["Archive"] += 1 - case MirrorStatus.STATUS_EXTRACT: - tasks["Extract"] += 1 - case MirrorStatus.STATUS_SPLIT: - tasks["Split"] += 1 - case MirrorStatus.STATUS_QUEUEDL: - tasks["QueueDl"] += 1 - case MirrorStatus.STATUS_QUEUEUP: - tasks["QueueUp"] += 1 - case MirrorStatus.STATUS_CLONE: - tasks["Clone"] += 1 - case MirrorStatus.STATUS_CHECK: - tasks["CheckUp"] += 1 - case MirrorStatus.STATUS_PAUSED: - tasks["Pause"] += 1 - case MirrorStatus.STATUS_SAMVID: - tasks["SamVid"] += 1 - case MirrorStatus.STATUS_CONVERT: - tasks["ConvertMedia"] += 1 - case MirrorStatus.STATUS_FFMPEG: - tasks["FFMPEG"] += 1 - case _: - tasks["Download"] += 1 - dl_speed += speed_string_to_bytes(download.speed()) - - msg = f"""<b>DL:</b> {tasks["Download"]} | <b>UP:</b> {tasks["Upload"]} | <b>SD:</b> {tasks["Seed"]} | <b>AR:</b> {tasks["Archive"]} -<b>EX:</b> {tasks["Extract"]} | <b>SP:</b> {tasks["Split"]} | <b>QD:</b> {tasks["QueueDl"]} | <b>QU:</b> {tasks["QueueUp"]} -<b>CL:</b> {tasks["Clone"]} | <b>CK:</b> {tasks["CheckUp"]} | <b>PA:</b> {tasks["Pause"]} | <b>SV:</b> {tasks["SamVid"]} -<b>CM:</b> {tasks["ConvertMedia"]} | <b>FF:</b> {tasks["FFmpeg"]} - -<b>ODLS:</b> {get_readable_file_size(dl_speed)}/s -<b>OULS:</b> {get_readable_file_size(up_speed)}/s -<b>OSDS:</b> {get_readable_file_size(seed_speed)}/s -""" - button = ButtonMaker() - button.data_button("Back", f"status {data[1]} ref") - await edit_message(message, msg, button.build_menu()) diff --git a/update.py b/update.py index af60df08b..d229d7fad 100644 --- a/update.py +++ b/update.py @@ -111,9 +111,9 @@ def format(self, record: LogRecord) -> str: UPSTREAM_REPO = config_file.get( "UPSTREAM_REPO", "https://github.com/AeonOrg/Aeon-MLTB", -).strip() +) -UPSTREAM_BRANCH = config_file.get("UPSTREAM_BRANCH", "").strip() or "main" +UPSTREAM_BRANCH = config_file.get("UPSTREAM_BRANCH", "") or "main" if UPSTREAM_REPO: if path.exists(".git"):