Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
N/A

Signed-off-by: Dawn India <[email protected]>
  • Loading branch information
Dawn-India committed Oct 11, 2024
1 parent c13d146 commit 16bea42
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
17 changes: 8 additions & 9 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@
from ..telegram_helper.bot_commands import BotCommands

COMMAND_USAGE = {}
max_workers = min(
10000,
(
cpu_count()
or 0
) + 4
)
THREAD_POOL = ThreadPoolExecutor(max_workers=max_workers)
THREAD_POOL = ThreadPoolExecutor(max_workers=4000)

class SetInterval:
def __init__(self, interval, action, *args, **kwargs):
def __init__(
self,
interval,
action,
*args,
**kwargs
):
self.interval = interval
self.action = action
self.task = bot_loop.create_task(
Expand Down
6 changes: 3 additions & 3 deletions bot/helper/listeners/qbit_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def _stop_duplicate(tor):
button
) = await stop_duplicate_check(task.listener) # type: ignore
if msg:
await _on_download_error(
_on_download_error(
msg,
tor,
button
Expand All @@ -120,7 +120,7 @@ async def _size_checked(tor):
LOGGER.info(
f"qBit Limit Exceeded: {task.listener.name} | {get_readable_file_size(task.listener.size)}" # type: ignore
)
qmsg = await _on_download_error(
qmsg = _on_download_error(
limit_exceeded,
tor
)
Expand Down Expand Up @@ -157,7 +157,7 @@ async def _avg_speed_check(tor):
LOGGER.info(
f"Task is slower than minimum download speed: {task.listener.name} | {get_readable_file_size(dl_speed)}ps"
)
qmsg = await _on_download_error(
qmsg = _on_download_error(
min_speed,
tor
)
Expand Down
8 changes: 4 additions & 4 deletions bot/helper/listeners/task_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,14 @@ async def on_download_complete(self):
self,
tg,
gid,
"up",
"up"
)
await gather(
update_status_message(self.message.chat.id), # type: ignore
tg.upload(
unwanted_files,
files_to_delete
),
)
)
elif is_gdrive_id(self.up_dest): # type: ignore
LOGGER.info(f"Gdrive Upload Name: {self.name}")
Expand All @@ -391,15 +391,15 @@ async def on_download_complete(self):
self,
drive,
gid,
"up",
"up"
)
await gather(
update_status_message(self.message.chat.id), # type: ignore
sync_to_async(
drive.upload,
unwanted_files,
files_to_delete
),
)
)
else:
LOGGER.info(f"Rclone Upload Name: {self.name}")
Expand Down
1 change: 0 additions & 1 deletion bot/helper/task_utils/status_utils/meta_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
)
from ...ext_utils.status_utils import (
get_readable_file_size,
get_readable_time,
MirrorStatus
)
from subprocess import run as frun
Expand Down
1 change: 0 additions & 1 deletion bot/helper/task_utils/status_utils/rclone_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from subprocess import run as rrun



class RcloneStatus:
def __init__(
self,
Expand Down
18 changes: 10 additions & 8 deletions bot/helper/telegram_helper/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ async def update_status_message(sid, force=False):
status = status_dict[sid]["status"]
is_user = status_dict[sid]["is_user"]
page_step = status_dict[sid]["page_step"]
text, buttons = await get_readable_message(
(
text,
buttons
) = await get_readable_message(
sid,
is_user,
page_no,
Expand All @@ -303,9 +306,7 @@ async def update_status_message(sid, force=False):
obj.cancel()
del intervals["status"][sid]
else:
LOGGER.error(
f"Status with id: {sid} haven't been updated. Error: {message}"
)
LOGGER.error(f"Status with id: {sid} haven't been updated. Error: {message}")
return
status_dict[sid]["message"].text = text
status_dict[sid]["time"] = time()
Expand All @@ -321,7 +322,10 @@ async def send_status_message(msg, user_id=0):
page_no = status_dict[sid]["page_no"]
status = status_dict[sid]["status"]
page_step = status_dict[sid]["page_step"]
text, buttons = await get_readable_message(
(
text,
buttons
) = await get_readable_message(
sid,
is_user,
page_no,
Expand All @@ -343,9 +347,7 @@ async def send_status_message(msg, user_id=0):
block=False
)
if isinstance(message, str):
LOGGER.error(
f"Status with id: {sid} haven't been sent. Error: {message}"
)
LOGGER.error(f"Status with id: {sid} haven't been sent. Error: {message}")
return
message.text = text
status_dict[sid].update({
Expand Down

0 comments on commit 16bea42

Please sign in to comment.