Skip to content

Commit

Permalink
fix: Token generation issues caused by the command suffix.
Browse files Browse the repository at this point in the history
## 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 <[email protected]>
  • Loading branch information
5hojib and mirrorhunter authored Jan 20, 2025
1 parent d466e26 commit 1b8d3a7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 88 deletions.
3 changes: 3 additions & 0 deletions bot/helper/aeon_utils/shorteners.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions bot/helper/ext_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
2 changes: 1 addition & 1 deletion bot/helper/telegram_helper/bot_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]
Expand Down
82 changes: 2 additions & 80 deletions bot/modules/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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":
Expand All @@ -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())
4 changes: 2 additions & 2 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit 1b8d3a7

Please sign in to comment.