From 00d05446ca62a7adaaebe28e62dcddec1ca64065 Mon Sep 17 00:00:00 2001 From: 5hojib Date: Sun, 5 Jan 2025 18:32:40 +0000 Subject: [PATCH] Auto-format code [skip actions] --- bot/helper/listeners/qbit_listener.py | 4 +++- bot/helper/mirror_leech_utils/gdrive_utils/upload.py | 2 +- bot/modules/mediainfo.py | 6 +++++- bot/modules/mirror_leech.py | 6 +++++- bot/modules/restart.py | 12 +++++++----- bot/modules/stats.py | 2 +- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/bot/helper/listeners/qbit_listener.py b/bot/helper/listeners/qbit_listener.py index 7e0108954..adbb06c6a 100644 --- a/bot/helper/listeners/qbit_listener.py +++ b/bot/helper/listeners/qbit_listener.py @@ -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: diff --git a/bot/helper/mirror_leech_utils/gdrive_utils/upload.py b/bot/helper/mirror_leech_utils/gdrive_utils/upload.py index 8b0bacd6a..78fa6283d 100644 --- a/bot/helper/mirror_leech_utils/gdrive_utils/upload.py +++ b/bot/helper/mirror_leech_utils/gdrive_utils/upload.py @@ -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...") diff --git a/bot/modules/mediainfo.py b/bot/modules/mediainfo.py index 3146c051d..32e6cb4ba 100644 --- a/bot/modules/mediainfo.py +++ b/bot/modules/mediainfo.py @@ -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): diff --git a/bot/modules/mirror_leech.py b/bot/modules/mirror_leech.py index a9684ab8f..58c25c55f 100644 --- a/bot/modules/mirror_leech.py +++ b/bot/modules/mirror_leech.py @@ -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: diff --git a/bot/modules/restart.py b/bot/modules/restart.py index 0cede6d06..144fb9538 100644 --- a/bot/modules/restart.py +++ b/bot/modules/restart.py @@ -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): diff --git a/bot/modules/stats.py b/bot/modules/stats.py index cb9b0f522..250e75a0a 100644 --- a/bot/modules/stats.py +++ b/bot/modules/stats.py @@ -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 From %cr'",