Skip to content

Commit

Permalink
Auto-format code [skip actions]
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Jan 5, 2025
1 parent f4374b1 commit 00d0544
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
4 changes: 3 additions & 1 deletion bot/helper/listeners/qbit_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ async def _on_seed_finish(tor):

@new_task
async def _stop_duplicate(tor):
if (task := await get_task_by_gid(tor.hash[:12])) and task.listener.stop_duplicate:
if (
task := await get_task_by_gid(tor.hash[:12])
) and task.listener.stop_duplicate:
task.listener.name = tor.content_path.rsplit("/", 1)[-1].rsplit(".!qB", 1)[0]
msg, button = await stop_duplicate_check(task.listener)
if msg:
Expand Down
2 changes: 1 addition & 1 deletion bot/helper/mirror_leech_utils/gdrive_utils/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def upload(self, unwanted_files, ft_delete):
self._is_errored = True
finally:
self._updater.cancel()

if self.listener.is_cancelled and not self._is_errored:
if mime_type == "Folder" and dir_id:
LOGGER.info("Deleting uploaded data from Drive...")
Expand Down
6 changes: 5 additions & 1 deletion bot/modules/mediainfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ async def gen_mediainfo(message, link=None, media=None, msg=None):
headers = {
"user-agent": "Mozilla/5.0 (Linux; Android 12; 2201116PI) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Mobile Safari/537.36",
}
async with aiohttp.ClientSession() as session, session.get(link, headers=headers) as response, aiopen(des_path, "wb") as f:
async with (
aiohttp.ClientSession() as session,
session.get(link, headers=headers) as response,
aiopen(des_path, "wb") as f,
):
file_size = int(response.headers.get("Content-Length", 0))
async with aiopen(des_path, "wb") as f:
async for chunk in response.content.iter_chunked(10000000):
Expand Down
6 changes: 5 additions & 1 deletion bot/modules/mirror_leech.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ async def new_event(self):

path = f"{Config.DOWNLOAD_DIR}{self.mid}{self.folder_name}"

if not self.link and (reply_to := self.message.reply_to_message) and reply_to.text:
if (
not self.link
and (reply_to := self.message.reply_to_message)
and reply_to.text
):
self.link = reply_to.text.split("\n", 1)[0].strip()
if is_telegram_link(self.link):
try:
Expand Down
12 changes: 7 additions & 5 deletions bot/modules/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,18 @@ async def send_incomplete_task_message(cid, msg_id, msg):

async def restart_notification():
if await aiopath.isfile(".restartmsg"):
with aiopen(".restartmsg", "r") as f:
with aiopen(".restartmsg") as f:
chat_id, msg_id = map(int, await f.read().splitlines())
else:
chat_id, msg_id = 0, 0

if Config.INCOMPLETE_TASK_NOTIFIER and Config.DATABASE_URL and (notifier_dict := await database.get_incomplete_tasks()):
if (
Config.INCOMPLETE_TASK_NOTIFIER
and Config.DATABASE_URL
and (notifier_dict := await database.get_incomplete_tasks())
):
for cid, data in notifier_dict.items():
msg = (
"Restarted Successfully!" if cid == chat_id else "Bot Restarted!"
)
msg = "Restarted Successfully!" if cid == chat_id else "Bot Restarted!"
for tag, links in data.items():
msg += f"\n\n{tag}: "
for index, link in enumerate(links, start=1):
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def get_packages_version():
get_version_async(command, regex) for command, regex in commands.values()
]
versions = await gather(*tasks)
commands.update({tool: version for tool, version in zip(commands.keys(), versions, strict=False)})
commands.update(dict(zip(commands.keys(), versions, strict=False)))
if await aiopath.exists(".git"):
last_commit = await cmd_exec(
"git log -1 --date=short --pretty=format:'%cd <b>From</b> %cr'",
Expand Down

0 comments on commit 00d0544

Please sign in to comment.