Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Sep 17, 2024
1 parent 29e8fb7 commit 75cb5ca
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Thumbnails/*
rclone/*
tokens/*
list_drives.txt
shorteners.txt
cookies.txt
downloads
bot.session*
Expand Down
11 changes: 10 additions & 1 deletion bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

install()
setdefaulttimeout(600)
botStartTime = time()
bot_start_time = time()
bot_loop = get_event_loop()

getLogger("pyrogram").setLevel(ERROR)
Expand Down Expand Up @@ -84,6 +84,7 @@ def format(self, record):
"aspx",
]
user_data = {}
shorteners_list = []
aria2_options, qbit_options = {}, {}
queued_dl, queued_up = {}, {}
non_queued_dl, non_queued_up = set(), set()
Expand Down Expand Up @@ -148,6 +149,14 @@ def initialize_database():
with open(".netrc", "w"):
pass

if ospath.exists("shorteners.txt"):
with open("shorteners.txt", "r+") as f:
lines = f.readlines()
for line in lines:
temp = line.strip().split()
if len(temp) == 2:
shorteners_list.append({"domain": temp[0], "api_key": temp[1]})


def init_user_client():
user_session = environ.get("USER_SESSION_STRING", "")
Expand Down
4 changes: 2 additions & 2 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
user_data,
config_dict,
bot_username,
botStartTime,
bot_start_time,
)

from .modules import ( # noqa: F401
Expand Down Expand Up @@ -88,7 +88,7 @@ async def stats(_, message):
memory = virtual_memory()
stats = (
f"<b>Commit Date:</b> {last_commit}\n\n"
f"<b>Bot Uptime:</b> {get_readable_time(time() - botStartTime)}\n"
f"<b>Bot Uptime:</b> {get_readable_time(time() - bot_start_time)}\n"
f"<b>OS Uptime:</b> {get_readable_time(time() - boot_time())}\n\n"
f"<b>Total Disk Space:</b> {get_readable_file_size(total)}\n"
f"<b>Used:</b> {get_readable_file_size(used)} | <b>Free:</b> {get_readable_file_size(free)}\n\n"
Expand Down
9 changes: 1 addition & 8 deletions bot/helper/aeon_utils/shorteners.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
from random import choice
from asyncio import sleep
from urllib.parse import quote

from bot import shorteners_list
from aiohttp import ClientSession
from pyshorteners import Shortener

shorteners_list = [
{
"domain": "modijiurl.com",
"api_key": "cd5b3b10ed0e7c30e795e7ab3c8778f799cafb5b",
}
]


async def short(long_url):
async with ClientSession() as session:
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/ext_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
DOWNLOAD_DIR,
task_dict,
status_dict,
botStartTime,
bot_start_time,
task_dict_lock,
)
from bot.helper.ext_utils.bot_utils import sync_to_async
Expand Down Expand Up @@ -225,5 +225,5 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step=
buttons.callback("Next", f"status {sid} nex", position="header")
button = buttons.menu(8)
msg += f"<b>\nFree disk:</b> {get_readable_file_size(disk_usage(DOWNLOAD_DIR).free)}"
msg += f"\n<b>Bot uptime:</b> {get_readable_time(time() - botStartTime)}"
msg += f"\n<b>Bot uptime:</b> {get_readable_time(time() - bot_start_time)}"
return msg, button
4 changes: 2 additions & 2 deletions bot/modules/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
bot,
task_dict,
status_dict,
botStartTime,
bot_start_time,
task_dict_lock,
)
from bot.helper.ext_utils.bot_utils import new_task
Expand All @@ -34,7 +34,7 @@ async def mirror_status(_, message):
async with task_dict_lock:
count = len(task_dict)
if count == 0:
currentTime = get_readable_time(time() - botStartTime)
currentTime = get_readable_time(time() - bot_start_time)
free = get_readable_file_size(disk_usage(DOWNLOAD_DIR).free)
msg = "No downloads are currently in progress.\n"
msg += f"\n<b>Bot uptime</b>: {currentTime}"
Expand Down

0 comments on commit 75cb5ca

Please sign in to comment.