diff --git a/bot/__init__.py b/bot/__init__.py
index cdf75eb47..480f11f44 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -14,7 +14,7 @@
from time import time
from apscheduler.schedulers.asyncio import AsyncIOScheduler
-from aria2p import API as ariaAPI
+from aria2p import API as ariaAPI # noqa: N811
from aria2p import Client as ariaClient
from qbittorrentapi import Client as QbClient
from tzlocal import get_localzone
diff --git a/bot/core/config_manager.py b/bot/core/config_manager.py
index 05fc35d64..2262ff4ae 100644
--- a/bot/core/config_manager.py
+++ b/bot/core/config_manager.py
@@ -1,5 +1,5 @@
from importlib import import_module
-
+from typing import ClassVar
class Config:
AS_DOCUMENT = False
@@ -12,10 +12,9 @@ class Config:
DEFAULT_UPLOAD = "rc"
DOWNLOAD_DIR = "/usr/src/app/downloads/"
DELETE_LINKS = False
- EQUAL_SPLITS = False
EXTENSION_FILTER = ""
FSUB_IDS = ""
- FFMPEG_CMDS = []
+ FFMPEG_CMDS: ClassVar[list[str]] = []
FILELION_API = ""
GDRIVE_ID = ""
INCOMPLETE_TASK_NOTIFIER = False
@@ -45,7 +44,7 @@ class Config:
RSS_DELAY = 600
SEARCH_API_LINK = ""
SEARCH_LIMIT = 0
- SEARCH_PLUGINS = []
+ SEARCH_PLUGINS: ClassVar[list[str]] = []
STATUS_LIMIT = 10
STATUS_UPDATE_INTERVAL = 15
STOP_DUPLICATE = False
diff --git a/bot/core/startup.py b/bot/core/startup.py
index 2067d9574..3310aac3f 100644
--- a/bot/core/startup.py
+++ b/bot/core/startup.py
@@ -214,8 +214,8 @@ async def load_configurations():
if not await aiopath.exists(".netrc"):
async with aiopen(".netrc", "w"):
pass
- subprocess.run(["chmod", "600", ".netrc"], check=False)
- subprocess.run(["cp", ".netrc", "/root/.netrc"], check=False)
+ await (await create_subprocess_shell("chmod 600 .netrc")).wait()
+ await (await create_subprocess_shell("cp .netrc /root/.netrc")).wait()
PORT = environ.get("PORT") or environ.get("BASE_URL_PORT", 80)
await create_subprocess_shell(
diff --git a/bot/helper/common.py b/bot/helper/common.py
index a53dbce40..842686d65 100644
--- a/bot/helper/common.py
+++ b/bot/helper/common.py
@@ -87,7 +87,6 @@ def __init__(self):
self.is_qbit = False
self.is_clone = False
self.is_ytdlp = False
- self.equal_splits = False
self.user_transmission = False
self.mixed_leech = False
self.extract = False
@@ -367,7 +366,7 @@ async def before_start(self):
ChatAction.TYPING,
)
except Exception:
- raise ValueError("Start the bot and try again!")
+ raise ValueError("Start the bot and try again!") from None
elif (
self.user_transmission or self.mixed_leech
) and not self.is_super_chat:
@@ -383,9 +382,6 @@ async def before_start(self):
or self.user_dict.get("split_size")
or Config.LEECH_SPLIT_SIZE
)
- self.equal_splits = self.user_dict.get("equal_splits") or (
- Config.EQUAL_SPLITS and "equal_splits" not in self.user_dict
- )
self.max_split_size = (
TgClient.MAX_SPLIT_SIZE if self.user_transmission else 2097152000
)
@@ -735,11 +731,7 @@ async def proceed_compress(self, dl_path, gid, o_files, ft_delete):
async with task_dict_lock:
task_dict[self.mid] = SevenZStatus(self, gid, "Zip")
size = await get_path_size(dl_path)
- if self.equal_splits:
- parts = -(-size // self.split_size)
- split_size = (size // parts) + (size % parts)
- else:
- split_size = self.split_size
+ split_size = self.split_size
cmd = [
"7z",
f"-v{split_size}b",
@@ -1198,8 +1190,11 @@ async def proceed_ffmpeg(self, dl_path, gid):
res = await run_ffmpeg_cmd(self, cmd, file_path)
if res and delete_files:
await remove(file_path)
- if "ffmpeg." in res:
- newres = res.replace("ffmpeg.", "")
+ directory = ospath.dirname(res)
+ file_name = ospath.basename(res)
+ if file_name.startswith("ffmpeg."):
+ newname = file_name.replace("ffmpeg.", "")
+ newres = ospath.join(directory, newname)
await move(res, newres)
else:
for dirpath, _, files in await sync_to_async(
@@ -1235,8 +1230,11 @@ async def proceed_ffmpeg(self, dl_path, gid):
res = await run_ffmpeg_cmd(self, cmd, f_path)
if res and delete_files:
await remove(f_path)
- if "ffmpeg." in res:
- newres = res.replace("ffmpeg.", "")
+ directory = ospath.dirname(res)
+ file_name = ospath.basename(res)
+ if file_name.startswith("ffmpeg."):
+ newname = file_name.replace("ffmpeg.", "")
+ newres = ospath.join(directory, newname)
await move(res, newres)
if checked:
cpu_eater_lock.release()
diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py
index 0f1ffd232..c8b83faf2 100644
--- a/bot/helper/ext_utils/bot_utils.py
+++ b/bot/helper/ext_utils/bot_utils.py
@@ -124,14 +124,6 @@ def process_argument_with_values(start_index):
values.append(items[j])
return values
- def process_nested_list(start_index):
- values = []
- end_index = start_index + 1
- while end_index < total and items[end_index] != "]":
- values.append(items[end_index])
- end_index += 1
- return values, end_index - start_index
-
while i < total:
part = items[i]
if part in arg_base:
@@ -149,10 +141,17 @@ def process_nested_list(start_index):
"-med",
]:
arg_base[part] = True
- elif part == "-ff" and i + 1 < total and items[i + 1].startswith("["):
- nested_values, skip_count = process_nested_list(i + 1)
- arg_base[part] = nested_values
- i += skip_count
+ elif part == "-ff":
+ i += 1
+ if i < total:
+ values = []
+ while i < total:
+ values.append(items[i])
+ if items[i].endswith("]"):
+ break
+ else:
+ i += 1
+ arg_base[part] = " ".join(values)
else:
sub_list = process_argument_with_values(i)
if sub_list:
diff --git a/bot/helper/ext_utils/media_utils.py b/bot/helper/ext_utils/media_utils.py
index 94f0ae59e..f13dbd8b8 100644
--- a/bot/helper/ext_utils/media_utils.py
+++ b/bot/helper/ext_utils/media_utils.py
@@ -432,15 +432,12 @@ async def split_file(
listener,
start_time=0,
i=1,
- inLoop=False,
multi_streams=True,
):
if listener.seed and not listener.new_dir:
dirpath = f"{dirpath}/splited_files"
await makedirs(dirpath, exist_ok=True)
parts = -(-size // listener.split_size)
- if listener.equal_splits and not inLoop:
- split_size = (size // parts) + (size % parts)
if not listener.as_doc and (await get_document_type(path))[0]:
if multi_streams:
multi_streams = await is_multi_streams(path)
@@ -506,7 +503,6 @@ async def split_file(
listener,
start_time,
i,
- True,
False,
)
LOGGER.warning(
@@ -527,7 +523,6 @@ async def split_file(
listener,
start_time,
i,
- True,
multi_streams,
)
lpd = (await get_media_info(out_path))[0]
diff --git a/bot/helper/mirror_leech_utils/rclone_utils/serve.py b/bot/helper/mirror_leech_utils/rclone_utils/serve.py
index d44a3e5d7..4197549ed 100644
--- a/bot/helper/mirror_leech_utils/rclone_utils/serve.py
+++ b/bot/helper/mirror_leech_utils/rclone_utils/serve.py
@@ -27,7 +27,7 @@ async def rclone_serve_booter():
config.add_section("combine")
config.set("combine", "type", "combine")
config.set("combine", "upstreams", upstreams)
- with open("rclone.conf", "w") as f:
+ async with aiopen("rclone.conf", "w") as f:
config.write(f, space_around_delimiters=False)
if RcloneServe:
try:
diff --git a/bot/helper/telegram_helper/message_utils.py b/bot/helper/telegram_helper/message_utils.py
index 14e559d7f..2a3ca0739 100644
--- a/bot/helper/telegram_helper/message_utils.py
+++ b/bot/helper/telegram_helper/message_utils.py
@@ -4,7 +4,7 @@
from cachetools import TTLCache
from pyrogram import Client, enums
-from pyrogram.errors import FloodWait, MessageEmpty, MessageNotModified
+from pyrogram.errors import FloodWait, MessageEmpty, MessageNotModified, FloodPremiumWait
from pyrogram.types import InputMediaPhoto
from bot import (
@@ -279,7 +279,7 @@ async def get_tg_link_message(link, user_id=""):
raise TgLinkException("Private: Please report!")
-async def check_permission(client, chat, uploader_id, up_dest):
+async def check_permission(_, chat, uploader_id, __):
member = await chat.get_member(uploader_id)
if (
not member.privileges.can_manage_chat
diff --git a/bot/modules/clone.py b/bot/modules/clone.py
index fc31b4ae6..eca90e990 100644
--- a/bot/modules/clone.py
+++ b/bot/modules/clone.py
@@ -34,6 +34,8 @@
from bot.helper.telegram_helper.message_utils import (
delete_message,
send_message,
+ delete_links,
+ five_minute_del,
send_status_message,
)
diff --git a/bot/modules/mirror_leech.py b/bot/modules/mirror_leech.py
index 36d6290e9..8e60e0c4c 100644
--- a/bot/modules/mirror_leech.py
+++ b/bot/modules/mirror_leech.py
@@ -1,3 +1,4 @@
+# ruff: noqa: RUF006
from asyncio import create_task
from base64 import b64encode
from re import match as re_match
diff --git a/bot/modules/users_settings.py b/bot/modules/users_settings.py
index 424c93c0b..3611efdba 100644
--- a/bot/modules/users_settings.py
+++ b/bot/modules/users_settings.py
@@ -54,13 +54,6 @@ async def get_user_settings(from_user):
else:
split_size = Config.LEECH_SPLIT_SIZE
- if user_dict.get("equal_splits", False) or (
- "equal_splits" not in user_dict and Config.EQUAL_SPLITS
- ):
- equal_splits = "Enabled"
- else:
- equal_splits = "Disabled"
-
if user_dict.get("media_group", False) or (
"media_group" not in user_dict and Config.MEDIA_GROUP
):
@@ -182,7 +175,6 @@ async def get_user_settings(from_user):
Leech Type is {ltype}
Custom Thumbnail {thumbmsg}
Leech Split Size is {split_size}
-Equal Splits is {equal_splits}
Media Group is {media_group}
Leech Prefix is {escape(lprefix)}
Leech Destination is {leech_dest}
@@ -366,7 +358,6 @@ async def edit_user_settings(client, query):
await query.answer("Not Yours!", show_alert=True)
elif data[2] in [
"as_doc",
- "equal_splits",
"media_group",
"user_transmission",
"stop_duplicate",
@@ -444,20 +435,6 @@ async def edit_user_settings(client, query):
else:
ltype = "MEDIA"
buttons.data_button("Send As Document", f"userset {user_id} as_doc true")
- if user_dict.get("equal_splits", False) or (
- "equal_splits" not in user_dict and Config.EQUAL_SPLITS
- ):
- buttons.data_button(
- "Disable Equal Splits",
- f"userset {user_id} equal_splits false",
- )
- equal_splits = "Enabled"
- else:
- buttons.data_button(
- "Enable Equal Splits",
- f"userset {user_id} equal_splits true",
- )
- equal_splits = "Disabled"
if user_dict.get("media_group", False) or (
"media_group" not in user_dict and Config.MEDIA_GROUP
):
@@ -520,7 +497,6 @@ async def edit_user_settings(client, query):
Leech Type is {ltype}
Custom Thumbnail {thumbmsg}
Leech Split Size is {split_size}
-Equal Splits is {equal_splits}
Media Group is {media_group}
Leech Prefix is {escape(lprefix)}
Leech Destination is {leech_dest}
diff --git a/config_sample.py b/config_sample.py
index 60c1206df..2f806dbd0 100644
--- a/config_sample.py
+++ b/config_sample.py
@@ -53,7 +53,6 @@
# Leech
LEECH_SPLIT_SIZE = 0
AS_DOCUMENT = False
-EQUAL_SPLITS = False
MEDIA_GROUP = False
USER_TRANSMISSION = False
MIXED_LEECH = False