diff --git a/README.md b/README.md
index bf7831b91a3..6bfb7fbb764 100644
--- a/README.md
+++ b/README.md
@@ -257,18 +257,17 @@ quotes, even if it's `Int`, `Bool` or `List`.
- `USE_SERVICE_ACCOUNTS`: Whether to use Service Accounts or not, with google-api-python-client. For this to work
see [Using Service Accounts](https://github.com/anasty17/mirror-leech-telegram-bot#generate-service-accounts-what-is-service-account)
section below. Default is `False`. `Bool`
-- `NAME_SUBSTITUTE`: Add word/letter/sentense/pattern to remove or replace with other words with sensitive case or without. **Notes**:
+- `NAME_SUBSTITUTE`: Add word/letter/character/sentense/pattern to remove or replace with other words with sensitive case or without. **Notes**:
1. Seed will get disbaled while using this option
2. Before any character you must add `\BACKSLASH`, those are the characters: `\^$.|?*+()[]{}-`
- * Example-1: `text : code : s | mirror : leech | tea : : s | clone`
- - text will get replaced by code with sensitive case
- - mirror will get replaced by leech
- - tea will get removed with sensitive case
- - clone will get removed
- * Example-2: `\(text\) | \[test\] : test | \\text\\ : text : s`
- - `(text)` will get removed
- - `[test]` will get replaced by test
- - `\text\` will get replaced by text with sensitive case
+ * Example: script/code/s | mirror/leech | tea/ /s | clone | cpu/ | \[mltb\]/mltb | \\text\\/text/s
+ - script will get replaced by code with sensitive case
+ - mirror will get replaced by leech
+ - tea will get replaced by space with sensitive case
+ - clone will get removed
+ - cpu will get replaced by space
+ - [mltb] will get replaced by mltb
+ - \text\ will get replaced by text with sensitive case
**3. GDrive Tools**
diff --git a/bot/helper/common.py b/bot/helper/common.py
index 3fc5872ed49..cc9952349c5 100644
--- a/bot/helper/common.py
+++ b/bot/helper/common.py
@@ -169,7 +169,7 @@ async def before_start(self):
)
)
if self.name_sub:
- self.name_sub = [x.split(" : ") for x in self.name_sub.split(" | ")]
+ self.name_sub = [x.split("/") for x in self.name_sub.split(" | ")]
self.seed = False
self.extension_filter = self.user_dict.get("excluded_extensions") or (
global_extension_filter
@@ -963,13 +963,20 @@ async def substitute(self, dl_path):
if await aiopath.isfile(dl_path):
up_dir, name = dl_path.rsplit("/", 1)
for substitution in self.name_sub:
+ sen = False
pattern = substitution[0]
- res = (
- substitution[1] if len(substitution) > 1 and substitution[1] else ""
- )
- sen = len(substitution) > 2 and substitution[2] == "s"
- new_name = sub(rf"{pattern}", res, name, flags=I if sen else 0)
- new_path = ospath.join(up_dir, new_name)
+ if len(substitution) > 1:
+ if len(substitution) > 2:
+ sen = substitution[2] == "s"
+ res = substitution[1]
+ elif len(substitution[1]) == 0:
+ res = " "
+ else:
+ res = substitution[1]
+ else:
+ res = ""
+ name = sub(rf"{pattern}", res, name, flags=I if sen else 0)
+ new_path = ospath.join(up_dir, name)
await move(dl_path, new_path)
return new_path
else:
@@ -977,13 +984,18 @@ async def substitute(self, dl_path):
for file_ in files:
f_path = ospath.join(dirpath, file_)
for substitution in self.name_sub:
+ sen = False
pattern = substitution[0]
- res = (
- substitution[1]
- if len(substitution) > 1 and substitution[1]
- else ""
- )
- sen = len(substitution) > 2 and substitution[2] == "s"
- new_name = sub(rf"{pattern}", res, file_, flags=I if sen else 0)
- await move(f_path, ospath.join(dirpath, new_name))
+ if len(substitution) > 1:
+ if len(substitution) > 2:
+ sen = substitution[2] == "s"
+ res = substitution[1]
+ elif len(substitution[1]) == 0:
+ res = " "
+ else:
+ res = substitution[1]
+ else:
+ res = ""
+ file_ = sub(rf"{pattern}", res, file_, flags=I if sen else 0)
+ await move(f_path, ospath.join(dirpath, file_))
return dl_path
diff --git a/bot/helper/ext_utils/help_messages.py b/bot/helper/ext_utils/help_messages.py
index db79d994db6..f073df41f20 100644
--- a/bot/helper/ext_utils/help_messages.py
+++ b/bot/helper/ext_utils/help_messages.py
@@ -190,12 +190,18 @@
/cmd rcl or rclonePath -up rclonePath or rc or rcl
/cmd mrcc:rclonePath -up rcl or rc(if you have add rclone path from usetting) (to use user config)"""
-name_sub = """Name Substitution: -ns
-/cmd link -ns tea : coffee : s|ACC : : s|mP4
-This will affect on all files. Format: wordToReplace : wordToReplaceWith : sensitiveCase
-1. tea will get replaced by coffee with sensitive case because I have added `s` last of the option.
-2. ACC will get removed because I have added nothing between to replace with sensitive case because I have added `s` last of the option.
-3. mP4 will get removed because I have added nothing to replace with
+name_sub = r"""Name Substitution: -ns
+/cmd link -ns script/code/s | mirror/leech | tea/ /s | clone | cpu/ | \[mltb\]/mltb | \\text\\/text/s
+This will affect on all files. Format: wordToReplace/wordToReplaceWith/sensitiveCase
+Word Subtitions. You can add pattern instead of normal text. Timeout: 60 sec
+NOTE: You must add \ before any character, those are the characters: \^$.|?*+()[]{}-
+1. script will get replaced by code with sensitive case
+2. mirror will get replaced by leech
+4. tea will get replaced by space with sensitive case
+5. clone will get removed
+6. cpu will get replaced by space
+7. [mltb] will get replaced by mltb
+8. \text\ will get replaced by text with sensitive case
"""
mixed_leech = """Mixed leech: -ml
diff --git a/bot/helper/ext_utils/media_utils.py b/bot/helper/ext_utils/media_utils.py
index 78c1cc15b54..63b0d2ea127 100644
--- a/bot/helper/ext_utils/media_utils.py
+++ b/bot/helper/ext_utils/media_utils.py
@@ -184,10 +184,6 @@ async def get_document_type(path):
mime_type = await sync_to_async(get_mime_type, path)
if mime_type.startswith("image"):
return False, False, True
- if mime_type.startswith("audio"):
- return False, True, False
- if not mime_type.startswith("video") and not mime_type.endswith("octet-stream"):
- return is_video, is_audio, is_image
try:
result = await cmd_exec(
[
@@ -205,6 +201,10 @@ async def get_document_type(path):
is_video = True
except Exception as e:
LOGGER.error(f"Get Document Type: {e}. Mostly File not found! - File: {path}")
+ if mime_type.startswith("audio"):
+ return False, True, False
+ if not mime_type.startswith("video") and not mime_type.endswith("octet-stream"):
+ return is_video, is_audio, is_image
if mime_type.startswith("video"):
is_video = True
return is_video, is_audio, is_image
diff --git a/bot/modules/users_settings.py b/bot/modules/users_settings.py
index 7538632ebec..12318b6bc63 100644
--- a/bot/modules/users_settings.py
+++ b/bot/modules/users_settings.py
@@ -748,15 +748,14 @@ async def edit_user_settings(client, query):
buttons.data_button("Close", f"userset {user_id} close")
emsg = r"""Word Subtitions. You can add pattern instead of normal text. Timeout: 60 sec
NOTE: You must add \ before any character, those are the characters: \^$.|?*+()[]{}-
-Example-1: text : code : s|mirror : leech|tea : : s|clone
-1. text will get replaced by code with sensitive case
+Example: script/code/s | mirror/leech | tea/ /s | clone | cpu/ | \[mltb\]/mltb | \\text\\/text/s
+1. script will get replaced by code with sensitive case
2. mirror will get replaced by leech
-4. tea will get removed with sensitive case
+4. tea will get replaced by space with sensitive case
5. clone will get removed
-Example-2: \(text\) | \[test\] : test | \\text\\ : text : s
-1. (text) will get removed
-2. [test] will get replaced by test
-3. \text\ will get replaced by text with sensitive case
+6. cpu will get replaced by space
+7. [mltb] will get replaced by mltb
+8. \text\ will get replaced by text with sensitive case
"""
emsg += f"Your Current Value is {user_dict.get('name_sub') or 'not added yet!'}"
await edit_message(