From e8a30afad42775b4be139c27d6a0c9b93041d27c Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 21 Apr 2021 14:08:34 +0530
Subject: [PATCH 01/77] Fixed Error Raised When A Invalid UID is Provided
---
bot/database/database.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bot/database/database.py b/bot/database/database.py
index 8241abfa8..dcf5e7f47 100644
--- a/bot/database/database.py
+++ b/bot/database/database.py
@@ -477,6 +477,8 @@ async def get_file(self, unique_id: str):
file = await self.fcol.find_one({"unique_id": unique_id})
file_id = None
file_type = None
+ file_name = None
+ file_caption = None
if file:
file_id = file.get("file_id")
From 2e19ea0900bda0198fea2e7a23a45976bf173e8c Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Fri, 23 Apr 2021 08:23:08 +0530
Subject: [PATCH 02/77] Update commands.py
---
bot/plugins/commands.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/plugins/commands.py b/bot/plugins/commands.py
index 363c690ed..7af5d5db0 100644
--- a/bot/plugins/commands.py
+++ b/bot/plugins/commands.py
@@ -47,7 +47,7 @@ async def start(bot, update):
elif file_type == "video":
- await update.bot.send_video(
+ await bot.send_video(
chat_id=update.chat.id,
video = file_id,
caption = caption,
@@ -66,7 +66,7 @@ async def start(bot, update):
elif file_type == "audio":
- await update.bot.send_audio(
+ await bot.send_audio(
chat_id=update.chat.id,
audio = file_id,
caption = caption,
From bd3a60ebca5a9a153da01d5d36b628326470cbcd Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Fri, 23 Apr 2021 21:00:57 +0530
Subject: [PATCH 03/77] =?UTF-8?q?Fixed=20Some=20Adaptive=20Issues=20?=
=?UTF-8?q?=F0=9F=98=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
bot/plugins/callback.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
index 3276f681e..eefa58d00 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -952,7 +952,7 @@ async def cb_config(bot, update: CallbackQuery):
mf_count = settings["configs"]["max_results"]
mr_count = settings["configs"]["max_per_page"]
show_invite = settings["configs"]["show_invite_link"]
- pm_file_chat = settings["configs"]["pm_fchat"]
+ pm_file_chat = settings["configs"].get("pm_fchat", False)
accuracy_point = settings["configs"].get("accuracy", 0.80)
text=f"Configure Your
+
+
-
-{chat_name} Group's Filter Settings...\n"
From baee87b48bbd3da99ad5a2636549c13020677af2 Mon Sep 17 00:00:00 2001
From: Shahsad Kolathur Deploy To VPS
-git clone https://github.com/AlbertEinsteinTG/Adv-Auto-Filter-Bot-V2/tree/blob/main
-cd Adv-Auto-Filter-Bot-ReMaster
+git clone https://github.com/AlbertEinsteinTG/Adv-Auto-Filter-Bot-V2
+cd Adv-Auto-Filter-Bot-V2
pip3 install -r requirements.txt
# Change The Vars Of bot/__init__.py File Accordingly
python3 -m bot
From 613fab0cf67a808d6468ee0d9094d86bcae626a8 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Mon, 14 Jun 2021 11:55:39 +0530
Subject: [PATCH 15/77] Ownership Transfer
---
Readme.md | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/Readme.md b/Readme.md
index d1f1d89d8..322bac8b8 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,18 +1,18 @@
# Adv Auto Filter Bot V2
-__This Is Just An Simple Advance Auto Filter Bot Complete Rewritten Version Of [Adv-Filter-Bot](https://github.com/AlbertEinsteinTG/Adv-Auto-Filter-Bot)..__
+__This Is Just An Simple Advance Auto Filter Bot Complete Rewritten Version Of [Adv-Filter-Bot](https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot)..__
__Just Sent Any Text As Query It Will Search For All Connected Chat's Files In Its MongoDB And Reply You With The Message Link As A Button__
@@ -73,7 +73,7 @@ You can deploy this bot anywhere.
Deploy To Heroku
-
+
Deploy To VPS
-git clone https://github.com/AlbertEinsteinTG/Adv-Auto-Filter-Bot-V2
+git clone https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot-V2
cd Adv-Auto-Filter-Bot-V2
pip3 install -r requirements.txt
# Change The Vars Of bot/__init__.py File Accordingly
@@ -99,7 +99,7 @@ Do Fork And Star The Repository If You Liked It.
## Disclaimer
[](https://www.gnu.org/licenses/agpl-3.0.en.html#header)
-Licensed under [GNU AGPL v3.0.](https://github.com/AlbertEinsteinTG/Adv-Auto-Filter-Bot-V2/blob/main/LICENSE)
+Licensed under [GNU AGPL v3.0.](https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot-V2/blob/main/LICENSE)
Selling The Codes To Other People For Money Is *Strictly Prohibited*.
@@ -107,3 +107,4 @@ Selling The Codes To Other People For Money Is *Strictly Prohibited*.
- Thanks To Dan For His Awsome [Libary](https://github.com/pyrogram/pyrogram)
- Thanks To SpEcHiDe For His Awesome [DeleteMessagesRoBot](https://github.com/SpEcHiDe/DeleteMessagesRoBot)
+ - [Thanks To Me 👀](https://github.com/AlbertEinsteinTG)
From aa5bca3024075942003d2a08768e6fd980b4b00d Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Mon, 14 Jun 2021 12:50:18 +0530
Subject: [PATCH 16/77] Redirect
---
bot/plugins/commands.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/plugins/commands.py b/bot/plugins/commands.py
index 7af5d5db0..56027add1 100644
--- a/bot/plugins/commands.py
+++ b/bot/plugins/commands.py
@@ -90,7 +90,7 @@ async def start(bot, update):
buttons = [[
InlineKeyboardButton('Developers', url='https://t.me/CrazyBotsz'),
- InlineKeyboardButton('Source Code 🧾', url ='https://github.com/AlbertEinsteinTG/Adv-Auto-Filter-Bot-V2')
+ InlineKeyboardButton('Source Code 🧾', url ='https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot-V2')
],[
InlineKeyboardButton('Support 🛠', url='https://t.me/CrazyBotszGrp')
],[
From 0d362bcc9b51ea368144f65827ccebc7c4571755 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Mon, 14 Jun 2021 12:51:22 +0530
Subject: [PATCH 17/77] Fix!
---
bot/plugins/callback.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
index eefa58d00..ffb301fdd 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -1602,7 +1602,7 @@ async def cb_about(bot, update: CallbackQuery):
text+=f"\nBot's Uptime: {time_formatter(time.time() - start_uptime)}\n"
text+=f"\nBot Funtion: Auto Filter Files\n"
text+=f"""\nBot Support: @CrazyBotszGrp\n"""
- text+="""\nSource Code: Source"""
+ text+="""\nSource Code: Source"""
buttons = [
[
@@ -1640,7 +1640,7 @@ async def callback_data(bot, update: CallbackQuery):
if query_data == "start":
buttons = [[
InlineKeyboardButton('My Dev 👨🔬', url='https://t.me/AlbertEinstein_TG'),
- InlineKeyboardButton('Source Code 🧾', url ='https://github.com/AlbertEinsteinTG/Adv-Auto-Filter-Bot')
+ InlineKeyboardButton('Source Code 🧾', url ='https://github.com/CrazyBotsz/Adv-Filter-Bot-V2')
],[
InlineKeyboardButton('Support 🛠', url='https://t.me/CrazyBotszGrp')
],[
From 9c505532f19379a9d596514a01eb5967dcfeb389 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Mon, 14 Jun 2021 21:38:29 +0530
Subject: [PATCH 18/77] =?UTF-8?q?Technical=20Move=20=F0=9F=98=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Readme.md b/Readme.md
index 322bac8b8..dd4166006 100644
--- a/Readme.md
+++ b/Readme.md
@@ -73,7 +73,7 @@ You can deploy this bot anywhere.
Deploy To Heroku
-
+
" + file_name + "")
-
- if file_type == "document":
-
- await bot.send_document(
- chat_id=update.chat.id,
- document = file_id,
- caption = caption,
- parse_mode="html",
- reply_to_message_id=update.message_id,
- reply_markup=InlineKeyboardMarkup(
- [
- [
- InlineKeyboardButton
- (
- 'Developers', url="https://t.me/CrazyBotsz"
- )
- ]
- ]
- )
- )
-
- elif file_type == "video":
-
- await bot.send_video(
- chat_id=update.chat.id,
- video = file_id,
+ try:
+ await update.reply_cached_media(
+ file_id,
+ quote=True,
caption = caption,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(
@@ -63,29 +41,9 @@ async def start(bot, update):
]
)
)
-
- elif file_type == "audio":
-
- await bot.send_audio(
- chat_id=update.chat.id,
- audio = file_id,
- caption = caption,
- parse_mode="html",
- reply_markup=InlineKeyboardMarkup(
- [
- [
- InlineKeyboardButton
- (
- 'Developers', url="https://t.me/CrazyBotsz"
- )
- ]
- ]
- )
- )
-
- else:
- print(file_type)
-
+ except Exception as e:
+ await update.reply_text(f"Error:\n{e}", True, parse_mode="html")
+ LOGGER(__name__).error(e)
return
buttons = [[
From f12b2da9f48d8dea070390d45e6e0cdc0a56473d Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 11 Jul 2021 20:36:58 +0530
Subject: [PATCH 20/77] Mammanodu Onnum Thonnale.......
---
bot/plugins/commands.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/plugins/commands.py b/bot/plugins/commands.py
index 37ddb6556..5fadbc96b 100644
--- a/bot/plugins/commands.py
+++ b/bot/plugins/commands.py
@@ -2,9 +2,9 @@
# -*- coding: utf-8 -*-
# (c) @AlbertEinsteinTG
-from pyrogram import filters, Client, LOGGER
+from pyrogram import filters, Client
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
-from bot import Translation # pylint: disable=import-error
+from bot import Translation, LOGGER # pylint: disable=import-error
from bot.database import Database # pylint: disable=import-error
db = Database()
From d55204768f831434043a86b71ea3a5486241a6b8 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 18 Jul 2021 09:03:40 +0530
Subject: [PATCH 21/77] =?UTF-8?q?Does=20this=20fix=3F=F0=9F=91=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
bot/bot.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/bot.py b/bot/bot.py
index e90f1f018..f6541e22d 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -20,7 +20,7 @@ def __init__(self):
plugins={
"root": "bot/plugins"
},
- workers=4,
+ workers=200,
bot_token=BOT_TOKEN,
sleep_threshold=10
)
From 2cfd8634fe23fb6dac891d4be384344231457028 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:18:56 +0530
Subject: [PATCH 22/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/User.py | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 DonLee_Robot/User.py
diff --git a/DonLee_Robot/User.py b/DonLee_Robot/User.py
new file mode 100644
index 000000000..4d47fa281
--- /dev/null
+++ b/DonLee_Robot/User.py
@@ -0,0 +1,32 @@
+# !/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @AlbertEinsteinTG
+# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+from pyrogram import Client, __version__
+
+from . import API_HASH, APP_ID, LOGGER, \
+ USER_SESSION
+
+
+class User(Client):
+ def __init__(self):
+ super().__init__(
+ USER_SESSION,
+ api_hash=API_HASH,
+ api_id=APP_ID,
+ workers=4
+ )
+ self.LOGGER = LOGGER
+
+ async def start(self):
+ await super().start()
+ usr_bot_me = await self.get_me()
+ return (self, usr_bot_me.id)
+
+ async def stop(self, *args):
+ await super().stop()
+ self.LOGGER(__name__).info("Bot stopped. Bye.")
From 715298326f78cb5a3cadc2ecf5c1a31e65658f40 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:21:00 +0530
Subject: [PATCH 23/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/donlee_robot.py | 43 ++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 DonLee_Robot/donlee_robot.py
diff --git a/DonLee_Robot/donlee_robot.py b/DonLee_Robot/donlee_robot.py
new file mode 100644
index 000000000..92fc7d37f
--- /dev/null
+++ b/DonLee_Robot/donlee_robot.py
@@ -0,0 +1,43 @@
+# (c) @SpEcHIDe
+# (c) @AlbertEinsteinTG
+# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+from pyrogram import Client, __version__
+
+from . import API_HASH, APP_ID, LOGGER, BOT_TOKEN
+
+from .User import User
+
+class DonLee_Robot(Client):
+ USER: User = None
+ USER_ID: int = None
+
+ def __init__(self):
+ super().__init__(
+ "bot",
+ api_hash=API_HASH,
+ api_id=APP_ID,
+ plugins={
+ "root": "DonLee_Robot/Plugins"
+ },
+ workers=200,
+ bot_token=BOT_TOKEN,
+ sleep_threshold=10
+ )
+ self.LOGGER = LOGGER
+
+ async def start(self):
+ await super().start()
+ bot_details = await self.get_me()
+ self.set_parse_mode("html")
+ self.LOGGER(__name__).info(
+ f"@{bot_details.username} started! "
+ )
+ self.USER, self.USER_ID = await User().start()
+
+ async def stop(self, *args):
+ await super().stop()
+ self.LOGGER(__name__).info("Bot stopped. Bye.")
From ea6377a7d6939a58fe7886b7b5c21dc02873a9ca Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:23:04 +0530
Subject: [PATCH 24/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/__main__.in | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 DonLee_Robot/__main__.in
diff --git a/DonLee_Robot/__main__.in b/DonLee_Robot/__main__.in
new file mode 100644
index 000000000..491431ee6
--- /dev/null
+++ b/DonLee_Robot/__main__.in
@@ -0,0 +1,13 @@
+# !/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @AlbertEinsteinTG
+# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+
+from .donlee_robot import Donlee_Robot
+
+app = Donlee_Robot()
+app.run()
From d182733eead81353322bd572be43c0c598c4cd5a Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:27:53 +0530
Subject: [PATCH 25/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/__init__.py | 50 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 DonLee_Robot/__init__.py
diff --git a/DonLee_Robot/__init__.py b/DonLee_Robot/__init__.py
new file mode 100644
index 000000000..719574f6e
--- /dev/null
+++ b/DonLee_Robot/__init__.py
@@ -0,0 +1,50 @@
+# !/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @AlbertEinsteinTG
+# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+import os
+import logging
+import time
+
+from logging.handlers import RotatingFileHandler
+
+from .Translation import Translation
+
+# Change Accordingly While Deploying To A VPS
+# API_ID From https://youtu.be/5eEsvLAKVc0
+APP_ID = int(os.environ.get("APP_ID"))
+# API_HASH From https://youtu.be/5eEsvLAKVc0
+API_HASH = os.environ.get("API_HASH")
+# BOT_TOKEN From https://youtu.be/cB4UduCcNWs
+BOT_TOKEN = os.environ.get("BOT_TOKEN")
+# DD_URI From https://youtu.be/cB4UduCcNWs
+DB_URI = os.environ.get("DB_URI")
+# USER_SESSION From https://youtu.be/WUN_12-dYOM
+USER_SESSION = os.environ.get("USER_SESSION")
+
+VERIFY = {}
+
+logging.basicConfig(
+ level=logging.INFO,
+ format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",
+ datefmt='%d-%b-%y %H:%M:%S',
+ handlers=[
+ RotatingFileHandler(
+ "autofilterbot.txt",
+ maxBytes=50000000,
+ backupCount=10
+ ),
+ logging.StreamHandler()
+ ]
+)
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+
+start_uptime = time.time()
+
+
+def LOGGER(name: str) -> logging.Logger:
+ return logging.getLogger(name)
From bdd590998241eb0dd91e0bce5e4d52f21edc2905 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:30:09 +0530
Subject: [PATCH 26/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Database/Database.py | 498 ++++++++++++++++++++++++++++++
1 file changed, 498 insertions(+)
create mode 100644 DonLee_Robot/Database/Database.py
diff --git a/DonLee_Robot/Database/Database.py b/DonLee_Robot/Database/Database.py
new file mode 100644
index 000000000..763d64aa8
--- /dev/null
+++ b/DonLee_Robot/Database/Database.py
@@ -0,0 +1,498 @@
+import os
+import motor.motor_asyncio # pylint: disable=import-error
+from DonLee_Robot import DB_URI
+
+DB_NAME = os.environ.get("DB_NAME", "DonLee_Robot")
+
+class Database:
+
+ def __init__(self):
+ self._client = motor.motor_asyncio.AsyncIOMotorClient(DB_URI)
+ self.db = self._client[DB_NAME]
+ self.col = self.db["Main"]
+ self.acol = self.db["Active_Chats"]
+ self.fcol = self.db["Filter_Collection"]
+
+ self.cache = {}
+ self.acache = {}
+
+
+ async def create_index(self):
+ """
+ Create text index if not in db
+ """
+ await self.fcol.create_index([("file_name", "text")])
+
+
+ def new_chat(self, group_id, channel_id, channel_name):
+ """
+ Create a document in db if the chat is new
+ """
+ try:
+ group_id, channel_id = int(group_id), int(channel_id)
+ except:
+ pass
+
+ return dict(
+ _id = group_id,
+ chat_ids = [{
+ "chat_id": channel_id,
+ "chat_name": channel_name
+ }],
+ types = dict(
+ audio=False,
+ document=True,
+ video=True
+ ),
+ configs = dict(
+ accuracy=0.80,
+ max_pages=5,
+ max_results=50,
+ max_per_page=10,
+ pm_fchat=True,
+ show_invite_link=True
+ )
+ )
+
+
+ async def status(self, group_id: int):
+ """
+ Get the total filters, total connected
+ chats and total active chats of a chat
+ """
+ group_id = int(group_id)
+
+ total_filter = await self.tf_count(group_id)
+
+ chats = await self.find_chat(group_id)
+ chats = chats.get("chat_ids")
+ total_chats = len(chats) if chats is not None else 0
+
+ achats = await self.find_active(group_id)
+ if achats not in (None, False):
+ achats = achats.get("chats")
+ if achats == None:
+ achats = []
+ else:
+ achats = []
+ total_achats = len(achats)
+
+ return total_filter, total_chats, total_achats
+
+
+ async def find_group_id(self, channel_id: int):
+ """
+ Find all group id which is connected to a channel
+ for add a new files to db
+ """
+ data = self.col.find({})
+ group_list = []
+
+ for group_id in await data.to_list(length=50): # No Need Of Even 50
+ for y in group_id["chat_ids"]:
+ if int(y["chat_id"]) == int(channel_id):
+ group_list.append(group_id["_id"])
+ else:
+ continue
+ return group_list
+
+ # Related TO Finding Channel(s)
+ async def find_chat(self, group_id: int):
+ """
+ A funtion to fetch a group's settings
+ """
+ connections = self.cache.get(str(group_id))
+
+ if connections is not None:
+ return connections
+
+ connections = await self.col.find_one({'_id': group_id})
+
+ if connections:
+ self.cache[str(group_id)] = connections
+
+ return connections
+ else:
+ return self.new_chat(None, None, None)
+
+
+ async def add_chat(self, group_id: int, channel_id: int, channel_name):
+ """
+ A funtion to add/update a chat document when a new chat is connected
+ """
+ new = self.new_chat(group_id, channel_id, channel_name)
+ update_d = {"$push" : {"chat_ids" : {"chat_id": channel_id, "chat_name" : channel_name}}}
+ prev = await self.col.find_one({'_id':group_id})
+
+ if prev:
+ await self.col.update_one({'_id':group_id}, update_d)
+ await self.update_active(group_id, channel_id, channel_name)
+ await self.refresh_cache(group_id)
+
+ return True
+
+ self.cache[str(group_id)] = new
+
+ await self.col.insert_one(new)
+ await self.add_active(group_id, channel_id, channel_name)
+ await self.refresh_cache(group_id)
+
+ return True
+
+
+ async def del_chat(self, group_id: int, channel_id: int):
+ """
+ A Funtion to delete a channel and its files from db of a chat connection
+ """
+ group_id, channel_id = int(group_id), int(channel_id) # group_id and channel_id Didnt type casted to int for some reason
+
+ prev = self.col.find_one({"_id": group_id})
+
+ if prev:
+
+ await self.col.update_one(
+ {"_id": group_id},
+ {"$pull" :
+ {"chat_ids" :
+ {"chat_id":
+ channel_id
+ }
+ }
+ },
+ False,
+ True
+ )
+
+ await self.del_active(group_id, channel_id)
+ await self.refresh_cache(group_id)
+
+ return True
+
+ return False
+
+
+ async def in_db(self, group_id: int, channel_id: int):
+ """
+ Check whether if the given channel id is in db or not...
+ """
+ connections = self.cache.get(group_id)
+
+ if connections is None:
+ connections = await self.col.find_one({'_id': group_id})
+
+ check_list = []
+
+ if connections:
+ for x in connections["chat_ids"]:
+ check_list.append(int(x.get("chat_id")))
+
+ if int(channel_id) in check_list:
+ return True
+
+ return False
+
+
+ async def update_settings(self, group_id: int, settings):
+ """
+ A Funtion to update a chat's filter types in db
+ """
+ group_id = int(group_id)
+ prev = await self.col.find_one({"_id": group_id})
+
+ if prev:
+ try:
+ await self.col.update_one({"_id": group_id}, {"$set": {"types": settings}})
+ await self.refresh_cache(group_id)
+ return True
+
+ except Exception as e:
+ print (e)
+ return False
+ print("You Should First Connect To A Chat To Use This Funtion..... 'databse.py/#201' ")
+ return False
+
+
+ async def update_configs(self, group_id: int, configs):
+ """
+ A Funtion to update a chat's configs in db
+ """
+ prev = await self.col.find_one({"_id": group_id})
+
+ if prev:
+ try:
+ await self.col.update_one(prev, {"$set":{"configs": configs}})
+ await self.refresh_cache(group_id)
+ return True
+
+ except Exception as e:
+ print (e)
+ return False
+ print("You Should First Connect To A Chat To Use This")
+ return False
+
+
+ async def delete_all(self, group_id: int):
+ """
+ A Funtion to delete all documents related to a
+ chat from db
+ """
+ prev = await self.col.find_one({"_id": group_id})
+ if prev:
+ await self.delall_active(group_id)
+ await self.delall_filters(group_id)
+ await self.del_main(group_id)
+ await self.refresh_cache(group_id)
+
+ return
+
+
+ async def del_main(self, group_id: int):
+ """
+ A Funtion To Delete the chat's main db document
+ """
+ await self.col.delete_one({"_id": group_id})
+ await self.refresh_cache(group_id)
+
+ return True
+
+
+ async def refresh_cache(self, group_id: int):
+ """
+ A Funtion to refresh a chat's chase data
+ in case of update in db
+ """
+ if self.cache.get(str(group_id)):
+ self.cache.pop(str(group_id))
+
+ prev = await self.col.find_one({"_id": group_id})
+
+ if prev:
+ self.cache[str(group_id)] = prev
+ return True
+
+ # Related To Finding Active Channel(s)
+ async def add_active(self, group_id: int, channel_id: int, channel_name):
+ """
+ A Funtion to add a channel as an active chat the a connected group
+ (This Funtion will be used only if its the first time)
+ """
+ templ = {"_id": group_id, "chats":[{"chat_id": channel_id, "chat_name": channel_name}]}
+
+ try:
+ await self.acol.insert_one(templ)
+ await self.refresh_acache(group_id)
+ except Exception as e:
+ print(e)
+ return False
+
+ return True
+
+
+ async def del_active(self, group_id: int, channel_id: int):
+ """
+ A funtion to delete a channel from active chat colletion in db
+ """
+ templ = {"$pull": {"chats": dict(chat_id = channel_id)}}
+
+ try:
+ await self.acol.update_one({"_id": group_id}, templ, False, True)
+ except Exception as e:
+ print(e)
+ pass
+
+ await self.refresh_acache(group_id)
+ return True
+
+
+ async def update_active(self, group_id: int, channel_id: int, channel_name):
+ """
+ A Funtion to add a new active chat to the connected group
+ """
+ group_id, channel_id = int(group_id), int(channel_id)
+
+ prev = await self.acol.find_one({"_id": group_id})
+ templ = {"$push" : {"chats" : dict(chat_id = channel_id, chat_name = channel_name)}}
+ in_c = await self.in_active(group_id, channel_id)
+
+ if prev:
+ if not in_c:
+ await self.acol.update_one({"_id": group_id}, templ)
+ else:
+ return False
+ else:
+ await self.add_active(group_id, channel_id, channel_name)
+ return True
+
+
+ async def find_active(self, group_id: int):
+ """
+ A Funtion to find all active chats of
+ a group from db
+ """
+ if self.acache.get(str(group_id)):
+ self.acache.get(str(group_id))
+
+ connection = await self.acol.find_one({"_id": group_id})
+
+ if connection:
+ return connection
+ return False
+
+
+ async def in_active(self, group_id: int, channel_id: int):
+ """
+ A Funtion to check if a chat id is in the active
+ chat id list in db
+ """
+ prev = await self.acol.find_one({"_id": group_id})
+
+ if prev:
+ for x in prev["chats"]:
+ if x["chat_id"] == channel_id:
+ return True
+
+ return False
+
+ return False
+
+
+ async def delall_active(self, group_id: int):
+ """
+ A Funtion to Delete all active chats of
+ a group from db
+ """
+ await self.acol.delete_one({"_id":int(group_id)})
+ await self.refresh_acache(group_id)
+ return
+
+
+ async def refresh_acache(self, group_id: int):
+ """
+ A Funtion to refresh a active chat's chase data
+ in case of update in db
+ """
+ if self.acache.get(str(group_id)):
+ self.acache.pop(str(group_id))
+
+ prev = await self.acol.find_one({"_id": group_id})
+
+ if prev:
+ self.acache[str(group_id)] = prev
+ return True
+
+ # Related To Finding Filter(s)
+ async def add_filters(self, data):
+ """
+ A Funtion to add document as
+ a bulk to db
+ """
+ try:
+ await self.fcol.insert_many(data)
+ except Exception as e:
+ print(e)
+
+ return True
+
+
+ async def del_filters(self, group_id: int, channel_id: int):
+ """
+ A Funtion to delete all filters of a specific
+ chat and group from db
+ """
+ group_id, channel_id = int(group_id), int(channel_id)
+
+ try:
+ await self.fcol.delete_many({"chat_id": channel_id, "group_id": group_id})
+ print(await self.cf_count(group_id, channel_id))
+ return True
+ except Exception as e:
+ print(e)
+ return False
+
+
+ async def delall_filters(self, group_id: int):
+ """
+ A Funtion To delete all filters of a group
+ """
+ await self.fcol.delete_many({"group_id": int(group_id)})
+ return True
+
+
+ async def get_filters(self, group_id: int, keyword: str):
+ """
+ A Funtion to fetch all similar results for a keyowrd
+ from using text index
+ """
+ await self.create_index()
+
+ chat = await self.find_chat(group_id)
+ chat_accuracy = float(chat["configs"].get("accuracy", 0.80))
+ achats = await self.find_active(group_id)
+
+ achat_ids=[]
+ if not achats:
+ return False
+
+ for chats in achats["chats"]:
+ achat_ids.append(chats.get("chat_id"))
+
+ filters = []
+
+ pipeline= {
+ 'group_id': int(group_id), '$text':{'$search': keyword}
+ }
+
+
+ db_list = self.fcol.find(
+ pipeline,
+ {'score': {'$meta':'textScore'}} # Makes A New Filed With Match Score In Each Document
+ )
+
+ db_list.sort([("score", {'$meta': 'textScore'})]) # Sort all document on the basics of the score field
+
+ for document in await db_list.to_list(length=600):
+ if document["score"] < chat_accuracy:
+ continue
+
+ if document["chat_id"] in achat_ids:
+ filters.append(document)
+ else:
+ continue
+
+ return filters
+
+
+ async def get_file(self, unique_id: str):
+ """
+ A Funtion to get a specific files using its
+ unique id
+ """
+ file = await self.fcol.find_one({"unique_id": unique_id})
+ file_id = None
+ file_type = None
+ file_name = None
+ file_caption = None
+
+ if file:
+ file_id = file.get("file_id")
+ file_name = file.get("file_name")
+ file_type = file.get("file_type")
+ file_caption = file.get("file_caption")
+ return file_id, file_name, file_caption, file_type
+
+
+ async def cf_count(self, group_id: int, channel_id: int):
+ """
+ A Funtion To count number of filter in channel
+ w.r.t the connect group
+ """
+ return await self.fcol.count_documents({"chat_id": channel_id, "group_id": group_id})
+
+
+ async def tf_count(self, group_id: int):
+ """
+ A Funtion to count total filters of a group
+ """
+ return await self.fcol.count_documents({"group_id": group_id})
+
+
From 7af764ae4036ccabe76f26f2ad780963cf176430 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:30:51 +0530
Subject: [PATCH 27/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Database/__init__.py | 1 +
1 file changed, 1 insertion(+)
create mode 100644 DonLee_Robot/Database/__init__.py
diff --git a/DonLee_Robot/Database/__init__.py b/DonLee_Robot/Database/__init__.py
new file mode 100644
index 000000000..07f7250da
--- /dev/null
+++ b/DonLee_Robot/Database/__init__.py
@@ -0,0 +1 @@
+from .Database import Database
From 7ba0f129128b21bc653af12a87d923bafd73997d Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:33:27 +0530
Subject: [PATCH 28/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Channel.py | 358 ++++++++++++++++++++++++++++++++
1 file changed, 358 insertions(+)
create mode 100644 DonLee_Robot/Plugins/Channel.py
diff --git a/DonLee_Robot/Plugins/Channel.py b/DonLee_Robot/Plugins/Channel.py
new file mode 100644
index 000000000..cc8478c6e
--- /dev/null
+++ b/DonLee_Robot/Plugins/Channel.py
@@ -0,0 +1,358 @@
+import random
+import string
+import asyncio
+
+from pyrogram import Client, filters
+from pyrogram.errors import UserAlreadyParticipant, FloodWait
+
+from bot import VERIFY # pylint: disable=import-error
+from bot.bot import Bot # pylint: disable=import-error
+from bot.database import Database # pylint: disable=import-error
+from bot.plugins.auto_filter import recacher # pylint: disable=import-error
+
+db = Database()
+
+@Client.on_message(filters.command(["add"]) & filters.group, group=1)
+async def connect(bot: Bot, update):
+ """
+ A Funtion To Handle Incoming /add Command TO COnnect A Chat With Group
+ """
+ chat_id = update.chat.id
+ user_id = update.from_user.id if update.from_user else None
+ target_chat = update.text.split(None, 1)
+ global VERIFY
+
+ if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
+ admin_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+ admin_list.append(None)
+ VERIFY[str(chat_id)] = admin_list
+
+ if not user_id in VERIFY.get(str(chat_id)):
+ return
+
+ try:
+ if target_chat[1].startswith("@"):
+ if len(target_chat[1]) < 5:
+ await update.reply_text("Invalid Username...!!!")
+ return
+ target = target_chat[1]
+
+ elif not target_chat[1].startswith("@"):
+ if len(target_chat[1]) < 14:
+ await update.reply_text("Invalid Chat Id...\nChat ID Should Be Something Like This: -100xxxxxxxxxx")
+ return
+ target = int(target_chat[1])
+
+ except Exception:
+ await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
+ return
+
+ try:
+ join_link = await bot.export_chat_invite_link(target)
+ except Exception as e:
+ print(e)
+ await update.reply_text(f"Make Sure Im Admin At {target} And Have Permission For 'Inviting Users via Link' And Try Again.....!!!")
+ return
+
+ userbot_info = await bot.USER.get_me()
+ userbot_id = userbot_info.id
+ userbot_name = userbot_info.first_name
+
+ try:
+ await bot.USER.join_chat(join_link)
+
+ except UserAlreadyParticipant:
+ pass
+
+ except Exception:
+ await update.reply_text(f"My UserBot [{userbot_name}](tg://user?id={userbot_id}) Couldnt Join The Channel `{target}` Make Sure Userbot Is Not Banned There Or Add It Manually And Try Again....!!")
+ return
+
+ try:
+ c_chat = await bot.get_chat(target)
+ channel_id = c_chat.id
+ channel_name = c_chat.title
+
+ except Exception as e:
+ await update.reply_text("Encountered Some Issue..Please Check Logs..!!")
+ raise e
+
+
+ in_db = await db.in_db(chat_id, channel_id)
+
+ if in_db:
+ await update.reply_text("Channel Aldready In Db...!!!")
+ return
+
+ wait_msg = await update.reply_text("Please Wait Till I Add All Your Files From Channel To Db\n\nThis May Take 10 or 15 Mins Depending On Your No. Of Files In Channel.....\n\nUntil Then Please Dont Sent Any Other Command Or This Operation May Be Intrupted....")
+
+ try:
+ type_list = ["video", "audio", "document"]
+ data = []
+ skipCT = 0
+
+ for typ in type_list:
+
+ async for msgs in bot.USER.search_messages(channel_id,filter=typ): #Thanks To @PrgOfficial For Suggesting
+
+ # Using 'if elif' instead of 'or' to determine 'file_type'
+ # Better Way? Make A PR
+ try:
+ if msgs.video:
+ try:
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except FloodWait as e:
+ asyncio.sleep(e.x)
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except Exception as e:
+ print(e)
+ continue
+ file_id = file_id.video.file_id
+ file_name = msgs.video.file_name[0:-4]
+ file_caption = msgs.caption if msgs.caption else ""
+ file_size = msgs.video.file_size
+ file_type = "video"
+
+ elif msgs.audio:
+ try:
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except FloodWait as e:
+ asyncio.sleep(e.x)
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except Exception as e:
+ print(e)
+ continue
+ file_id = file_id.audio.file_id
+ file_name = msgs.audio.file_name[0:-4]
+ file_caption = msgs.caption if msgs.caption else ""
+ file_size = msgs.audio.file_size
+ file_type = "audio"
+
+ elif msgs.document:
+ try:
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except FloodWait as e:
+ asyncio.sleep(e.x)
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except Exception as e:
+ print(str(e))
+ continue
+ file_id = file_id.document.file_id
+ file_name = msgs.document.file_name[0:-4]
+ file_caption = msgs.caption if msgs.caption else ""
+ file_size = msgs.document.file_size
+ file_type = "document"
+
+ for i in ["_", "|", "-", "."]: # Work Around
+ try:
+ file_name = file_name.replace(i, " ")
+ except Exception:
+ pass
+
+ file_link = msgs.link
+ group_id = chat_id
+ unique_id = ''.join(
+ random.choice(
+ string.ascii_lowercase +
+ string.ascii_uppercase +
+ string.digits
+ ) for _ in range(15)
+ )
+
+ dicted = dict(
+ file_id=file_id, # Done
+ unique_id=unique_id,
+ file_name=file_name,
+ file_caption=file_caption,
+ file_size=file_size,
+ file_type=file_type,
+ file_link=file_link,
+ chat_id=channel_id,
+ group_id=group_id,
+ )
+
+ data.append(dicted)
+ except Exception as e:
+ if 'NoneType' in str(e): # For Some Unknown Reason Some File Names are NoneType
+ skipCT +=1
+ continue
+ print(e)
+
+ print(f"{skipCT} Files Been Skipped Due To File Name Been None..... #BlameTG")
+ except Exception as e:
+ await wait_msg.edit_text("Couldnt Fetch Files From Channel... Please look Into Logs For More Details")
+ raise e
+
+ await db.add_filters(data)
+ await db.add_chat(chat_id, channel_id, channel_name)
+ await recacher(chat_id, True, True, bot, update)
+
+ await wait_msg.edit_text(f"Channel Was Sucessfully Added With {len(data)} Files..")
+
+
+@Client.on_message(filters.command(["del"]) & filters.group, group=1)
+async def disconnect(bot: Bot, update):
+ """
+ A Funtion To Handle Incoming /del Command TO Disconnect A Chat With A Group
+ """
+ chat_id = update.chat.id
+ user_id = update.from_user.id if update.from_user else None
+ target_chat = update.text.split(None, 1)
+ global VERIFY
+
+ if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
+ admin_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+ admin_list.append(None)
+ VERIFY[str(chat_id)] = admin_list
+
+ if not user_id in VERIFY.get(str(chat_id)):
+ return
+
+ try:
+ if target_chat[1].startswith("@"):
+ if len(target_chat[1]) < 5:
+ await update.reply_text("Invalid Username...!!!")
+ return
+ target = target_chat[1]
+
+ elif not target_chat.startswith("@"):
+ if len(target_chat[1]) < 14:
+ await update.reply_text("Invalid Chat Id...\nChat ID Should Be Something Like This: -100xxxxxxxxxx")
+ return
+ target = int(target_chat[1])
+
+ except Exception:
+ await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
+ return
+
+ userbot = await bot.USER.get_me()
+ userbot_name = userbot.first_name
+ userbot_id = userbot.id
+
+ try:
+ channel_info = await bot.USER.get_chat(target)
+ channel_id = channel_info.id
+ except Exception:
+ await update.reply_text(f"My UserBot [{userbot_name}](tg://user?id={userbot_id}) Couldnt Fetch Details Of `{target}` Make Sure Userbot Is Not Banned There Or Add It Manually And Try Again....!!")
+ return
+
+ in_db = await db.in_db(chat_id, channel_id)
+
+ if not in_db:
+ await update.reply_text("This Channel Is Not Connected With The Group...")
+ return
+
+ wait_msg = await update.reply_text("Deleting All Files Of This Channel From DB....!!!\n\nPlease Be Patience...Dont Sent Another Command Until This Process Finishes..")
+
+ await db.del_filters(chat_id, channel_id)
+ await db.del_active(chat_id, channel_id)
+ await db.del_chat(chat_id, channel_id)
+ await recacher(chat_id, True, True, bot, update)
+
+ await wait_msg.edit_text("Sucessfully Deleted All Files From DB....")
+
+
+@Client.on_message(filters.command(["delall"]) & filters.group, group=1)
+async def delall(bot: Bot, update):
+ """
+ A Funtion To Handle Incoming /delall Command TO Disconnect All Chats From A Group
+ """
+ chat_id=update.chat.id
+ user_id = update.from_user.id if update.from_user else None
+ global VERIFY
+
+ if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
+ admin_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+ admin_list.append(None)
+ VERIFY[str(chat_id)] = admin_list
+
+ if not user_id in VERIFY.get(str(chat_id)):
+ return
+
+ await db.delete_all(chat_id)
+ await recacher(chat_id, True, True, bot, update)
+
+ await update.reply_text("Sucessfully Deleted All Connected Chats From This Group....")
+
+
+@Client.on_message(filters.channel & (filters.video | filters.audio | filters.document) & ~filters.edited, group=0)
+async def new_files(bot: Bot, update):
+ """
+ A Funtion To Handle Incoming New Files In A Channel ANd Add Them To Respective Channels..
+ """
+ channel_id = update.chat.id
+
+ # Using 'if elif' instead of 'or' to determine 'file_type'
+ # Better Way? Make A PR
+
+ try:
+ if update.video:
+ file_type = "video"
+ file_id = update.video.file_id
+ file_name = update.video.file_name[0:-4]
+ file_caption = update.caption if update.caption else ""
+ file_size = update.video.file_size
+
+ elif update.audio:
+ file_type = "audio"
+ file_id = update.audio.file_id
+ file_name = update.audio.file_name[0:-4]
+ file_caption = update.caption if update.caption else ""
+ file_size = update.audio.file_size
+
+ elif update.document:
+ file_type = "document"
+ file_id = update.document.file_id
+ file_name = update.document.file_name[0:-4]
+ file_caption = update.caption if update.caption else ""
+ file_size = update.document.file_size
+
+ for i in ["_", "|", "-", "."]: # Work Around
+ try:
+ file_name = file_name.replace(i, " ")
+ except Exception:
+ pass
+ except Exception as e:
+ print(e)
+ return
+
+
+ file_link = update.link
+ group_ids = await db.find_group_id(channel_id)
+ unique_id = ''.join(
+ random.choice(
+ string.ascii_lowercase +
+ string.ascii_uppercase +
+ string.digits
+ ) for _ in range(15)
+ )
+
+ data = []
+
+ if group_ids:
+ for group_id in group_ids:
+ data_packets = dict(
+ file_id=file_id, # File Id For Future Updates Maybe...
+ unique_id=unique_id,
+ file_name=file_name,
+ file_caption=file_caption,
+ file_size = file_size,
+ file_type=file_type,
+ file_link=file_link,
+ chat_id=channel_id,
+ group_id=group_id,
+ )
+
+ data.append(data_packets)
+ await db.add_filters(data)
+ return
+
From 42c16f76bada65dafc8eb554d4668dee011d7e84 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:45:36 +0530
Subject: [PATCH 29/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Settings.py | 111 +++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
create mode 100644 DonLee_Robot/Plugins/Settings.py
diff --git a/DonLee_Robot/Plugins/Settings.py b/DonLee_Robot/Plugins/Settings.py
new file mode 100644
index 000000000..189c21b10
--- /dev/null
+++ b/DonLee_Robot/Plugins/Settings.py
@@ -0,0 +1,111 @@
+# !/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @AlbertEinsteinTG
+# (c) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+import re
+from pyrogram import Client, filters
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
+from DonLee_Robot import DonLee_Robot
+from DonLee_Robot import VERIFY # pylint: disable=import-error
+
+@DonLee_Robot.on_message(filters.command(["settings"]) & filters.group, group=1)
+async def settings(bot, update):
+
+ chat_id = update.chat.id
+ user_id = update.from_user.id if update.from_user else None
+ global VERIFY
+
+ if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
+ admin_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+ admin_list.append(None)
+ VERIFY[str(chat_id)] = admin_list
+
+ if not user_id in VERIFY.get(str(chat_id)): # Checks if user is admin of the chat
+ return
+
+ bot_info = await bot.get_me()
+ bot_first_name= bot_info.first_name
+
+ text =f"{bot_first_name}'s Settings Pannel.....\n"
+ text+=f"\nYou Can Use This Menu To Change Connectivity And Know Status Of Your Every Connected Channel, Change Filter Types, Configure Filter Results And To Know Status Of Your Group..."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "Channels", callback_data=f"channel_list({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Filter Types", callback_data=f"types({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Configure 🛠", callback_data=f"config({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Status", callback_data=f"status({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "About", callback_data=f"about({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await bot.send_message (
+
+ chat_id=chat_id,
+ text=text,
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+
+ )
+
+
+def remove_emoji(string):
+ emoji_pattern = re.compile("["
+ u"\U0001F600-\U0001F64F"
+ u"\U0001F300-\U0001F5FF"
+ u"\U0001F680-\U0001F6FF"
+ u"\U0001F1E0-\U0001F1FF"
+ u"\U00002500-\U00002BEF"
+ u"\U00002702-\U000027B0"
+ u"\U00002702-\U000027B0"
+ u"\U000024C2-\U0001F251"
+ u"\U0001f926-\U0001f937"
+ u"\U00010000-\U0010ffff"
+ u"\u2640-\u2642"
+ u"\u2600-\u2B55"
+ u"\u200d"
+ u"\u23cf"
+ u"\u23e9"
+ u"\u231a"
+ u"\ufe0f"
+ u"\u3030"
+ "]+", flags=re.UNICODE)
+
+ return emoji_pattern.sub(r' ', str(string))
From cfcd36990a6cba40f16e9b48e2d735cb72956a48 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 09:47:48 +0530
Subject: [PATCH 30/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Channel.py | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/DonLee_Robot/Plugins/Channel.py b/DonLee_Robot/Plugins/Channel.py
index cc8478c6e..773d1be3a 100644
--- a/DonLee_Robot/Plugins/Channel.py
+++ b/DonLee_Robot/Plugins/Channel.py
@@ -5,15 +5,15 @@
from pyrogram import Client, filters
from pyrogram.errors import UserAlreadyParticipant, FloodWait
-from bot import VERIFY # pylint: disable=import-error
-from bot.bot import Bot # pylint: disable=import-error
-from bot.database import Database # pylint: disable=import-error
-from bot.plugins.auto_filter import recacher # pylint: disable=import-error
+from Donlee_Robot import VERIFY # pylint: disable=import-error
+from Donlee_Robot.donlee_robot import Donlee_Robot # pylint: disable=import-error
+from Donlee_Robot.Database import Database # pylint: disable=import-error
+from Donlee_Robot.Plugins.Auto_Filter import recacher # pylint: disable=import-error
db = Database()
-@Client.on_message(filters.command(["add"]) & filters.group, group=1)
-async def connect(bot: Bot, update):
+@Donlee_Robot.on_message(filters.command(["add"]) & filters.group, group=1)
+async def connect(bot: Donlee_Robot, update):
"""
A Funtion To Handle Incoming /add Command TO COnnect A Chat With Group
"""
@@ -193,8 +193,8 @@ async def connect(bot: Bot, update):
await wait_msg.edit_text(f"Channel Was Sucessfully Added With {len(data)} Files..")
-@Client.on_message(filters.command(["del"]) & filters.group, group=1)
-async def disconnect(bot: Bot, update):
+@Donlee_Robot.on_message(filters.command(["del"]) & filters.group, group=1)
+async def disconnect(bot: Donlee_Robot, update):
"""
A Funtion To Handle Incoming /del Command TO Disconnect A Chat With A Group
"""
@@ -258,8 +258,8 @@ async def disconnect(bot: Bot, update):
await wait_msg.edit_text("Sucessfully Deleted All Files From DB....")
-@Client.on_message(filters.command(["delall"]) & filters.group, group=1)
-async def delall(bot: Bot, update):
+@Donlee_Robot.on_message(filters.command(["delall"]) & filters.group, group=1)
+async def delall(bot: Donlee_Robot, update):
"""
A Funtion To Handle Incoming /delall Command TO Disconnect All Chats From A Group
"""
@@ -284,8 +284,8 @@ async def delall(bot: Bot, update):
await update.reply_text("Sucessfully Deleted All Connected Chats From This Group....")
-@Client.on_message(filters.channel & (filters.video | filters.audio | filters.document) & ~filters.edited, group=0)
-async def new_files(bot: Bot, update):
+@Donlee_Robot.on_message(filters.channel & (filters.video | filters.audio | filters.document) & ~filters.edited, group=0)
+async def new_files(bot: Donlee_Robot, update):
"""
A Funtion To Handle Incoming New Files In A Channel ANd Add Them To Respective Channels..
"""
From ce41ae64f1729fe727110a2ce18a0cbac4250319 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 10:09:08 +0530
Subject: [PATCH 31/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Callback.py | 1713 ++++++++++++++++++++++++++++++
1 file changed, 1713 insertions(+)
create mode 100644 DonLee_Robot/Plugins/Callback.py
diff --git a/DonLee_Robot/Plugins/Callback.py b/DonLee_Robot/Plugins/Callback.py
new file mode 100644
index 000000000..40feba6eb
--- /dev/null
+++ b/DonLee_Robot/Plugins/Callback.py
@@ -0,0 +1,1713 @@
+import re
+import time
+import asyncio
+
+from pyrogram import Client, filters
+from pyrogram.errors import FloodWait, UserNotParticipant
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
+
+from DonLee_Robot.donlee_robot import DonLee_Robot
+from DonLee_Robot import start_uptime, Translation, VERIFY # pylint: disable=import-error
+from DonLee_Robot.Plugins.Auto_Filter import ( # pylint: disable=import-error
+ FIND,
+ INVITE_LINK,
+ ACTIVE_CHATS,
+ recacher,
+ gen_invite_links
+ )
+from DonLee_Robot.Plugins.Settings import( # pylint: disable=import-error
+ remove_emoji
+)
+from DonLee_Robot.Database import Database # pylint: disable=import-error
+
+db = Database()
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"navigate\((.+)\)"), group=2)
+async def cb_navg(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For The Next Button Appearing In Results
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ index_val, btn, query = re.findall(r"navigate\((.+)\)", query_data)[0].split("|", 2)
+ try:
+ ruser_id = update.message.reply_to_message.from_user.id
+ except Exception as e:
+ print(e)
+ ruser_id = None
+
+ admin_list = VERIFY.get(str(chat_id))
+ if admin_list == None: # Make Admin's ID List
+
+ admin_list = []
+
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+
+ admin_list.append(None) # Just For Anonymous Admin....
+ VERIFY[str(chat_id)] = admin_list
+
+ if not ((user_id == ruser_id) or (user_id in admin_list)): # Checks if user is same as requested user or is admin
+ await update.answer("Nice Try ;)",show_alert=True)
+ return
+
+
+ if btn == "next":
+ index_val = int(index_val) + 1
+ elif btn == "back":
+ index_val = int(index_val) - 1
+
+ achats = ACTIVE_CHATS[str(chat_id)]
+ configs = await db.find_chat(chat_id)
+ pm_file_chat = configs["configs"]["pm_fchat"]
+ show_invite = configs["configs"]["show_invite_link"]
+ show_invite = (False if pm_file_chat == True else show_invite)
+
+ results = FIND.get(query).get("results")
+ leng = FIND.get(query).get("total_len")
+ max_pages = FIND.get(query).get("max_pages")
+
+ try:
+ temp_results = results[index_val].copy()
+ except IndexError:
+ return # Quick Fix🏃🏃
+ except Exception as e:
+ print(e)
+ return
+
+ if ((index_val + 1 )== max_pages) or ((index_val + 1) == len(results)): # Max Pages
+ temp_results.append([
+ InlineKeyboardButton("⏪ Back", callback_data=f"navigate({index_val}|back|{query})")
+ ])
+
+ elif int(index_val) == 0:
+ pass
+
+ else:
+ temp_results.append([
+ InlineKeyboardButton("⏪ Back", callback_data=f"navigate({index_val}|back|{query})"),
+ InlineKeyboardButton("Next ⏩", callback_data=f"navigate({index_val}|next|{query})")
+ ])
+
+ if not int(index_val) == 0:
+ temp_results.append([
+ InlineKeyboardButton(f"🔰 Page {index_val + 1}/{len(results) if len(results) < max_pages else max_pages} 🔰", callback_data="ignore")
+ ])
+
+ if show_invite and int(index_val) !=0 :
+
+ ibuttons = []
+ achatId = []
+ await gen_invite_links(configs, chat_id, bot, update)
+
+ for x in achats["chats"] if isinstance(achats, dict) else achats:
+ achatId.append(int(x["chat_id"])) if isinstance(x, dict) else achatId.append(x)
+
+ for y in INVITE_LINK.get(str(chat_id)):
+
+ chat_id = int(y["chat_id"])
+
+ if chat_id not in achatId:
+ continue
+
+ chat_name = y["chat_name"]
+ invite_link = y["invite_link"]
+
+ if ((len(ibuttons)%2) == 0):
+ ibuttons.append(
+ [
+ InlineKeyboardButton
+ (
+ f"⚜ {chat_name} ⚜", url=invite_link
+ )
+ ]
+ )
+
+ else:
+ ibuttons[-1].append(
+ InlineKeyboardButton
+ (
+ f"⚜ {chat_name} ⚜", url=invite_link
+ )
+ )
+
+ for x in ibuttons:
+ temp_results.insert(0, x)
+ ibuttons = None
+ achatId = None
+
+ reply_markup = InlineKeyboardMarkup(temp_results)
+
+ text=f"Found {leng} Results For Your Query: {query}"
+
+ try:
+ await update.message.edit(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+ except FloodWait as f: # Flood Wait Caused By Spamming Next/Back Buttons
+ await asyncio.sleep(f.x)
+ await update.message.edit(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"settings"), group=2)
+async def cb_settings(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Back Button in /settings Command
+ """
+ global VERIFY
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)): # Check If User Is Admin
+ return
+
+ bot_status = await bot.get_me()
+ bot_fname= bot_status.first_name
+
+ text =f"{bot_fname}'s Settings Pannel.....\n"
+ text+=f"\nYou Can Use This Menu To Change Connectivity And Know Status Of Your Every Connected Channel, Change Filter Types, Configure Filter Results And To Know Status Of Your Group..."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "Channels", callback_data=f"channel_list({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Filter Types", callback_data=f"types({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Configure 🛠", callback_data=f"config({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Status", callback_data=f"status({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "About", callback_data=f"about({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"warn\((.+)\)"), group=2)
+async def cb_warn(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Acknowledging User's About What Are They Upto
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:35]
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name, action = re.findall(r"warn\((.+)\)", query_data)[0].split("|", 2)
+
+ if action == "connect":
+ text=f"Are You Sure You Want To Enable Connection With {channel_name}..???\n"
+ text+=f"\nThis Will Show File Links From {channel_name} While Showing Results..."
+
+ elif action == "disconnect":
+ text=f"Are You Sure You Want To Disable {channel_name} Connection With The Group???....\n"
+ text+=f"\nThe DB Files Will Still Be There And You Can Connect Back To This Channel Anytime From Settings Menu Without Adding Files To DB Again...\n"
+ text+=f"\nThis Disabling Just Hide Results From The Filter Results..."
+
+ elif action == "c_delete":
+ text=f"Are You Sure You Want To Disconnect {channel_name} From This Group??\n"
+ text+=f"\nThis Will Delete Channel And All Its Files From DB Too....!!\n"
+ text+=f"\nYou Need To Add Channel Again If You Need To Shows It Result..."
+
+
+ elif action=="f_delete":
+ text=f"Are You Sure That You Want To Clear All Filter From This Chat {channel_name}???\n"
+ text+=f"\nThis Will Erase All Files From DB.."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "Yes", callback_data=f"{action}({channel_id}|{channel_name})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "No", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"channel_list\((.+)\)"), group=2)
+async def cb_channel_list(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Displaying All Channel List And Providing A Menu To Navigate
+ To Every COnnect Chats For Furthur Control
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:35]
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id = re.findall(r"channel_list\((.+)\)", query_data)[0]
+
+ text = "Semms Like You Dont Have Any Channel Connected...\n\nConnect To Any Chat To Continue With This Settings..."
+
+ db_list = await db.find_chat(int(chat_id))
+
+ channel_id_list = []
+ channel_name_list = []
+
+ if db_list:
+ for x in db_list["chat_ids"]:
+ channel_id = x["chat_id"]
+ channel_name = x["chat_name"]
+
+ try:
+ if (channel_id == None or channel_name == None):
+ continue
+ except:
+ break
+
+ channel_name = remove_emoji(channel_name).encode('ascii', 'ignore').decode('ascii')[:35]
+ channel_id_list.append(channel_id)
+ channel_name_list.append(channel_name)
+
+ buttons = []
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data="settings"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ )
+
+ if channel_name_list:
+
+ text=f"List Of Connected Channels With {chat_name} With There Settings..\n"
+
+ for x in range(1, (len(channel_name_list)+1)):
+ text+=f"\n{x}. {channel_name_list[x-1]}\n"
+
+ text += "\nChoose Appropriate Buttons To Navigate Through Respective Channels"
+
+
+ btn_key = [
+ "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟",
+ "1️⃣1️⃣", "1️⃣2️⃣", "1️⃣3️⃣", "1️⃣4️⃣", "1️⃣5️⃣", "1️⃣6️⃣", "1️⃣7️⃣",
+ "1️⃣8️⃣", "1️⃣9️⃣", "2️⃣0️⃣" # Just In Case 😂🤣
+ ]
+
+ for i in range(1, (len(channel_name_list) + 1)): # Append The Index Number of Channel In Just A Single Line
+ if i == 1:
+ buttons.insert(0,
+ [
+ InlineKeyboardButton
+ (
+ btn_key[i-1], callback_data=f"info({channel_id_list[i-1]}|{channel_name_list[i-1]})"
+ )
+ ]
+ )
+
+ else:
+ buttons[0].append(
+ InlineKeyboardButton
+ (
+ btn_key[i-1], callback_data=f"info({channel_id_list[i-1]}|{channel_name_list[i-1]})"
+ )
+ )
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text = text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"info\((.+)\)"), group=2)
+async def cb_info(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Displaying Details Of The Connected Chat And Provide
+ Ability To Connect / Disconnect / Delete / Delete Filters of That Specific Chat
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"info\((.+)\)", query_data)[0].split("|", 1)
+
+ f_count = await db.cf_count(chat_id, int(channel_id))
+ active_chats = await db.find_active(chat_id)
+
+ if active_chats: # Checks for active chats connected to a chat
+ dicts = active_chats["chats"]
+ db_cids = [ int(x["chat_id"]) for x in dicts ]
+
+ if int(channel_id) in db_cids:
+ active_chats = True
+ status = "Connected"
+
+ else:
+ active_chats = False
+ status = "Disconnected"
+
+ else:
+ active_chats = False
+ status = "Disconnected"
+
+ text=f"Info About {channel_name}\n"
+ text+=f"\nChannel Name: {channel_name}\n"
+ text+=f"\nChannel ID: {channel_id}\n"
+ text+=f"\nChannel Files: {f_count}\n"
+ text+=f"\nCurrent Status: {status}\n"
+
+
+ if active_chats:
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "🚨 Disconnect 🚨", callback_data=f"warn({channel_id}|{channel_name}|disconnect)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
+ )
+ ]
+ ]
+
+ else:
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "💠 Connect 💠", callback_data=f"warn({channel_id}|{channel_name}|connect)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
+ )
+ ]
+ ]
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
+ )
+ ]
+ )
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"channel_list({chat_id})"
+ )
+ ]
+ )
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"^connect\((.+)\)"), group=2)
+async def cb_connect(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Helping The user To Make A Chat Active Chat Which Will
+ Make The Bot To Fetch Results From This Channel Too
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"connect\((.+)\)", query_data)[0].split("|", 1)
+ channel_id = int(channel_id)
+
+ f_count = await db.cf_count(chat_id, channel_id)
+
+ add_active = await db.update_active(chat_id, channel_id, channel_name)
+
+ if not add_active:
+ await update.answer(f"{channel_name} Is Aldready in Active Connection", show_alert=True)
+ return
+
+ text= f"Sucessfully Connected To {channel_name}\n"
+ text+=f"\nInfo About {channel_name}\n"
+ text+=f"\nChannel Name: {channel_name}\n"
+ text+=f"\nChannel ID: {channel_id}\n"
+ text+=f"\nChannel Files: {f_count}\n"
+ text+=f"\nCurrent Status: Connected\n"
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "🚨 Disconnect 🚨", callback_data=f"warn({channel_id}|{channel_name}|disconnect)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
+ )
+ ]
+ ]
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
+ )
+ ]
+ )
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"channel_list({chat_id})"
+ )
+ ]
+ )
+ await recacher(chat_id, False, True, bot, update)
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"disconnect\((.+)\)"), group=2)
+async def cb_disconnect(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Helping The user To Make A Chat inactive Chat Which Will
+ Make The Bot To Avoid Fetching Results From This Channel
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"connect\((.+)\)", query_data)[0].split("|", 1)
+
+ f_count = await db.cf_count(chat_id, int(channel_id))
+
+ remove_active = await db.del_active(chat_id, int(channel_id))
+
+ if not remove_active:
+ await update.answer("Couldnt Full Fill YOur Request...\n Report This @CrazyBotszGrp Along With Bot's Log", show_alert=True)
+ return
+
+ text= f"Sucessfully Disconnected From {channel_name}\n"
+ text+=f"\nInfo About {channel_name}\n"
+ text+=f"\nChannel Name: {channel_name}\n"
+ text+=f"\nChannel ID: {channel_id}\n"
+ text+=f"\nChannel Files: {f_count}\n"
+ text+=f"\nCurrent Status: Disconnected\n"
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "💠 Connect 💠", callback_data=f"warn({channel_id}|{channel_name}|connect)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
+ )
+ ]
+ ]
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
+ )
+ ]
+ )
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"channel_list({chat_id})"
+ )
+ ]
+ )
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await recacher(chat_id, False, True, bot, update)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"c_delete\((.+)\)"), group=2)
+async def cb_channel_delete(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Delete A Channel Connection From A Group Chat History
+ Along With All Its Filter Files
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"c_delete\((.+)\)", query_data)[0].split("|", 1)
+ channel_id = int(channel_id)
+
+ c_delete = await db.del_chat(chat_id, channel_id)
+ a_delete = await db.del_active(chat_id, channel_id) # pylint: disable=unused-variable
+ f_delete = await db.del_filters(chat_id, channel_id)
+
+ if (c_delete and f_delete ):
+ text=f"{channel_name} [ {channel_id} ] Has Been Sucessfully Deleted And All Its Files Were Cleared From DB...."
+
+ else:
+ text=f"Couldn't Delete Channel And All Its Files From DB Sucessfully....\nPlease Try Again After Sometimes...Also Make Sure To Check The Logs..!!"
+ await update.answer(text=text, show_alert=True)
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"channel_list({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ await recacher(chat_id, True, True, bot, update)
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"f_delete\((.+)\)"), group=2)
+async def cb_filters_delete(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Delete A Specific Channel's Filters Connected To A Group
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"f_delete\((.+)\)", query_data)[0].split("|", 1)
+
+ f_delete = await db.del_filters(chat_id, int(channel_id))
+
+ if not f_delete:
+ text="Oops..!!\n\nEncountered Some Error While Deleteing Filters....\nPlease Check The Logs...."
+ await update.answer(text=text, show_alert=True)
+ return
+
+ text =f"All Filters Of {channel_id}[{channel_name}] Has Been Deleted Sucessfully From My DB.."
+
+ buttons=[
+ [
+ InlineKeyboardButton
+ (
+ "Back", callback_data="settings"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"types\((.+)\)"), group=2)
+async def cb_types(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Changing The Result Types To Be Shown In While Sending Results
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id = re.findall(r"types\((.+)\)", query_data)[0]
+
+ _types = await db.find_chat(int(chat_id))
+
+ text=f"Filter Types Enabled/Disbled In {chat_name}\n"
+
+ _types = _types["types"]
+ vid = _types["video"]
+ doc = _types["document"]
+ aud = _types["audio"]
+
+ buttons = []
+
+ if vid:
+ text+="\nVideo Index: Enabled\n"
+ v_e = "✅"
+ vcb_data = f"toggle({chat_id}|video|False)"
+
+ else:
+ text+="\nVideo Index: Disabled\n"
+ v_e="❎"
+ vcb_data = f"toggle({chat_id}|video|True)"
+
+ if doc:
+ text+="\nDocument Index: Enabled\n"
+ d_e = "✅"
+ dcb_data = f"toggle({chat_id}|document|False)"
+
+ else:
+ text+="\nDocument Index: Disabled\n"
+ d_e="❎"
+ dcb_data = f"toggle({chat_id}|document|True)"
+
+ if aud:
+ text+="\nAudio Index: Enabled\n"
+ a_e = "✅"
+ acb_data = f"toggle({chat_id}|audio|False)"
+
+ else:
+ text+="\nAudio Index: Disabled\n"
+ a_e="❎"
+ acb_data = f"toggle({chat_id}|audio|True)"
+
+
+ text+="\nBelow Buttons Will Toggle Respective Media Types As Enabled Or Disabled....\n"
+ text+="This Will Take Into Action As Soon As You Change Them...."
+
+ buttons.append([InlineKeyboardButton(f"Video Index: {v_e}", callback_data=vcb_data)])
+ buttons.append([InlineKeyboardButton(f"Audio Index: {a_e}", callback_data=acb_data)])
+ buttons.append([InlineKeyboardButton(f"Document Index: {d_e}", callback_data=dcb_data)])
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"settings"
+ )
+ ]
+ )
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"toggle\((.+)\)"), group=2)
+async def cb_toggle(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Support handler For types()
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id, types, val = re.findall(r"toggle\((.+)\)", query_data)[0].split("|", 2)
+
+ _types = await db.find_chat(int(chat_id))
+
+ _types = _types["types"]
+ vid = _types["video"]
+ doc = _types["document"]
+ aud = _types["audio"]
+
+ if types == "video":
+ vid = True if val=="True" else False
+ elif types == "audio":
+ aud = True if val=="True" else False
+ elif types == "document":
+ doc = True if val=="True" else False
+
+
+ settings = {
+ "video": vid,
+ "audio": aud,
+ "document": doc
+ }
+
+ process = await db.update_settings(chat_id, settings)
+
+ if process:
+ await update.answer(text="Filter Types Updated Sucessfully", show_alert=True)
+
+ else:
+ text="Something Wrong Please Check Bot Log For More Information...."
+ await update.answer(text, show_alert=True)
+ return
+
+ _types = await db.find_chat(int(chat_id))
+
+ text =f"Filter Types Enabled In {update.message.chat.title}\n"
+
+ _types = _types["types"]
+ vid = _types["video"]
+ doc = _types["document"]
+ aud = _types["audio"]
+
+ buttons = []
+
+ if vid:
+ text+="\nVideo Index: Enabled\n"
+ v_e = "✅"
+ vcb_data = f"toggle({chat_id}|video|False)"
+
+ else:
+ text+="\nVideo Index: Disabled\n"
+ v_e="❎"
+ vcb_data = f"toggle({chat_id}|video|True)"
+
+ if doc:
+ text+="\nDocument Index: Enabled\n"
+ d_e = "✅"
+ dcb_data = f"toggle({chat_id}|document|False)"
+
+ else:
+ text+="\nDocument Index: Disabled\n"
+ d_e="❎"
+ dcb_data = f"toggle({chat_id}|document|True)"
+
+ if aud:
+ text+="\nAudio Index: Enabled\n"
+ a_e = "✅"
+ acb_data = f"toggle({chat_id}|audio|False)"
+
+ else:
+ text+="\nAudio Index: Disabled\n"
+ a_e="❎"
+ acb_data = f"toggle({chat_id}|audio|True)"
+
+
+ text+="\nBelow Buttons Will Toggle Respective Media Types As Enabled Or Disabled....\n"
+ text+="This Will Take Into Action As Soon As You Change Them...."
+
+ buttons.append([InlineKeyboardButton(f"Video Index : {v_e}", callback_data=vcb_data)])
+ buttons.append([InlineKeyboardButton(f"Audio Index : {a_e}", callback_data=acb_data)])
+ buttons.append([InlineKeyboardButton(f"Document Index : {d_e}", callback_data=dcb_data)])
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"settings"
+ )
+ ]
+ )
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"config\((.+)\)"), group=2)
+async def cb_config(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Chaning The Number Of Total Pages /
+ Total Results / Results Per pages / Enable or Diable Invite Link /
+ Enable or Disable PM File Chat
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id = re.findall(r"config\((.+)\)", query_data)[0]
+
+ settings = await db.find_chat(int(chat_id))
+
+ mp_count = settings["configs"]["max_pages"]
+ mf_count = settings["configs"]["max_results"]
+ mr_count = settings["configs"]["max_per_page"]
+ show_invite = settings["configs"]["show_invite_link"]
+ pm_file_chat = settings["configs"].get("pm_fchat", False)
+ accuracy_point = settings["configs"].get("accuracy", 0.80)
+
+ text=f"Configure Your {chat_name} Group's Filter Settings...\n"
+
+ text+=f"\n{chat_name} Current Settings:\n"
+
+ text+=f"\n - Max Filter: {mf_count}\n"
+
+ text+=f"\n - Max Pages: {mp_count}\n"
+
+ text+=f"\n - Max Filter Per Page: {mr_count}\n"
+
+ text+=f"\n - Accuracy Percentage: {accuracy_point}\n"
+
+ text+=f"\n - Show Invitation Link: {show_invite}\n"
+
+ text+=f"\n - Provide File In Bot PM: {pm_file_chat}\n"
+
+ text+="\nAdjust Above Value Using Buttons Below... "
+ buttons=[
+ [
+ InlineKeyboardButton
+ (
+ "Filter Per Page", callback_data=f"mr_count({mr_count}|{chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Max Pages", callback_data=f"mp_count({mp_count}|{chat_id})"
+ )
+ ]
+ ]
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Total Filter Count", callback_data=f"mf_count({mf_count}|{chat_id})"
+ )
+ ]
+ )
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Show Invite Links", callback_data=f"show_invites({show_invite}|{chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Bot File Chat", callback_data=f"inPM({pm_file_chat}|{chat_id})"
+ )
+ ]
+ )
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Result's Accuracy", callback_data=f"accuracy({accuracy_point}|{chat_id})"
+ )
+ ]
+ )
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"settings"
+ )
+ ]
+ )
+
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"mr_count\((.+)\)"), group=2)
+async def cb_max_buttons(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Changing The Count Of Result To Be Shown Per Page
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ count, chat_id = re.findall(r"mr_count\((.+)\)", query_data)[0].split("|", 1)
+
+ text = f"Choose Your Desired 'Max Filter Count Per Page' For Every Filter Results Shown In {chat_name}"
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "5 Filters", callback_data=f"set(per_page|5|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "10 Filters", callback_data=f"set(per_page|10|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "15 Filters", callback_data=f"set(per_page|15|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "20 Filters", callback_data=f"set(per_page|20|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "25 Filters", callback_data=f"set(per_page|25|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "30 Filters", callback_data=f"set(per_page|30|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"mp_count\((.+)\)"), group=2)
+async def cb_max_page(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Changing The Count Of Maximum Result Pages To Be Shown
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ count, chat_id = re.findall(r"mp_count\((.+)\)", query_data)[0].split("|", 1)
+
+ text = f"Choose Your Desired 'Max Filter Page Count' For Every Filter Results Shown In {chat_name}"
+
+ buttons = [
+
+ [
+ InlineKeyboardButton
+ (
+ "2 Pages", callback_data=f"set(pages|2|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "4 Pages", callback_data=f"set(pages|4|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "6 Pages", callback_data=f"set(pages|6|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "8 Pages", callback_data=f"set(pages|8|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "10 Pages", callback_data=f"set(pages|10|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"config({chat_id})"
+ )
+ ]
+
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"mf_count\((.+)\)"), group=2)
+async def cb_max_results(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Changing The Count Of Maximum Files TO Be Fetched From Database
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ count, chat_id = re.findall(r"mf_count\((.+)\)", query_data)[0].split("|", 1)
+
+ text = f"Choose Your Desired 'Max Filter' To Be Fetched From DB For Every Filter Results Shown In {chat_name}"
+
+ buttons = [
+
+ [
+ InlineKeyboardButton
+ (
+ "50 Results", callback_data=f"set(results|50|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "100 Results", callback_data=f"set(results|100|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "150 Results", callback_data=f"set(results|150|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "200 Results", callback_data=f"set(results|200|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "250 Results", callback_data=f"set(results|250|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "300 Results", callback_data=f"set(results|300|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"show_invites\((.+)\)"), group=2)
+async def cb_show_invites(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Enabling Or Diabling Invite Link Buttons
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ value, chat_id = re.findall(r"show_invites\((.+)\)", query_data)[0].split("|", 1)
+
+ value = True if value=="True" else False
+
+ if value:
+ buttons= [
+ [
+ InlineKeyboardButton
+ (
+ "Disable ❌", callback_data=f"set(showInv|False|{chat_id}|{value})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ else:
+ buttons =[
+ [
+ InlineKeyboardButton
+ (
+ "Enable ✔", callback_data=f"set(showInv|True|{chat_id}|{value})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ text=f"This Config Will Help You To Show Invitation Link Of All Active Chats Along With The Filter Results For The Users To Join....."
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"inPM\((.+)\)"), group=2)
+async def cb_pm_file(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Enabling Or Diabling File Transfer Through Bot PM
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ value, chat_id = re.findall(r"inPM\((.+)\)", query_data)[0].split("|", 1)
+
+ value = True if value=="True" else False
+
+ if value:
+ buttons= [
+ [
+ InlineKeyboardButton
+ (
+ "Disable ❎", callback_data=f"set(inPM|False|{chat_id}|{value})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ else:
+ buttons =[
+ [
+ InlineKeyboardButton
+ (
+ "Enable ✅", callback_data=f"set(inPM|True|{chat_id}|{value})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ text=f"This Config Will Help You To Enable/Disable File Transfer Through Bot PM Without Redirecting Them To Channel...."
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"accuracy\((.+)\)"), group=2)
+async def cb_accuracy(bot, update: CallbackQuery):
+ """
+ A Callaback Funtion to control the accuracy of matching results
+ that the bot should return for a query....
+ """
+ global VERIFY
+ chat_id = update.message.chat.id
+ chat_name = update.message.chat.title
+ user_id = update.from_user.id
+ query_data = update.data
+
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ val, chat_id = re.findall(r"accuracy\((.+)\)", query_data)[0].split("|", 1)
+
+ text = f"Choose Your Desired 'Accuracy Perceentage' For Every Filter Results Shown In {chat_name}\n\n"
+ text+= f"NB: Higher The Value Better Matching Results Will Be Provided... And If Value Is Lower It Will Show More Results \
+ Which Is Fimilary To Query Search (Wont Be Accurate)...."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "100 %", callback_data=f"set(accuracy|1.00|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "80 %", callback_data=f"set(accuracy|0.80|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "65 %", callback_data=f"set(accuracy|0.65|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "60 %", callback_data=f"set(accuracy|0.60|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "55 %", callback_data=f"set(accuracy|0.55|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "50 %", callback_data=f"set(accuracy|0.50|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"set\((.+)\)"), group=2)
+async def cb_set(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Support For config()
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ action, val, chat_id, curr_val = re.findall(r"set\((.+)\)", query_data)[0].split("|", 3)
+
+ try:
+ val, chat_id, curr_val = float(val), int(chat_id), float(curr_val)
+ except:
+ chat_id = int(chat_id)
+
+ if val == curr_val:
+ await update.answer("New Value Cannot Be Old Value...Please Choose Different Value...!!!", show_alert=True)
+ return
+
+ prev = await db.find_chat(chat_id)
+
+ accuracy = float(prev["configs"].get("accuracy", 0.80))
+ max_pages = int(prev["configs"].get("max_pages"))
+ max_results = int(prev["configs"].get("max_results"))
+ max_per_page = int(prev["configs"].get("max_per_page"))
+ pm_file_chat = True if prev["configs"].get("pm_fchat") == (True or "True") else False
+ show_invite_link = True if prev["configs"].get("show_invite_link") == (True or "True") else False
+
+ if action == "accuracy": # Scophisticated way 😂🤣
+ accuracy = val
+
+ elif action == "pages":
+ max_pages = int(val)
+
+ elif action == "results":
+ max_results = int(val)
+
+ elif action == "per_page":
+ max_per_page = int(val)
+
+ elif action =="showInv":
+ show_invite_link = True if val=="True" else False
+
+ elif action == "inPM":
+ pm_file_chat = True if val=="True" else False
+
+
+ new = dict(
+ accuracy=accuracy,
+ max_pages=max_pages,
+ max_results=max_results,
+ max_per_page=max_per_page,
+ pm_fchat=pm_file_chat,
+ show_invite_link=show_invite_link
+ )
+
+ append_db = await db.update_configs(chat_id, new)
+
+ if not append_db:
+ text="Something Wrong Please Check Bot Log For More Information...."
+ await update.answer(text=text, show_alert=True)
+ return
+
+ text=f"Your Request Was Updated Sucessfully....\nNow All Upcoming Results Will Show According To This Settings..."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"status\((.+)\)"), group=2)
+async def cb_status(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Showing Overall Status Of A Group
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id = re.findall(r"status\((.+)\)", query_data)[0]
+
+ total_filters, total_chats, total_achats = await db.status(chat_id)
+
+ text = f"Status Of {chat_name}\n"
+ text += f"\nTotal Connected Chats: {total_chats}\n"
+ text += f"\nTotal Active Chats: {total_achats}\n"
+ text += f"\nTotal Filters: {total_filters}"
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data="settings"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"about\((.+)\)"), group=2)
+async def cb_about(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Showing About Section In Bot Setting Menu
+ """
+ global VERIFY
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ text=f"Bot's Status\n"
+ text+=f"\nBot's Uptime: {time_formatter(time.time() - start_uptime)}\n"
+ text+=f"\nBot Funtion: Auto Filter Files\n"
+ text+=f"""\nBot Support: @Mo_Tech_Group\n"""
+ text+="""\nSource Code: Source"""
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "My Dev ⚡", url="https://t.me/MRK_YT"
+ ),
+
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data="settings"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"^(start|help|about|close)$"), group=2)
+async def callback_data(bot, update: CallbackQuery):
+
+ query_data = update.data
+
+ if query_data == "start":
+ buttons = [[
+ InlineKeyboardButton('My Dev 👨🔬', url='https://t.me/Mrk_YT'),
+ InlineKeyboardButton('Source Code 🧾', url ='https://github.com/PR0FESS0R-99/DonLee_Robot')
+ ],[
+ InlineKeyboardButton('🛠 Support 🛠', url='https://t.me/mo_Tech_yt')
+ ],[
+ InlineKeyboardButton('⚙ Help ⚙', callback_data="help")
+ ],[
+ InlineKeyboardButton('💫 Deploy Video 💫', url='https://youtu.be/uAHl5jvnrhk')
+ ]]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ Translation.START_TEXT.format(update.from_user.mention),
+ reply_markup=reply_markup,
+ parse_mode="html",
+ disable_web_page_preview=True
+ )
+
+
+ elif query_data == "help":
+ buttons = [[
+ InlineKeyboardButton('Home ⚡', callback_data='start'),
+ InlineKeyboardButton('About 🚩', callback_data='about')
+ ],[
+ InlineKeyboardButton('Close 🔐', callback_data='close')
+ ]]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ Translation.HELP_TEXT,
+ reply_markup=reply_markup,
+ parse_mode="html",
+ disable_web_page_preview=True
+ )
+
+
+ elif query_data == "about":
+ buttons = [[
+ InlineKeyboardButton('Home ⚡', callback_data='start'),
+ InlineKeyboardButton('Close 🔐', callback_data='close')
+ ]]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ Translation.ABOUT_TEXT,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+ elif query_data == "close":
+ await update.message.delete()
+
+
+
+def time_formatter(seconds: float) -> str:
+ """
+ humanize time
+ """
+ minutes, seconds = divmod(int(seconds),60)
+ hours, minutes = divmod(minutes, 60)
+ days, hours = divmod(hours, 24)
+ tmp = ((str(days) + "d, ") if days else "") + \
+ ((str(hours) + "h, ") if hours else "") + \
+ ((str(minutes) + "m, ") if minutes else "") + \
+ ((str(seconds) + "s") if seconds else "")
+ return tmp
+
From e674bc10f78b5605129adf887dab89deb96139b5 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 10:14:34 +0530
Subject: [PATCH 32/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Commands.py | 113 +++++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
create mode 100644 DonLee_Robot/Plugins/Commands.py
diff --git a/DonLee_Robot/Plugins/Commands.py b/DonLee_Robot/Plugins/Commands.py
new file mode 100644
index 000000000..cc4c8015c
--- /dev/null
+++ b/DonLee_Robot/Plugins/Commands.py
@@ -0,0 +1,113 @@
+# !/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @AlbertEinsteinTG
+# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+from pyrogram import filters, Client
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
+from DonLee_Robot import Translation, LOGGER # pylint: disable=import-error
+from DonLee_Robot.Database import Database # pylint: disable=import-error
+from DonLee_Robot.donlee_robot import DonLee_Robot
+
+db = Database()
+
+@DonLee_Robot.on_message(filters.command(["start"]) & filters.private, group=1)
+async def start(bot, update):
+
+ try:
+ file_uid = update.command[1]
+ except IndexError:
+ file_uid = False
+
+ if file_uid:
+ file_id, file_name, file_caption, file_type = await db.get_file(file_uid)
+
+ if (file_id or file_type) == None:
+ return
+
+ caption = file_caption if file_caption != ("" or None) else ("" + file_name + "")
+ try:
+ await update.reply_cached_media(
+ file_id,
+ quote=True,
+ caption = caption,
+ parse_mode="html",
+ reply_markup=InlineKeyboardMarkup(
+ [
+ [
+ InlineKeyboardButton
+ (
+ 'Developers', url="https://t.me/mo_tech_YT"
+ )
+ ]
+ ]
+ )
+ )
+ except Exception as e:
+ await update.reply_text(f"Error:\n{e}", True, parse_mode="html")
+ LOGGER(__name__).error(e)
+ return
+
+ buttons = [[
+ InlineKeyboardButton('My Dev 🧒', url='https://t.me/mrk_yt'),
+ InlineKeyboardButton('Source Code 🧾', url ='https://github.com/PR0FESS0R-99/DonLee_Robot')
+ ],[
+ InlineKeyboardButton('🛠 Support 🛠', url='https://t.me/mo_tech_yt')
+ ],[
+ InlineKeyboardButton('⚙ Help ⚙', callback_data="help")
+ ],[
+ InlineKeyboardButton('💫 Deploy Video 💫', url='https://youtu.be/uAHl5jvnrhk')
+ ]]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.START_TEXT.format(
+ update.from_user.first_name),
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
+
+
+@DonLee_Robot.on_message(filters.command(["help"]) & filters.private, group=1)
+async def help(bot, update):
+ buttons = [[
+ InlineKeyboardButton('Home ⚡', callback_data='start'),
+ InlineKeyboardButton('About 🚩', callback_data='about')
+ ],[
+ InlineKeyboardButton('Close 🔐', callback_data='close')
+ ]]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.HELP_TEXT,
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
+
+
+@DonLee_Robot.on_message(filters.command(["about"]) & filters.private, group=1)
+async def about(bot, update):
+
+ buttons = [[
+ InlineKeyboardButton('Home ⚡', callback_data='start'),
+ InlineKeyboardButton('Close 🔐', callback_data='close')
+ ]]
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.ABOUT_TEXT,
+ reply_markup=reply_markup,
+ disable_web_page_preview=True,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
From 7ada01c6d299350c5fa29f6592d31e3d3f30b450 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 10:17:56 +0530
Subject: [PATCH 33/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Auto_Filter.py | 288 ++++++++++++++++++++++++++++
1 file changed, 288 insertions(+)
create mode 100644 DonLee_Robot/Plugins/Auto_Filter.py
diff --git a/DonLee_Robot/Plugins/Auto_Filter.py b/DonLee_Robot/Plugins/Auto_Filter.py
new file mode 100644
index 000000000..07d2a1841
--- /dev/null
+++ b/DonLee_Robot/Plugins/Auto_Filter.py
@@ -0,0 +1,288 @@
+import re
+import logging
+import asyncio
+
+from pyrogram import Client, filters
+from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
+from pyrogram.errors import ButtonDataInvalid, FloodWait
+
+from DonLee_Robot.Database import Database # pylint: disable=import-error
+from DonLee_Robot.donlee_robot import DonLee_Robot # pylint: disable=import-error
+
+
+FIND = {}
+INVITE_LINK = {}
+ACTIVE_CHATS = {}
+db = Database()
+
+@DonLee_Robot.on_message(filters.text & filters.group & ~filters.bot, group=0)
+async def auto_filter(bot, update):
+ """
+ A Funtion To Handle Incoming Text And Reply With Appropriate Results
+ """
+ group_id = update.chat.id
+
+ if re.findall(r"((^\/|^,|^\.|^[\U0001F600-\U000E007F]).*)", update.text):
+ return
+
+ if ("https://" or "http://") in update.text:
+ return
+
+ query = re.sub(r"[1-2]\d{3}", "", update.text) # Targetting Only 1000 - 2999 😁
+
+ if len(query) < 2:
+ return
+
+ results = []
+
+ global ACTIVE_CHATS
+ global FIND
+
+ configs = await db.find_chat(group_id)
+ achats = ACTIVE_CHATS[str(group_id)] if ACTIVE_CHATS.get(str(group_id)) else await db.find_active(group_id)
+ ACTIVE_CHATS[str(group_id)] = achats
+
+ if not configs:
+ return
+
+ allow_video = configs["types"]["video"]
+ allow_audio = configs["types"]["audio"]
+ allow_document = configs["types"]["document"]
+
+ max_pages = configs["configs"]["max_pages"] # maximum page result of a query
+ pm_file_chat = configs["configs"]["pm_fchat"] # should file to be send from bot pm to user
+ max_results = configs["configs"]["max_results"] # maximum total result of a query
+ max_per_page = configs["configs"]["max_per_page"] # maximum buttom per page
+ show_invite = configs["configs"]["show_invite_link"] # should or not show active chat invite link
+
+ show_invite = (False if pm_file_chat == True else show_invite) # turn show_invite to False if pm_file_chat is True
+
+ filters = await db.get_filters(group_id, query)
+
+ if filters:
+ for filter in filters: # iterating through each files
+ file_name = filter.get("file_name")
+ file_type = filter.get("file_type")
+ file_link = filter.get("file_link")
+ file_size = int(filter.get("file_size", "0"))
+
+ # from B to MiB
+
+ if file_size < 1024:
+ file_size = f"[{file_size} B]"
+ elif file_size < (1024**2):
+ file_size = f"[{str(round(file_size/1024, 2))} KiB] "
+ elif file_size < (1024**3):
+ file_size = f"[{str(round(file_size/(1024**2), 2))} MiB] "
+ elif file_size < (1024**4):
+ file_size = f"[{str(round(file_size/(1024**3), 2))} GiB] "
+
+
+ file_size = "" if file_size == ("[0 B]") else file_size
+
+ # add emoji down below inside " " if you want..
+ button_text = f"{file_size}{file_name}"
+
+
+ if file_type == "video":
+ if allow_video:
+ pass
+ else:
+ continue
+
+ elif file_type == "audio":
+ if allow_audio:
+ pass
+ else:
+ continue
+
+ elif file_type == "document":
+ if allow_document:
+ pass
+ else:
+ continue
+
+ if len(results) >= max_results:
+ break
+
+ if pm_file_chat:
+ unique_id = filter.get("unique_id")
+ if not FIND.get("bot_details"):
+ try:
+ bot_= await bot.get_me()
+ FIND["bot_details"] = bot_
+ except FloodWait as e:
+ asyncio.sleep(e.x)
+ bot_= await bot.get_me()
+ FIND["bot_details"] = bot_
+
+ bot_ = FIND.get("bot_details")
+ file_link = f"https://t.me/{bot_.username}?start={unique_id}"
+
+ results.append(
+ [
+ InlineKeyboardButton(button_text, url=file_link)
+ ]
+ )
+
+ else:
+ return # return if no files found for that query
+
+
+ if len(results) == 0: # double check
+ return
+
+ else:
+
+ result = []
+ # seperating total files into chunks to make as seperate pages
+ result += [results[i * max_per_page :(i + 1) * max_per_page ] for i in range((len(results) + max_per_page - 1) // max_per_page )]
+ len_result = len(result)
+ len_results = len(results)
+ results = None # Free Up Memory
+
+ FIND[query] = {"results": result, "total_len": len_results, "max_pages": max_pages} # TrojanzHex's Idea Of Dicts😅
+
+ # Add next buttin if page count is not equal to 1
+ if len_result != 1:
+ result[0].append(
+ [
+ InlineKeyboardButton("Next ⏩", callback_data=f"navigate(0|next|{query})")
+ ]
+ )
+
+ # Just A Decaration
+ result[0].append([
+ InlineKeyboardButton(f"🔰 Page 1/{len_result if len_result < max_pages else max_pages} 🔰", callback_data="ignore")
+ ])
+
+
+ # if show_invite is True Append invite link buttons
+ if show_invite:
+
+ ibuttons = []
+ achatId = []
+ await gen_invite_links(configs, group_id, bot, update)
+
+ for x in achats["chats"] if isinstance(achats, dict) else achats:
+ achatId.append(int(x["chat_id"])) if isinstance(x, dict) else achatId.append(x)
+
+ ACTIVE_CHATS[str(group_id)] = achatId
+
+ for y in INVITE_LINK.get(str(group_id)):
+
+ chat_id = int(y["chat_id"])
+
+ if chat_id not in achatId:
+ continue
+
+ chat_name = y["chat_name"]
+ invite_link = y["invite_link"]
+
+ if ((len(ibuttons)%2) == 0):
+ ibuttons.append(
+ [
+ InlineKeyboardButton(f"⚜ {chat_name} ⚜", url=invite_link)
+ ]
+ )
+
+ else:
+ ibuttons[-1].append(
+ InlineKeyboardButton(f"⚜ {chat_name} ⚜", url=invite_link)
+ )
+
+ for x in ibuttons:
+ result[0].insert(0, x) #Insert invite link buttons at first of page
+
+ ibuttons = None # Free Up Memory...
+ achatId = None
+
+
+ reply_markup = InlineKeyboardMarkup(result[0])
+
+ try:
+ await bot.send_message(
+ chat_id = update.chat.id,
+ text=f"Found {(len_results)} Results For Your Query: {query}",
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
+
+ except ButtonDataInvalid:
+ print(result[0])
+
+ except Exception as e:
+ print(e)
+
+
+async def gen_invite_links(db, group_id, bot, update):
+ """
+ A Funtion To Generate Invite Links For All Active
+ Connected Chats In A Group
+ """
+ chats = db.get("chat_ids")
+ global INVITE_LINK
+
+ if INVITE_LINK.get(str(group_id)):
+ return
+
+ Links = []
+ if chats:
+ for x in chats:
+ Name = x["chat_name"]
+
+ if Name == None:
+ continue
+
+ chatId=int(x["chat_id"])
+
+ Link = await bot.export_chat_invite_link(chatId)
+ Links.append({"chat_id": chatId, "chat_name": Name, "invite_link": Link})
+
+ INVITE_LINK[str(group_id)] = Links
+ return
+
+
+async def recacher(group_id, ReCacheInvite=True, ReCacheActive=False, bot=DonLee_Robot, update=Message):
+ """
+ A Funtion To rechase invite links and active chats of a specific chat
+ """
+ global INVITE_LINK, ACTIVE_CHATS
+
+ if ReCacheInvite:
+ if INVITE_LINK.get(str(group_id)):
+ INVITE_LINK.pop(str(group_id))
+
+ Links = []
+ chats = await db.find_chat(group_id)
+ chats = chats["chat_ids"]
+
+ if chats:
+ for x in chats:
+ Name = x["chat_name"]
+ chat_id = x["chat_id"]
+ if (Name == None or chat_id == None):
+ continue
+
+ chat_id = int(chat_id)
+
+ Link = await bot.export_chat_invite_link(chat_id)
+ Links.append({"chat_id": chat_id, "chat_name": Name, "invite_link": Link})
+
+ INVITE_LINK[str(group_id)] = Links
+
+ if ReCacheActive:
+
+ if ACTIVE_CHATS.get(str(group_id)):
+ ACTIVE_CHATS.pop(str(group_id))
+
+ achats = await db.find_active(group_id)
+ achatId = []
+ if achats:
+ for x in achats["chats"]:
+ achatId.append(int(x["chat_id"]))
+
+ ACTIVE_CHATS[str(group_id)] = achatId
+ return
+
From c3d7ad9b6afec57ae198e145eb72a388879579ba Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 10:40:54 +0530
Subject: [PATCH 34/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Settings.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/DonLee_Robot/Plugins/Settings.py b/DonLee_Robot/Plugins/Settings.py
index 189c21b10..35830c3d3 100644
--- a/DonLee_Robot/Plugins/Settings.py
+++ b/DonLee_Robot/Plugins/Settings.py
@@ -1,7 +1,7 @@
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) @AlbertEinsteinTG
-# (c) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
# Copyright permission under MIT License
# All rights reserved by PR0FESS0R-99
# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
@@ -9,7 +9,7 @@
import re
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-from DonLee_Robot import DonLee_Robot
+from DonLee_Robot.donlee_Robot import DonLee_Robot
from DonLee_Robot import VERIFY # pylint: disable=import-error
@DonLee_Robot.on_message(filters.command(["settings"]) & filters.group, group=1)
From d1448cfbe1de6ad41ceec1536df298955971a073 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 10:49:03 +0530
Subject: [PATCH 35/77] Delete bot directory
---
bot/__init__.py | 45 -
bot/__main__.py | 8 -
bot/bot.py | 40 -
bot/database/__init__.py | 1 -
bot/database/database.py | 498 -----------
bot/plugins/auto_filter.py | 288 ------
bot/plugins/callback.py | 1710 ------------------------------------
bot/plugins/channel.py | 358 --------
bot/plugins/commands.py | 106 ---
bot/plugins/settings.py | 107 ---
bot/translation.py | 58 --
bot/user.py | 28 -
12 files changed, 3247 deletions(-)
delete mode 100644 bot/__init__.py
delete mode 100644 bot/__main__.py
delete mode 100644 bot/bot.py
delete mode 100644 bot/database/__init__.py
delete mode 100644 bot/database/database.py
delete mode 100644 bot/plugins/auto_filter.py
delete mode 100644 bot/plugins/callback.py
delete mode 100644 bot/plugins/channel.py
delete mode 100644 bot/plugins/commands.py
delete mode 100644 bot/plugins/settings.py
delete mode 100644 bot/translation.py
delete mode 100644 bot/user.py
diff --git a/bot/__init__.py b/bot/__init__.py
deleted file mode 100644
index 23d2a30c8..000000000
--- a/bot/__init__.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-
-import os
-import logging
-import time
-
-from logging.handlers import RotatingFileHandler
-
-from .translation import Translation
-
-# Change Accordingly While Deploying To A VPS
-APP_ID = int(os.environ.get("APP_ID"))
-
-API_HASH = os.environ.get("API_HASH")
-
-BOT_TOKEN = os.environ.get("BOT_TOKEN")
-
-DB_URI = os.environ.get("DB_URI")
-
-USER_SESSION = os.environ.get("USER_SESSION")
-
-VERIFY = {}
-
-logging.basicConfig(
- level=logging.INFO,
- format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",
- datefmt='%d-%b-%y %H:%M:%S',
- handlers=[
- RotatingFileHandler(
- "autofilterbot.txt",
- maxBytes=50000000,
- backupCount=10
- ),
- logging.StreamHandler()
- ]
-)
-logging.getLogger("pyrogram").setLevel(logging.WARNING)
-
-start_uptime = time.time()
-
-
-def LOGGER(name: str) -> logging.Logger:
- return logging.getLogger(name)
diff --git a/bot/__main__.py b/bot/__main__.py
deleted file mode 100644
index 576ddf439..000000000
--- a/bot/__main__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-
-from .bot import Bot
-
-app = Bot()
-app.run()
\ No newline at end of file
diff --git a/bot/bot.py b/bot/bot.py
deleted file mode 100644
index f6541e22d..000000000
--- a/bot/bot.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @SpEcHIDe
-
-from pyrogram import Client, __version__
-
-from . import API_HASH, APP_ID, LOGGER, BOT_TOKEN
-
-from .user import User
-
-class Bot(Client):
- USER: User = None
- USER_ID: int = None
-
- def __init__(self):
- super().__init__(
- "bot",
- api_hash=API_HASH,
- api_id=APP_ID,
- plugins={
- "root": "bot/plugins"
- },
- workers=200,
- bot_token=BOT_TOKEN,
- sleep_threshold=10
- )
- self.LOGGER = LOGGER
-
- async def start(self):
- await super().start()
- bot_details = await self.get_me()
- self.set_parse_mode("html")
- self.LOGGER(__name__).info(
- f"@{bot_details.username} started! "
- )
- self.USER, self.USER_ID = await User().start()
-
- async def stop(self, *args):
- await super().stop()
- self.LOGGER(__name__).info("Bot stopped. Bye.")
diff --git a/bot/database/__init__.py b/bot/database/__init__.py
deleted file mode 100644
index ef3f969bc..000000000
--- a/bot/database/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from .database import Database
diff --git a/bot/database/database.py b/bot/database/database.py
deleted file mode 100644
index 54752e9c8..000000000
--- a/bot/database/database.py
+++ /dev/null
@@ -1,498 +0,0 @@
-import os
-import motor.motor_asyncio # pylint: disable=import-error
-from bot import DB_URI
-
-DB_NAME = os.environ.get("DB_NAME", "Adv_Auto_Filter")
-
-class Database:
-
- def __init__(self):
- self._client = motor.motor_asyncio.AsyncIOMotorClient(DB_URI)
- self.db = self._client[DB_NAME]
- self.col = self.db["Main"]
- self.acol = self.db["Active_Chats"]
- self.fcol = self.db["Filter_Collection"]
-
- self.cache = {}
- self.acache = {}
-
-
- async def create_index(self):
- """
- Create text index if not in db
- """
- await self.fcol.create_index([("file_name", "text")])
-
-
- def new_chat(self, group_id, channel_id, channel_name):
- """
- Create a document in db if the chat is new
- """
- try:
- group_id, channel_id = int(group_id), int(channel_id)
- except:
- pass
-
- return dict(
- _id = group_id,
- chat_ids = [{
- "chat_id": channel_id,
- "chat_name": channel_name
- }],
- types = dict(
- audio=False,
- document=True,
- video=True
- ),
- configs = dict(
- accuracy=0.80,
- max_pages=5,
- max_results=50,
- max_per_page=10,
- pm_fchat=True,
- show_invite_link=True
- )
- )
-
-
- async def status(self, group_id: int):
- """
- Get the total filters, total connected
- chats and total active chats of a chat
- """
- group_id = int(group_id)
-
- total_filter = await self.tf_count(group_id)
-
- chats = await self.find_chat(group_id)
- chats = chats.get("chat_ids")
- total_chats = len(chats) if chats is not None else 0
-
- achats = await self.find_active(group_id)
- if achats not in (None, False):
- achats = achats.get("chats")
- if achats == None:
- achats = []
- else:
- achats = []
- total_achats = len(achats)
-
- return total_filter, total_chats, total_achats
-
-
- async def find_group_id(self, channel_id: int):
- """
- Find all group id which is connected to a channel
- for add a new files to db
- """
- data = self.col.find({})
- group_list = []
-
- for group_id in await data.to_list(length=50): # No Need Of Even 50
- for y in group_id["chat_ids"]:
- if int(y["chat_id"]) == int(channel_id):
- group_list.append(group_id["_id"])
- else:
- continue
- return group_list
-
- # Related TO Finding Channel(s)
- async def find_chat(self, group_id: int):
- """
- A funtion to fetch a group's settings
- """
- connections = self.cache.get(str(group_id))
-
- if connections is not None:
- return connections
-
- connections = await self.col.find_one({'_id': group_id})
-
- if connections:
- self.cache[str(group_id)] = connections
-
- return connections
- else:
- return self.new_chat(None, None, None)
-
-
- async def add_chat(self, group_id: int, channel_id: int, channel_name):
- """
- A funtion to add/update a chat document when a new chat is connected
- """
- new = self.new_chat(group_id, channel_id, channel_name)
- update_d = {"$push" : {"chat_ids" : {"chat_id": channel_id, "chat_name" : channel_name}}}
- prev = await self.col.find_one({'_id':group_id})
-
- if prev:
- await self.col.update_one({'_id':group_id}, update_d)
- await self.update_active(group_id, channel_id, channel_name)
- await self.refresh_cache(group_id)
-
- return True
-
- self.cache[str(group_id)] = new
-
- await self.col.insert_one(new)
- await self.add_active(group_id, channel_id, channel_name)
- await self.refresh_cache(group_id)
-
- return True
-
-
- async def del_chat(self, group_id: int, channel_id: int):
- """
- A Funtion to delete a channel and its files from db of a chat connection
- """
- group_id, channel_id = int(group_id), int(channel_id) # group_id and channel_id Didnt type casted to int for some reason
-
- prev = self.col.find_one({"_id": group_id})
-
- if prev:
-
- await self.col.update_one(
- {"_id": group_id},
- {"$pull" :
- {"chat_ids" :
- {"chat_id":
- channel_id
- }
- }
- },
- False,
- True
- )
-
- await self.del_active(group_id, channel_id)
- await self.refresh_cache(group_id)
-
- return True
-
- return False
-
-
- async def in_db(self, group_id: int, channel_id: int):
- """
- Check whether if the given channel id is in db or not...
- """
- connections = self.cache.get(group_id)
-
- if connections is None:
- connections = await self.col.find_one({'_id': group_id})
-
- check_list = []
-
- if connections:
- for x in connections["chat_ids"]:
- check_list.append(int(x.get("chat_id")))
-
- if int(channel_id) in check_list:
- return True
-
- return False
-
-
- async def update_settings(self, group_id: int, settings):
- """
- A Funtion to update a chat's filter types in db
- """
- group_id = int(group_id)
- prev = await self.col.find_one({"_id": group_id})
-
- if prev:
- try:
- await self.col.update_one({"_id": group_id}, {"$set": {"types": settings}})
- await self.refresh_cache(group_id)
- return True
-
- except Exception as e:
- print (e)
- return False
- print("You Should First Connect To A Chat To Use This Funtion..... 'databse.py/#201' ")
- return False
-
-
- async def update_configs(self, group_id: int, configs):
- """
- A Funtion to update a chat's configs in db
- """
- prev = await self.col.find_one({"_id": group_id})
-
- if prev:
- try:
- await self.col.update_one(prev, {"$set":{"configs": configs}})
- await self.refresh_cache(group_id)
- return True
-
- except Exception as e:
- print (e)
- return False
- print("You Should First Connect To A Chat To Use This")
- return False
-
-
- async def delete_all(self, group_id: int):
- """
- A Funtion to delete all documents related to a
- chat from db
- """
- prev = await self.col.find_one({"_id": group_id})
- if prev:
- await self.delall_active(group_id)
- await self.delall_filters(group_id)
- await self.del_main(group_id)
- await self.refresh_cache(group_id)
-
- return
-
-
- async def del_main(self, group_id: int):
- """
- A Funtion To Delete the chat's main db document
- """
- await self.col.delete_one({"_id": group_id})
- await self.refresh_cache(group_id)
-
- return True
-
-
- async def refresh_cache(self, group_id: int):
- """
- A Funtion to refresh a chat's chase data
- in case of update in db
- """
- if self.cache.get(str(group_id)):
- self.cache.pop(str(group_id))
-
- prev = await self.col.find_one({"_id": group_id})
-
- if prev:
- self.cache[str(group_id)] = prev
- return True
-
- # Related To Finding Active Channel(s)
- async def add_active(self, group_id: int, channel_id: int, channel_name):
- """
- A Funtion to add a channel as an active chat the a connected group
- (This Funtion will be used only if its the first time)
- """
- templ = {"_id": group_id, "chats":[{"chat_id": channel_id, "chat_name": channel_name}]}
-
- try:
- await self.acol.insert_one(templ)
- await self.refresh_acache(group_id)
- except Exception as e:
- print(e)
- return False
-
- return True
-
-
- async def del_active(self, group_id: int, channel_id: int):
- """
- A funtion to delete a channel from active chat colletion in db
- """
- templ = {"$pull": {"chats": dict(chat_id = channel_id)}}
-
- try:
- await self.acol.update_one({"_id": group_id}, templ, False, True)
- except Exception as e:
- print(e)
- pass
-
- await self.refresh_acache(group_id)
- return True
-
-
- async def update_active(self, group_id: int, channel_id: int, channel_name):
- """
- A Funtion to add a new active chat to the connected group
- """
- group_id, channel_id = int(group_id), int(channel_id)
-
- prev = await self.acol.find_one({"_id": group_id})
- templ = {"$push" : {"chats" : dict(chat_id = channel_id, chat_name = channel_name)}}
- in_c = await self.in_active(group_id, channel_id)
-
- if prev:
- if not in_c:
- await self.acol.update_one({"_id": group_id}, templ)
- else:
- return False
- else:
- await self.add_active(group_id, channel_id, channel_name)
- return True
-
-
- async def find_active(self, group_id: int):
- """
- A Funtion to find all active chats of
- a group from db
- """
- if self.acache.get(str(group_id)):
- self.acache.get(str(group_id))
-
- connection = await self.acol.find_one({"_id": group_id})
-
- if connection:
- return connection
- return False
-
-
- async def in_active(self, group_id: int, channel_id: int):
- """
- A Funtion to check if a chat id is in the active
- chat id list in db
- """
- prev = await self.acol.find_one({"_id": group_id})
-
- if prev:
- for x in prev["chats"]:
- if x["chat_id"] == channel_id:
- return True
-
- return False
-
- return False
-
-
- async def delall_active(self, group_id: int):
- """
- A Funtion to Delete all active chats of
- a group from db
- """
- await self.acol.delete_one({"_id":int(group_id)})
- await self.refresh_acache(group_id)
- return
-
-
- async def refresh_acache(self, group_id: int):
- """
- A Funtion to refresh a active chat's chase data
- in case of update in db
- """
- if self.acache.get(str(group_id)):
- self.acache.pop(str(group_id))
-
- prev = await self.acol.find_one({"_id": group_id})
-
- if prev:
- self.acache[str(group_id)] = prev
- return True
-
- # Related To Finding Filter(s)
- async def add_filters(self, data):
- """
- A Funtion to add document as
- a bulk to db
- """
- try:
- await self.fcol.insert_many(data)
- except Exception as e:
- print(e)
-
- return True
-
-
- async def del_filters(self, group_id: int, channel_id: int):
- """
- A Funtion to delete all filters of a specific
- chat and group from db
- """
- group_id, channel_id = int(group_id), int(channel_id)
-
- try:
- await self.fcol.delete_many({"chat_id": channel_id, "group_id": group_id})
- print(await self.cf_count(group_id, channel_id))
- return True
- except Exception as e:
- print(e)
- return False
-
-
- async def delall_filters(self, group_id: int):
- """
- A Funtion To delete all filters of a group
- """
- await self.fcol.delete_many({"group_id": int(group_id)})
- return True
-
-
- async def get_filters(self, group_id: int, keyword: str):
- """
- A Funtion to fetch all similar results for a keyowrd
- from using text index
- """
- await self.create_index()
-
- chat = await self.find_chat(group_id)
- chat_accuracy = float(chat["configs"].get("accuracy", 0.80))
- achats = await self.find_active(group_id)
-
- achat_ids=[]
- if not achats:
- return False
-
- for chats in achats["chats"]:
- achat_ids.append(chats.get("chat_id"))
-
- filters = []
-
- pipeline= {
- 'group_id': int(group_id), '$text':{'$search': keyword}
- }
-
-
- db_list = self.fcol.find(
- pipeline,
- {'score': {'$meta':'textScore'}} # Makes A New Filed With Match Score In Each Document
- )
-
- db_list.sort([("score", {'$meta': 'textScore'})]) # Sort all document on the basics of the score field
-
- for document in await db_list.to_list(length=600):
- if document["score"] < chat_accuracy:
- continue
-
- if document["chat_id"] in achat_ids:
- filters.append(document)
- else:
- continue
-
- return filters
-
-
- async def get_file(self, unique_id: str):
- """
- A Funtion to get a specific files using its
- unique id
- """
- file = await self.fcol.find_one({"unique_id": unique_id})
- file_id = None
- file_type = None
- file_name = None
- file_caption = None
-
- if file:
- file_id = file.get("file_id")
- file_name = file.get("file_name")
- file_type = file.get("file_type")
- file_caption = file.get("file_caption")
- return file_id, file_name, file_caption, file_type
-
-
- async def cf_count(self, group_id: int, channel_id: int):
- """
- A Funtion To count number of filter in channel
- w.r.t the connect group
- """
- return await self.fcol.count_documents({"chat_id": channel_id, "group_id": group_id})
-
-
- async def tf_count(self, group_id: int):
- """
- A Funtion to count total filters of a group
- """
- return await self.fcol.count_documents({"group_id": group_id})
-
-
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
deleted file mode 100644
index 76d06ef6d..000000000
--- a/bot/plugins/auto_filter.py
+++ /dev/null
@@ -1,288 +0,0 @@
-import re
-import logging
-import asyncio
-
-from pyrogram import Client, filters
-from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
-from pyrogram.errors import ButtonDataInvalid, FloodWait
-
-from bot.database import Database # pylint: disable=import-error
-from bot.bot import Bot # pylint: disable=import-error
-
-
-FIND = {}
-INVITE_LINK = {}
-ACTIVE_CHATS = {}
-db = Database()
-
-@Bot.on_message(filters.text & filters.group & ~filters.bot, group=0)
-async def auto_filter(bot, update):
- """
- A Funtion To Handle Incoming Text And Reply With Appropriate Results
- """
- group_id = update.chat.id
-
- if re.findall(r"((^\/|^,|^\.|^[\U0001F600-\U000E007F]).*)", update.text):
- return
-
- if ("https://" or "http://") in update.text:
- return
-
- query = re.sub(r"[1-2]\d{3}", "", update.text) # Targetting Only 1000 - 2999 😁
-
- if len(query) < 2:
- return
-
- results = []
-
- global ACTIVE_CHATS
- global FIND
-
- configs = await db.find_chat(group_id)
- achats = ACTIVE_CHATS[str(group_id)] if ACTIVE_CHATS.get(str(group_id)) else await db.find_active(group_id)
- ACTIVE_CHATS[str(group_id)] = achats
-
- if not configs:
- return
-
- allow_video = configs["types"]["video"]
- allow_audio = configs["types"]["audio"]
- allow_document = configs["types"]["document"]
-
- max_pages = configs["configs"]["max_pages"] # maximum page result of a query
- pm_file_chat = configs["configs"]["pm_fchat"] # should file to be send from bot pm to user
- max_results = configs["configs"]["max_results"] # maximum total result of a query
- max_per_page = configs["configs"]["max_per_page"] # maximum buttom per page
- show_invite = configs["configs"]["show_invite_link"] # should or not show active chat invite link
-
- show_invite = (False if pm_file_chat == True else show_invite) # turn show_invite to False if pm_file_chat is True
-
- filters = await db.get_filters(group_id, query)
-
- if filters:
- for filter in filters: # iterating through each files
- file_name = filter.get("file_name")
- file_type = filter.get("file_type")
- file_link = filter.get("file_link")
- file_size = int(filter.get("file_size", "0"))
-
- # from B to MiB
-
- if file_size < 1024:
- file_size = f"[{file_size} B]"
- elif file_size < (1024**2):
- file_size = f"[{str(round(file_size/1024, 2))} KiB] "
- elif file_size < (1024**3):
- file_size = f"[{str(round(file_size/(1024**2), 2))} MiB] "
- elif file_size < (1024**4):
- file_size = f"[{str(round(file_size/(1024**3), 2))} GiB] "
-
-
- file_size = "" if file_size == ("[0 B]") else file_size
-
- # add emoji down below inside " " if you want..
- button_text = f"{file_size}{file_name}"
-
-
- if file_type == "video":
- if allow_video:
- pass
- else:
- continue
-
- elif file_type == "audio":
- if allow_audio:
- pass
- else:
- continue
-
- elif file_type == "document":
- if allow_document:
- pass
- else:
- continue
-
- if len(results) >= max_results:
- break
-
- if pm_file_chat:
- unique_id = filter.get("unique_id")
- if not FIND.get("bot_details"):
- try:
- bot_= await bot.get_me()
- FIND["bot_details"] = bot_
- except FloodWait as e:
- asyncio.sleep(e.x)
- bot_= await bot.get_me()
- FIND["bot_details"] = bot_
-
- bot_ = FIND.get("bot_details")
- file_link = f"https://t.me/{bot_.username}?start={unique_id}"
-
- results.append(
- [
- InlineKeyboardButton(button_text, url=file_link)
- ]
- )
-
- else:
- return # return if no files found for that query
-
-
- if len(results) == 0: # double check
- return
-
- else:
-
- result = []
- # seperating total files into chunks to make as seperate pages
- result += [results[i * max_per_page :(i + 1) * max_per_page ] for i in range((len(results) + max_per_page - 1) // max_per_page )]
- len_result = len(result)
- len_results = len(results)
- results = None # Free Up Memory
-
- FIND[query] = {"results": result, "total_len": len_results, "max_pages": max_pages} # TrojanzHex's Idea Of Dicts😅
-
- # Add next buttin if page count is not equal to 1
- if len_result != 1:
- result[0].append(
- [
- InlineKeyboardButton("Next ⏩", callback_data=f"navigate(0|next|{query})")
- ]
- )
-
- # Just A Decaration
- result[0].append([
- InlineKeyboardButton(f"🔰 Page 1/{len_result if len_result < max_pages else max_pages} 🔰", callback_data="ignore")
- ])
-
-
- # if show_invite is True Append invite link buttons
- if show_invite:
-
- ibuttons = []
- achatId = []
- await gen_invite_links(configs, group_id, bot, update)
-
- for x in achats["chats"] if isinstance(achats, dict) else achats:
- achatId.append(int(x["chat_id"])) if isinstance(x, dict) else achatId.append(x)
-
- ACTIVE_CHATS[str(group_id)] = achatId
-
- for y in INVITE_LINK.get(str(group_id)):
-
- chat_id = int(y["chat_id"])
-
- if chat_id not in achatId:
- continue
-
- chat_name = y["chat_name"]
- invite_link = y["invite_link"]
-
- if ((len(ibuttons)%2) == 0):
- ibuttons.append(
- [
- InlineKeyboardButton(f"⚜ {chat_name} ⚜", url=invite_link)
- ]
- )
-
- else:
- ibuttons[-1].append(
- InlineKeyboardButton(f"⚜ {chat_name} ⚜", url=invite_link)
- )
-
- for x in ibuttons:
- result[0].insert(0, x) #Insert invite link buttons at first of page
-
- ibuttons = None # Free Up Memory...
- achatId = None
-
-
- reply_markup = InlineKeyboardMarkup(result[0])
-
- try:
- await bot.send_message(
- chat_id = update.chat.id,
- text=f"Found {(len_results)} Results For Your Query: {query}",
- reply_markup=reply_markup,
- parse_mode="html",
- reply_to_message_id=update.message_id
- )
-
- except ButtonDataInvalid:
- print(result[0])
-
- except Exception as e:
- print(e)
-
-
-async def gen_invite_links(db, group_id, bot, update):
- """
- A Funtion To Generate Invite Links For All Active
- Connected Chats In A Group
- """
- chats = db.get("chat_ids")
- global INVITE_LINK
-
- if INVITE_LINK.get(str(group_id)):
- return
-
- Links = []
- if chats:
- for x in chats:
- Name = x["chat_name"]
-
- if Name == None:
- continue
-
- chatId=int(x["chat_id"])
-
- Link = await bot.export_chat_invite_link(chatId)
- Links.append({"chat_id": chatId, "chat_name": Name, "invite_link": Link})
-
- INVITE_LINK[str(group_id)] = Links
- return
-
-
-async def recacher(group_id, ReCacheInvite=True, ReCacheActive=False, bot=Bot, update=Message):
- """
- A Funtion To rechase invite links and active chats of a specific chat
- """
- global INVITE_LINK, ACTIVE_CHATS
-
- if ReCacheInvite:
- if INVITE_LINK.get(str(group_id)):
- INVITE_LINK.pop(str(group_id))
-
- Links = []
- chats = await db.find_chat(group_id)
- chats = chats["chat_ids"]
-
- if chats:
- for x in chats:
- Name = x["chat_name"]
- chat_id = x["chat_id"]
- if (Name == None or chat_id == None):
- continue
-
- chat_id = int(chat_id)
-
- Link = await bot.export_chat_invite_link(chat_id)
- Links.append({"chat_id": chat_id, "chat_name": Name, "invite_link": Link})
-
- INVITE_LINK[str(group_id)] = Links
-
- if ReCacheActive:
-
- if ACTIVE_CHATS.get(str(group_id)):
- ACTIVE_CHATS.pop(str(group_id))
-
- achats = await db.find_active(group_id)
- achatId = []
- if achats:
- for x in achats["chats"]:
- achatId.append(int(x["chat_id"]))
-
- ACTIVE_CHATS[str(group_id)] = achatId
- return
-
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
deleted file mode 100644
index ffb301fdd..000000000
--- a/bot/plugins/callback.py
+++ /dev/null
@@ -1,1710 +0,0 @@
-import re
-import time
-import asyncio
-
-from pyrogram import Client, filters
-from pyrogram.errors import FloodWait, UserNotParticipant
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
-
-from bot import start_uptime, Translation, VERIFY # pylint: disable=import-error
-from bot.plugins.auto_filter import ( # pylint: disable=import-error
- FIND,
- INVITE_LINK,
- ACTIVE_CHATS,
- recacher,
- gen_invite_links
- )
-from bot.plugins.settings import( # pylint: disable=import-error
- remove_emoji
-)
-from bot.database import Database # pylint: disable=import-error
-
-db = Database()
-
-
-@Client.on_callback_query(filters.regex(r"navigate\((.+)\)"), group=2)
-async def cb_navg(bot, update: CallbackQuery):
- """
- A Callback Funtion For The Next Button Appearing In Results
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- index_val, btn, query = re.findall(r"navigate\((.+)\)", query_data)[0].split("|", 2)
- try:
- ruser_id = update.message.reply_to_message.from_user.id
- except Exception as e:
- print(e)
- ruser_id = None
-
- admin_list = VERIFY.get(str(chat_id))
- if admin_list == None: # Make Admin's ID List
-
- admin_list = []
-
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
-
- admin_list.append(None) # Just For Anonymous Admin....
- VERIFY[str(chat_id)] = admin_list
-
- if not ((user_id == ruser_id) or (user_id in admin_list)): # Checks if user is same as requested user or is admin
- await update.answer("Nice Try ;)",show_alert=True)
- return
-
-
- if btn == "next":
- index_val = int(index_val) + 1
- elif btn == "back":
- index_val = int(index_val) - 1
-
- achats = ACTIVE_CHATS[str(chat_id)]
- configs = await db.find_chat(chat_id)
- pm_file_chat = configs["configs"]["pm_fchat"]
- show_invite = configs["configs"]["show_invite_link"]
- show_invite = (False if pm_file_chat == True else show_invite)
-
- results = FIND.get(query).get("results")
- leng = FIND.get(query).get("total_len")
- max_pages = FIND.get(query).get("max_pages")
-
- try:
- temp_results = results[index_val].copy()
- except IndexError:
- return # Quick Fix🏃🏃
- except Exception as e:
- print(e)
- return
-
- if ((index_val + 1 )== max_pages) or ((index_val + 1) == len(results)): # Max Pages
- temp_results.append([
- InlineKeyboardButton("⏪ Back", callback_data=f"navigate({index_val}|back|{query})")
- ])
-
- elif int(index_val) == 0:
- pass
-
- else:
- temp_results.append([
- InlineKeyboardButton("⏪ Back", callback_data=f"navigate({index_val}|back|{query})"),
- InlineKeyboardButton("Next ⏩", callback_data=f"navigate({index_val}|next|{query})")
- ])
-
- if not int(index_val) == 0:
- temp_results.append([
- InlineKeyboardButton(f"🔰 Page {index_val + 1}/{len(results) if len(results) < max_pages else max_pages} 🔰", callback_data="ignore")
- ])
-
- if show_invite and int(index_val) !=0 :
-
- ibuttons = []
- achatId = []
- await gen_invite_links(configs, chat_id, bot, update)
-
- for x in achats["chats"] if isinstance(achats, dict) else achats:
- achatId.append(int(x["chat_id"])) if isinstance(x, dict) else achatId.append(x)
-
- for y in INVITE_LINK.get(str(chat_id)):
-
- chat_id = int(y["chat_id"])
-
- if chat_id not in achatId:
- continue
-
- chat_name = y["chat_name"]
- invite_link = y["invite_link"]
-
- if ((len(ibuttons)%2) == 0):
- ibuttons.append(
- [
- InlineKeyboardButton
- (
- f"⚜ {chat_name} ⚜", url=invite_link
- )
- ]
- )
-
- else:
- ibuttons[-1].append(
- InlineKeyboardButton
- (
- f"⚜ {chat_name} ⚜", url=invite_link
- )
- )
-
- for x in ibuttons:
- temp_results.insert(0, x)
- ibuttons = None
- achatId = None
-
- reply_markup = InlineKeyboardMarkup(temp_results)
-
- text=f"Found {leng} Results For Your Query: {query}"
-
- try:
- await update.message.edit(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
- except FloodWait as f: # Flood Wait Caused By Spamming Next/Back Buttons
- await asyncio.sleep(f.x)
- await update.message.edit(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"settings"), group=2)
-async def cb_settings(bot, update: CallbackQuery):
- """
- A Callback Funtion For Back Button in /settings Command
- """
- global VERIFY
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)): # Check If User Is Admin
- return
-
- bot_status = await bot.get_me()
- bot_fname= bot_status.first_name
-
- text =f"{bot_fname}'s Settings Pannel.....\n"
- text+=f"\nYou Can Use This Menu To Change Connectivity And Know Status Of Your Every Connected Channel, Change Filter Types, Configure Filter Results And To Know Status Of Your Group..."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "Channels", callback_data=f"channel_list({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Filter Types", callback_data=f"types({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Configure 🛠", callback_data=f"config({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Status", callback_data=f"status({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "About", callback_data=f"about({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"warn\((.+)\)"), group=2)
-async def cb_warn(bot, update: CallbackQuery):
- """
- A Callback Funtion For Acknowledging User's About What Are They Upto
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:35]
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name, action = re.findall(r"warn\((.+)\)", query_data)[0].split("|", 2)
-
- if action == "connect":
- text=f"Are You Sure You Want To Enable Connection With {channel_name}..???\n"
- text+=f"\nThis Will Show File Links From {channel_name} While Showing Results..."
-
- elif action == "disconnect":
- text=f"Are You Sure You Want To Disable {channel_name} Connection With The Group???....\n"
- text+=f"\nThe DB Files Will Still Be There And You Can Connect Back To This Channel Anytime From Settings Menu Without Adding Files To DB Again...\n"
- text+=f"\nThis Disabling Just Hide Results From The Filter Results..."
-
- elif action == "c_delete":
- text=f"Are You Sure You Want To Disconnect {channel_name} From This Group??\n"
- text+=f"\nThis Will Delete Channel And All Its Files From DB Too....!!\n"
- text+=f"\nYou Need To Add Channel Again If You Need To Shows It Result..."
-
-
- elif action=="f_delete":
- text=f"Are You Sure That You Want To Clear All Filter From This Chat {channel_name}???\n"
- text+=f"\nThis Will Erase All Files From DB.."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "Yes", callback_data=f"{action}({channel_id}|{channel_name})"
- ),
-
- InlineKeyboardButton
- (
- "No", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"channel_list\((.+)\)"), group=2)
-async def cb_channel_list(bot, update: CallbackQuery):
- """
- A Callback Funtion For Displaying All Channel List And Providing A Menu To Navigate
- To Every COnnect Chats For Furthur Control
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:35]
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id = re.findall(r"channel_list\((.+)\)", query_data)[0]
-
- text = "Semms Like You Dont Have Any Channel Connected...\n\nConnect To Any Chat To Continue With This Settings..."
-
- db_list = await db.find_chat(int(chat_id))
-
- channel_id_list = []
- channel_name_list = []
-
- if db_list:
- for x in db_list["chat_ids"]:
- channel_id = x["chat_id"]
- channel_name = x["chat_name"]
-
- try:
- if (channel_id == None or channel_name == None):
- continue
- except:
- break
-
- channel_name = remove_emoji(channel_name).encode('ascii', 'ignore').decode('ascii')[:35]
- channel_id_list.append(channel_id)
- channel_name_list.append(channel_name)
-
- buttons = []
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data="settings"
- ),
-
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- )
-
- if channel_name_list:
-
- text=f"List Of Connected Channels With {chat_name} With There Settings..\n"
-
- for x in range(1, (len(channel_name_list)+1)):
- text+=f"\n{x}. {channel_name_list[x-1]}\n"
-
- text += "\nChoose Appropriate Buttons To Navigate Through Respective Channels"
-
-
- btn_key = [
- "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟",
- "1️⃣1️⃣", "1️⃣2️⃣", "1️⃣3️⃣", "1️⃣4️⃣", "1️⃣5️⃣", "1️⃣6️⃣", "1️⃣7️⃣",
- "1️⃣8️⃣", "1️⃣9️⃣", "2️⃣0️⃣" # Just In Case 😂🤣
- ]
-
- for i in range(1, (len(channel_name_list) + 1)): # Append The Index Number of Channel In Just A Single Line
- if i == 1:
- buttons.insert(0,
- [
- InlineKeyboardButton
- (
- btn_key[i-1], callback_data=f"info({channel_id_list[i-1]}|{channel_name_list[i-1]})"
- )
- ]
- )
-
- else:
- buttons[0].append(
- InlineKeyboardButton
- (
- btn_key[i-1], callback_data=f"info({channel_id_list[i-1]}|{channel_name_list[i-1]})"
- )
- )
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text = text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"info\((.+)\)"), group=2)
-async def cb_info(bot, update: CallbackQuery):
- """
- A Callback Funtion For Displaying Details Of The Connected Chat And Provide
- Ability To Connect / Disconnect / Delete / Delete Filters of That Specific Chat
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"info\((.+)\)", query_data)[0].split("|", 1)
-
- f_count = await db.cf_count(chat_id, int(channel_id))
- active_chats = await db.find_active(chat_id)
-
- if active_chats: # Checks for active chats connected to a chat
- dicts = active_chats["chats"]
- db_cids = [ int(x["chat_id"]) for x in dicts ]
-
- if int(channel_id) in db_cids:
- active_chats = True
- status = "Connected"
-
- else:
- active_chats = False
- status = "Disconnected"
-
- else:
- active_chats = False
- status = "Disconnected"
-
- text=f"Info About {channel_name}\n"
- text+=f"\nChannel Name: {channel_name}\n"
- text+=f"\nChannel ID: {channel_id}\n"
- text+=f"\nChannel Files: {f_count}\n"
- text+=f"\nCurrent Status: {status}\n"
-
-
- if active_chats:
- buttons = [
- [
- InlineKeyboardButton
- (
- "🚨 Disconnect 🚨", callback_data=f"warn({channel_id}|{channel_name}|disconnect)"
- ),
-
- InlineKeyboardButton
- (
- "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
- )
- ]
- ]
-
- else:
- buttons = [
- [
- InlineKeyboardButton
- (
- "💠 Connect 💠", callback_data=f"warn({channel_id}|{channel_name}|connect)"
- ),
-
- InlineKeyboardButton
- (
- "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
- )
- ]
- ]
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
- )
- ]
- )
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"channel_list({chat_id})"
- )
- ]
- )
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"^connect\((.+)\)"), group=2)
-async def cb_connect(bot, update: CallbackQuery):
- """
- A Callback Funtion Helping The user To Make A Chat Active Chat Which Will
- Make The Bot To Fetch Results From This Channel Too
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"connect\((.+)\)", query_data)[0].split("|", 1)
- channel_id = int(channel_id)
-
- f_count = await db.cf_count(chat_id, channel_id)
-
- add_active = await db.update_active(chat_id, channel_id, channel_name)
-
- if not add_active:
- await update.answer(f"{channel_name} Is Aldready in Active Connection", show_alert=True)
- return
-
- text= f"Sucessfully Connected To {channel_name}\n"
- text+=f"\nInfo About {channel_name}\n"
- text+=f"\nChannel Name: {channel_name}\n"
- text+=f"\nChannel ID: {channel_id}\n"
- text+=f"\nChannel Files: {f_count}\n"
- text+=f"\nCurrent Status: Connected\n"
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "🚨 Disconnect 🚨", callback_data=f"warn({channel_id}|{channel_name}|disconnect)"
- ),
-
- InlineKeyboardButton
- (
- "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
- )
- ]
- ]
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
- )
- ]
- )
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"channel_list({chat_id})"
- )
- ]
- )
- await recacher(chat_id, False, True, bot, update)
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"disconnect\((.+)\)"), group=2)
-async def cb_disconnect(bot, update: CallbackQuery):
- """
- A Callback Funtion Helping The user To Make A Chat inactive Chat Which Will
- Make The Bot To Avoid Fetching Results From This Channel
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"connect\((.+)\)", query_data)[0].split("|", 1)
-
- f_count = await db.cf_count(chat_id, int(channel_id))
-
- remove_active = await db.del_active(chat_id, int(channel_id))
-
- if not remove_active:
- await update.answer("Couldnt Full Fill YOur Request...\n Report This @CrazyBotszGrp Along With Bot's Log", show_alert=True)
- return
-
- text= f"Sucessfully Disconnected From {channel_name}\n"
- text+=f"\nInfo About {channel_name}\n"
- text+=f"\nChannel Name: {channel_name}\n"
- text+=f"\nChannel ID: {channel_id}\n"
- text+=f"\nChannel Files: {f_count}\n"
- text+=f"\nCurrent Status: Disconnected\n"
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "💠 Connect 💠", callback_data=f"warn({channel_id}|{channel_name}|connect)"
- ),
-
- InlineKeyboardButton
- (
- "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
- )
- ]
- ]
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
- )
- ]
- )
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"channel_list({chat_id})"
- )
- ]
- )
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await recacher(chat_id, False, True, bot, update)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"c_delete\((.+)\)"), group=2)
-async def cb_channel_delete(bot, update: CallbackQuery):
- """
- A Callback Funtion For Delete A Channel Connection From A Group Chat History
- Along With All Its Filter Files
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"c_delete\((.+)\)", query_data)[0].split("|", 1)
- channel_id = int(channel_id)
-
- c_delete = await db.del_chat(chat_id, channel_id)
- a_delete = await db.del_active(chat_id, channel_id) # pylint: disable=unused-variable
- f_delete = await db.del_filters(chat_id, channel_id)
-
- if (c_delete and f_delete ):
- text=f"{channel_name} [ {channel_id} ] Has Been Sucessfully Deleted And All Its Files Were Cleared From DB...."
-
- else:
- text=f"Couldn't Delete Channel And All Its Files From DB Sucessfully....\nPlease Try Again After Sometimes...Also Make Sure To Check The Logs..!!"
- await update.answer(text=text, show_alert=True)
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"channel_list({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- await recacher(chat_id, True, True, bot, update)
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"f_delete\((.+)\)"), group=2)
-async def cb_filters_delete(bot, update: CallbackQuery):
- """
- A Callback Funtion For Delete A Specific Channel's Filters Connected To A Group
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"f_delete\((.+)\)", query_data)[0].split("|", 1)
-
- f_delete = await db.del_filters(chat_id, int(channel_id))
-
- if not f_delete:
- text="Oops..!!\n\nEncountered Some Error While Deleteing Filters....\nPlease Check The Logs...."
- await update.answer(text=text, show_alert=True)
- return
-
- text =f"All Filters Of {channel_id}[{channel_name}] Has Been Deleted Sucessfully From My DB.."
-
- buttons=[
- [
- InlineKeyboardButton
- (
- "Back", callback_data="settings"
- ),
-
- InlineKeyboardButton
- (
- "Close", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"types\((.+)\)"), group=2)
-async def cb_types(bot, update: CallbackQuery):
- """
- A Callback Funtion For Changing The Result Types To Be Shown In While Sending Results
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id = re.findall(r"types\((.+)\)", query_data)[0]
-
- _types = await db.find_chat(int(chat_id))
-
- text=f"Filter Types Enabled/Disbled In {chat_name}\n"
-
- _types = _types["types"]
- vid = _types["video"]
- doc = _types["document"]
- aud = _types["audio"]
-
- buttons = []
-
- if vid:
- text+="\nVideo Index: Enabled\n"
- v_e = "✅"
- vcb_data = f"toggle({chat_id}|video|False)"
-
- else:
- text+="\nVideo Index: Disabled\n"
- v_e="❎"
- vcb_data = f"toggle({chat_id}|video|True)"
-
- if doc:
- text+="\nDocument Index: Enabled\n"
- d_e = "✅"
- dcb_data = f"toggle({chat_id}|document|False)"
-
- else:
- text+="\nDocument Index: Disabled\n"
- d_e="❎"
- dcb_data = f"toggle({chat_id}|document|True)"
-
- if aud:
- text+="\nAudio Index: Enabled\n"
- a_e = "✅"
- acb_data = f"toggle({chat_id}|audio|False)"
-
- else:
- text+="\nAudio Index: Disabled\n"
- a_e="❎"
- acb_data = f"toggle({chat_id}|audio|True)"
-
-
- text+="\nBelow Buttons Will Toggle Respective Media Types As Enabled Or Disabled....\n"
- text+="This Will Take Into Action As Soon As You Change Them...."
-
- buttons.append([InlineKeyboardButton(f"Video Index: {v_e}", callback_data=vcb_data)])
- buttons.append([InlineKeyboardButton(f"Audio Index: {a_e}", callback_data=acb_data)])
- buttons.append([InlineKeyboardButton(f"Document Index: {d_e}", callback_data=dcb_data)])
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"settings"
- )
- ]
- )
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"toggle\((.+)\)"), group=2)
-async def cb_toggle(bot, update: CallbackQuery):
- """
- A Callback Funtion Support handler For types()
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id, types, val = re.findall(r"toggle\((.+)\)", query_data)[0].split("|", 2)
-
- _types = await db.find_chat(int(chat_id))
-
- _types = _types["types"]
- vid = _types["video"]
- doc = _types["document"]
- aud = _types["audio"]
-
- if types == "video":
- vid = True if val=="True" else False
- elif types == "audio":
- aud = True if val=="True" else False
- elif types == "document":
- doc = True if val=="True" else False
-
-
- settings = {
- "video": vid,
- "audio": aud,
- "document": doc
- }
-
- process = await db.update_settings(chat_id, settings)
-
- if process:
- await update.answer(text="Filter Types Updated Sucessfully", show_alert=True)
-
- else:
- text="Something Wrong Please Check Bot Log For More Information...."
- await update.answer(text, show_alert=True)
- return
-
- _types = await db.find_chat(int(chat_id))
-
- text =f"Filter Types Enabled In {update.message.chat.title}\n"
-
- _types = _types["types"]
- vid = _types["video"]
- doc = _types["document"]
- aud = _types["audio"]
-
- buttons = []
-
- if vid:
- text+="\nVideo Index: Enabled\n"
- v_e = "✅"
- vcb_data = f"toggle({chat_id}|video|False)"
-
- else:
- text+="\nVideo Index: Disabled\n"
- v_e="❎"
- vcb_data = f"toggle({chat_id}|video|True)"
-
- if doc:
- text+="\nDocument Index: Enabled\n"
- d_e = "✅"
- dcb_data = f"toggle({chat_id}|document|False)"
-
- else:
- text+="\nDocument Index: Disabled\n"
- d_e="❎"
- dcb_data = f"toggle({chat_id}|document|True)"
-
- if aud:
- text+="\nAudio Index: Enabled\n"
- a_e = "✅"
- acb_data = f"toggle({chat_id}|audio|False)"
-
- else:
- text+="\nAudio Index: Disabled\n"
- a_e="❎"
- acb_data = f"toggle({chat_id}|audio|True)"
-
-
- text+="\nBelow Buttons Will Toggle Respective Media Types As Enabled Or Disabled....\n"
- text+="This Will Take Into Action As Soon As You Change Them...."
-
- buttons.append([InlineKeyboardButton(f"Video Index : {v_e}", callback_data=vcb_data)])
- buttons.append([InlineKeyboardButton(f"Audio Index : {a_e}", callback_data=acb_data)])
- buttons.append([InlineKeyboardButton(f"Document Index : {d_e}", callback_data=dcb_data)])
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"settings"
- )
- ]
- )
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"config\((.+)\)"), group=2)
-async def cb_config(bot, update: CallbackQuery):
- """
- A Callback Funtion For Chaning The Number Of Total Pages /
- Total Results / Results Per pages / Enable or Diable Invite Link /
- Enable or Disable PM File Chat
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id = re.findall(r"config\((.+)\)", query_data)[0]
-
- settings = await db.find_chat(int(chat_id))
-
- mp_count = settings["configs"]["max_pages"]
- mf_count = settings["configs"]["max_results"]
- mr_count = settings["configs"]["max_per_page"]
- show_invite = settings["configs"]["show_invite_link"]
- pm_file_chat = settings["configs"].get("pm_fchat", False)
- accuracy_point = settings["configs"].get("accuracy", 0.80)
-
- text=f"Configure Your {chat_name} Group's Filter Settings...\n"
-
- text+=f"\n{chat_name} Current Settings:\n"
-
- text+=f"\n - Max Filter: {mf_count}\n"
-
- text+=f"\n - Max Pages: {mp_count}\n"
-
- text+=f"\n - Max Filter Per Page: {mr_count}\n"
-
- text+=f"\n - Accuracy Percentage: {accuracy_point}\n"
-
- text+=f"\n - Show Invitation Link: {show_invite}\n"
-
- text+=f"\n - Provide File In Bot PM: {pm_file_chat}\n"
-
- text+="\nAdjust Above Value Using Buttons Below... "
- buttons=[
- [
- InlineKeyboardButton
- (
- "Filter Per Page", callback_data=f"mr_count({mr_count}|{chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Max Pages", callback_data=f"mp_count({mp_count}|{chat_id})"
- )
- ]
- ]
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Total Filter Count", callback_data=f"mf_count({mf_count}|{chat_id})"
- )
- ]
- )
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Show Invite Links", callback_data=f"show_invites({show_invite}|{chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Bot File Chat", callback_data=f"inPM({pm_file_chat}|{chat_id})"
- )
- ]
- )
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Result's Accuracy", callback_data=f"accuracy({accuracy_point}|{chat_id})"
- )
- ]
- )
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"settings"
- )
- ]
- )
-
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"mr_count\((.+)\)"), group=2)
-async def cb_max_buttons(bot, update: CallbackQuery):
- """
- A Callback Funtion For Changing The Count Of Result To Be Shown Per Page
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- count, chat_id = re.findall(r"mr_count\((.+)\)", query_data)[0].split("|", 1)
-
- text = f"Choose Your Desired 'Max Filter Count Per Page' For Every Filter Results Shown In {chat_name}"
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "5 Filters", callback_data=f"set(per_page|5|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "10 Filters", callback_data=f"set(per_page|10|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "15 Filters", callback_data=f"set(per_page|15|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "20 Filters", callback_data=f"set(per_page|20|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "25 Filters", callback_data=f"set(per_page|25|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "30 Filters", callback_data=f"set(per_page|30|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"mp_count\((.+)\)"), group=2)
-async def cb_max_page(bot, update: CallbackQuery):
- """
- A Callback Funtion For Changing The Count Of Maximum Result Pages To Be Shown
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- count, chat_id = re.findall(r"mp_count\((.+)\)", query_data)[0].split("|", 1)
-
- text = f"Choose Your Desired 'Max Filter Page Count' For Every Filter Results Shown In {chat_name}"
-
- buttons = [
-
- [
- InlineKeyboardButton
- (
- "2 Pages", callback_data=f"set(pages|2|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "4 Pages", callback_data=f"set(pages|4|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "6 Pages", callback_data=f"set(pages|6|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "8 Pages", callback_data=f"set(pages|8|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "10 Pages", callback_data=f"set(pages|10|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"config({chat_id})"
- )
- ]
-
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"mf_count\((.+)\)"), group=2)
-async def cb_max_results(bot, update: CallbackQuery):
- """
- A Callback Funtion For Changing The Count Of Maximum Files TO Be Fetched From Database
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- count, chat_id = re.findall(r"mf_count\((.+)\)", query_data)[0].split("|", 1)
-
- text = f"Choose Your Desired 'Max Filter' To Be Fetched From DB For Every Filter Results Shown In {chat_name}"
-
- buttons = [
-
- [
- InlineKeyboardButton
- (
- "50 Results", callback_data=f"set(results|50|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "100 Results", callback_data=f"set(results|100|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "150 Results", callback_data=f"set(results|150|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "200 Results", callback_data=f"set(results|200|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "250 Results", callback_data=f"set(results|250|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "300 Results", callback_data=f"set(results|300|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"show_invites\((.+)\)"), group=2)
-async def cb_show_invites(bot, update: CallbackQuery):
- """
- A Callback Funtion For Enabling Or Diabling Invite Link Buttons
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- value, chat_id = re.findall(r"show_invites\((.+)\)", query_data)[0].split("|", 1)
-
- value = True if value=="True" else False
-
- if value:
- buttons= [
- [
- InlineKeyboardButton
- (
- "Disable ❌", callback_data=f"set(showInv|False|{chat_id}|{value})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- else:
- buttons =[
- [
- InlineKeyboardButton
- (
- "Enable ✔", callback_data=f"set(showInv|True|{chat_id}|{value})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- text=f"This Config Will Help You To Show Invitation Link Of All Active Chats Along With The Filter Results For The Users To Join....."
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"inPM\((.+)\)"), group=2)
-async def cb_pm_file(bot, update: CallbackQuery):
- """
- A Callback Funtion For Enabling Or Diabling File Transfer Through Bot PM
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- value, chat_id = re.findall(r"inPM\((.+)\)", query_data)[0].split("|", 1)
-
- value = True if value=="True" else False
-
- if value:
- buttons= [
- [
- InlineKeyboardButton
- (
- "Disable ❎", callback_data=f"set(inPM|False|{chat_id}|{value})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- else:
- buttons =[
- [
- InlineKeyboardButton
- (
- "Enable ✅", callback_data=f"set(inPM|True|{chat_id}|{value})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- text=f"This Config Will Help You To Enable/Disable File Transfer Through Bot PM Without Redirecting Them To Channel...."
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"accuracy\((.+)\)"), group=2)
-async def cb_accuracy(bot, update: CallbackQuery):
- """
- A Callaback Funtion to control the accuracy of matching results
- that the bot should return for a query....
- """
- global VERIFY
- chat_id = update.message.chat.id
- chat_name = update.message.chat.title
- user_id = update.from_user.id
- query_data = update.data
-
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- val, chat_id = re.findall(r"accuracy\((.+)\)", query_data)[0].split("|", 1)
-
- text = f"Choose Your Desired 'Accuracy Perceentage' For Every Filter Results Shown In {chat_name}\n\n"
- text+= f"NB: Higher The Value Better Matching Results Will Be Provided... And If Value Is Lower It Will Show More Results \
- Which Is Fimilary To Query Search (Wont Be Accurate)...."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "100 %", callback_data=f"set(accuracy|1.00|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "80 %", callback_data=f"set(accuracy|0.80|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "65 %", callback_data=f"set(accuracy|0.65|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "60 %", callback_data=f"set(accuracy|0.60|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "55 %", callback_data=f"set(accuracy|0.55|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "50 %", callback_data=f"set(accuracy|0.50|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"set\((.+)\)"), group=2)
-async def cb_set(bot, update: CallbackQuery):
- """
- A Callback Funtion Support For config()
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- action, val, chat_id, curr_val = re.findall(r"set\((.+)\)", query_data)[0].split("|", 3)
-
- try:
- val, chat_id, curr_val = float(val), int(chat_id), float(curr_val)
- except:
- chat_id = int(chat_id)
-
- if val == curr_val:
- await update.answer("New Value Cannot Be Old Value...Please Choose Different Value...!!!", show_alert=True)
- return
-
- prev = await db.find_chat(chat_id)
-
- accuracy = float(prev["configs"].get("accuracy", 0.80))
- max_pages = int(prev["configs"].get("max_pages"))
- max_results = int(prev["configs"].get("max_results"))
- max_per_page = int(prev["configs"].get("max_per_page"))
- pm_file_chat = True if prev["configs"].get("pm_fchat") == (True or "True") else False
- show_invite_link = True if prev["configs"].get("show_invite_link") == (True or "True") else False
-
- if action == "accuracy": # Scophisticated way 😂🤣
- accuracy = val
-
- elif action == "pages":
- max_pages = int(val)
-
- elif action == "results":
- max_results = int(val)
-
- elif action == "per_page":
- max_per_page = int(val)
-
- elif action =="showInv":
- show_invite_link = True if val=="True" else False
-
- elif action == "inPM":
- pm_file_chat = True if val=="True" else False
-
-
- new = dict(
- accuracy=accuracy,
- max_pages=max_pages,
- max_results=max_results,
- max_per_page=max_per_page,
- pm_fchat=pm_file_chat,
- show_invite_link=show_invite_link
- )
-
- append_db = await db.update_configs(chat_id, new)
-
- if not append_db:
- text="Something Wrong Please Check Bot Log For More Information...."
- await update.answer(text=text, show_alert=True)
- return
-
- text=f"Your Request Was Updated Sucessfully....\nNow All Upcoming Results Will Show According To This Settings..."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"status\((.+)\)"), group=2)
-async def cb_status(bot, update: CallbackQuery):
- """
- A Callback Funtion For Showing Overall Status Of A Group
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id = re.findall(r"status\((.+)\)", query_data)[0]
-
- total_filters, total_chats, total_achats = await db.status(chat_id)
-
- text = f"Status Of {chat_name}\n"
- text += f"\nTotal Connected Chats: {total_chats}\n"
- text += f"\nTotal Active Chats: {total_achats}\n"
- text += f"\nTotal Filters: {total_filters}"
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data="settings"
- ),
-
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"about\((.+)\)"), group=2)
-async def cb_about(bot, update: CallbackQuery):
- """
- A Callback Funtion For Showing About Section In Bot Setting Menu
- """
- global VERIFY
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- text=f"Bot's Status\n"
- text+=f"\nBot's Uptime: {time_formatter(time.time() - start_uptime)}\n"
- text+=f"\nBot Funtion: Auto Filter Files\n"
- text+=f"""\nBot Support: @CrazyBotszGrp\n"""
- text+="""\nSource Code: Source"""
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "My Dev ⚡", url="https://t.me/AlbertEinstein_TG"
- ),
-
- InlineKeyboardButton
- (
- "🔙 Back", callback_data="settings"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@Client.on_callback_query(filters.regex(r"^(start|help|about|close)$"), group=2)
-async def callback_data(bot, update: CallbackQuery):
-
- query_data = update.data
-
- if query_data == "start":
- buttons = [[
- InlineKeyboardButton('My Dev 👨🔬', url='https://t.me/AlbertEinstein_TG'),
- InlineKeyboardButton('Source Code 🧾', url ='https://github.com/CrazyBotsz/Adv-Filter-Bot-V2')
- ],[
- InlineKeyboardButton('Support 🛠', url='https://t.me/CrazyBotszGrp')
- ],[
- InlineKeyboardButton('Help ⚙', callback_data="help")
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- Translation.START_TEXT.format(update.from_user.mention),
- reply_markup=reply_markup,
- parse_mode="html",
- disable_web_page_preview=True
- )
-
-
- elif query_data == "help":
- buttons = [[
- InlineKeyboardButton('Home ⚡', callback_data='start'),
- InlineKeyboardButton('About 🚩', callback_data='about')
- ],[
- InlineKeyboardButton('Close 🔐', callback_data='close')
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- Translation.HELP_TEXT,
- reply_markup=reply_markup,
- parse_mode="html",
- disable_web_page_preview=True
- )
-
-
- elif query_data == "about":
- buttons = [[
- InlineKeyboardButton('Home ⚡', callback_data='start'),
- InlineKeyboardButton('Close 🔐', callback_data='close')
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- Translation.ABOUT_TEXT,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
- elif query_data == "close":
- await update.message.delete()
-
-
-
-def time_formatter(seconds: float) -> str:
- """
- humanize time
- """
- minutes, seconds = divmod(int(seconds),60)
- hours, minutes = divmod(minutes, 60)
- days, hours = divmod(hours, 24)
- tmp = ((str(days) + "d, ") if days else "") + \
- ((str(hours) + "h, ") if hours else "") + \
- ((str(minutes) + "m, ") if minutes else "") + \
- ((str(seconds) + "s") if seconds else "")
- return tmp
-
diff --git a/bot/plugins/channel.py b/bot/plugins/channel.py
deleted file mode 100644
index cc8478c6e..000000000
--- a/bot/plugins/channel.py
+++ /dev/null
@@ -1,358 +0,0 @@
-import random
-import string
-import asyncio
-
-from pyrogram import Client, filters
-from pyrogram.errors import UserAlreadyParticipant, FloodWait
-
-from bot import VERIFY # pylint: disable=import-error
-from bot.bot import Bot # pylint: disable=import-error
-from bot.database import Database # pylint: disable=import-error
-from bot.plugins.auto_filter import recacher # pylint: disable=import-error
-
-db = Database()
-
-@Client.on_message(filters.command(["add"]) & filters.group, group=1)
-async def connect(bot: Bot, update):
- """
- A Funtion To Handle Incoming /add Command TO COnnect A Chat With Group
- """
- chat_id = update.chat.id
- user_id = update.from_user.id if update.from_user else None
- target_chat = update.text.split(None, 1)
- global VERIFY
-
- if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
- admin_list = []
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
- admin_list.append(None)
- VERIFY[str(chat_id)] = admin_list
-
- if not user_id in VERIFY.get(str(chat_id)):
- return
-
- try:
- if target_chat[1].startswith("@"):
- if len(target_chat[1]) < 5:
- await update.reply_text("Invalid Username...!!!")
- return
- target = target_chat[1]
-
- elif not target_chat[1].startswith("@"):
- if len(target_chat[1]) < 14:
- await update.reply_text("Invalid Chat Id...\nChat ID Should Be Something Like This: -100xxxxxxxxxx")
- return
- target = int(target_chat[1])
-
- except Exception:
- await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
- return
-
- try:
- join_link = await bot.export_chat_invite_link(target)
- except Exception as e:
- print(e)
- await update.reply_text(f"Make Sure Im Admin At {target} And Have Permission For 'Inviting Users via Link' And Try Again.....!!!")
- return
-
- userbot_info = await bot.USER.get_me()
- userbot_id = userbot_info.id
- userbot_name = userbot_info.first_name
-
- try:
- await bot.USER.join_chat(join_link)
-
- except UserAlreadyParticipant:
- pass
-
- except Exception:
- await update.reply_text(f"My UserBot [{userbot_name}](tg://user?id={userbot_id}) Couldnt Join The Channel `{target}` Make Sure Userbot Is Not Banned There Or Add It Manually And Try Again....!!")
- return
-
- try:
- c_chat = await bot.get_chat(target)
- channel_id = c_chat.id
- channel_name = c_chat.title
-
- except Exception as e:
- await update.reply_text("Encountered Some Issue..Please Check Logs..!!")
- raise e
-
-
- in_db = await db.in_db(chat_id, channel_id)
-
- if in_db:
- await update.reply_text("Channel Aldready In Db...!!!")
- return
-
- wait_msg = await update.reply_text("Please Wait Till I Add All Your Files From Channel To Db\n\nThis May Take 10 or 15 Mins Depending On Your No. Of Files In Channel.....\n\nUntil Then Please Dont Sent Any Other Command Or This Operation May Be Intrupted....")
-
- try:
- type_list = ["video", "audio", "document"]
- data = []
- skipCT = 0
-
- for typ in type_list:
-
- async for msgs in bot.USER.search_messages(channel_id,filter=typ): #Thanks To @PrgOfficial For Suggesting
-
- # Using 'if elif' instead of 'or' to determine 'file_type'
- # Better Way? Make A PR
- try:
- if msgs.video:
- try:
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except FloodWait as e:
- asyncio.sleep(e.x)
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except Exception as e:
- print(e)
- continue
- file_id = file_id.video.file_id
- file_name = msgs.video.file_name[0:-4]
- file_caption = msgs.caption if msgs.caption else ""
- file_size = msgs.video.file_size
- file_type = "video"
-
- elif msgs.audio:
- try:
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except FloodWait as e:
- asyncio.sleep(e.x)
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except Exception as e:
- print(e)
- continue
- file_id = file_id.audio.file_id
- file_name = msgs.audio.file_name[0:-4]
- file_caption = msgs.caption if msgs.caption else ""
- file_size = msgs.audio.file_size
- file_type = "audio"
-
- elif msgs.document:
- try:
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except FloodWait as e:
- asyncio.sleep(e.x)
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except Exception as e:
- print(str(e))
- continue
- file_id = file_id.document.file_id
- file_name = msgs.document.file_name[0:-4]
- file_caption = msgs.caption if msgs.caption else ""
- file_size = msgs.document.file_size
- file_type = "document"
-
- for i in ["_", "|", "-", "."]: # Work Around
- try:
- file_name = file_name.replace(i, " ")
- except Exception:
- pass
-
- file_link = msgs.link
- group_id = chat_id
- unique_id = ''.join(
- random.choice(
- string.ascii_lowercase +
- string.ascii_uppercase +
- string.digits
- ) for _ in range(15)
- )
-
- dicted = dict(
- file_id=file_id, # Done
- unique_id=unique_id,
- file_name=file_name,
- file_caption=file_caption,
- file_size=file_size,
- file_type=file_type,
- file_link=file_link,
- chat_id=channel_id,
- group_id=group_id,
- )
-
- data.append(dicted)
- except Exception as e:
- if 'NoneType' in str(e): # For Some Unknown Reason Some File Names are NoneType
- skipCT +=1
- continue
- print(e)
-
- print(f"{skipCT} Files Been Skipped Due To File Name Been None..... #BlameTG")
- except Exception as e:
- await wait_msg.edit_text("Couldnt Fetch Files From Channel... Please look Into Logs For More Details")
- raise e
-
- await db.add_filters(data)
- await db.add_chat(chat_id, channel_id, channel_name)
- await recacher(chat_id, True, True, bot, update)
-
- await wait_msg.edit_text(f"Channel Was Sucessfully Added With {len(data)} Files..")
-
-
-@Client.on_message(filters.command(["del"]) & filters.group, group=1)
-async def disconnect(bot: Bot, update):
- """
- A Funtion To Handle Incoming /del Command TO Disconnect A Chat With A Group
- """
- chat_id = update.chat.id
- user_id = update.from_user.id if update.from_user else None
- target_chat = update.text.split(None, 1)
- global VERIFY
-
- if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
- admin_list = []
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
- admin_list.append(None)
- VERIFY[str(chat_id)] = admin_list
-
- if not user_id in VERIFY.get(str(chat_id)):
- return
-
- try:
- if target_chat[1].startswith("@"):
- if len(target_chat[1]) < 5:
- await update.reply_text("Invalid Username...!!!")
- return
- target = target_chat[1]
-
- elif not target_chat.startswith("@"):
- if len(target_chat[1]) < 14:
- await update.reply_text("Invalid Chat Id...\nChat ID Should Be Something Like This: -100xxxxxxxxxx")
- return
- target = int(target_chat[1])
-
- except Exception:
- await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
- return
-
- userbot = await bot.USER.get_me()
- userbot_name = userbot.first_name
- userbot_id = userbot.id
-
- try:
- channel_info = await bot.USER.get_chat(target)
- channel_id = channel_info.id
- except Exception:
- await update.reply_text(f"My UserBot [{userbot_name}](tg://user?id={userbot_id}) Couldnt Fetch Details Of `{target}` Make Sure Userbot Is Not Banned There Or Add It Manually And Try Again....!!")
- return
-
- in_db = await db.in_db(chat_id, channel_id)
-
- if not in_db:
- await update.reply_text("This Channel Is Not Connected With The Group...")
- return
-
- wait_msg = await update.reply_text("Deleting All Files Of This Channel From DB....!!!\n\nPlease Be Patience...Dont Sent Another Command Until This Process Finishes..")
-
- await db.del_filters(chat_id, channel_id)
- await db.del_active(chat_id, channel_id)
- await db.del_chat(chat_id, channel_id)
- await recacher(chat_id, True, True, bot, update)
-
- await wait_msg.edit_text("Sucessfully Deleted All Files From DB....")
-
-
-@Client.on_message(filters.command(["delall"]) & filters.group, group=1)
-async def delall(bot: Bot, update):
- """
- A Funtion To Handle Incoming /delall Command TO Disconnect All Chats From A Group
- """
- chat_id=update.chat.id
- user_id = update.from_user.id if update.from_user else None
- global VERIFY
-
- if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
- admin_list = []
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
- admin_list.append(None)
- VERIFY[str(chat_id)] = admin_list
-
- if not user_id in VERIFY.get(str(chat_id)):
- return
-
- await db.delete_all(chat_id)
- await recacher(chat_id, True, True, bot, update)
-
- await update.reply_text("Sucessfully Deleted All Connected Chats From This Group....")
-
-
-@Client.on_message(filters.channel & (filters.video | filters.audio | filters.document) & ~filters.edited, group=0)
-async def new_files(bot: Bot, update):
- """
- A Funtion To Handle Incoming New Files In A Channel ANd Add Them To Respective Channels..
- """
- channel_id = update.chat.id
-
- # Using 'if elif' instead of 'or' to determine 'file_type'
- # Better Way? Make A PR
-
- try:
- if update.video:
- file_type = "video"
- file_id = update.video.file_id
- file_name = update.video.file_name[0:-4]
- file_caption = update.caption if update.caption else ""
- file_size = update.video.file_size
-
- elif update.audio:
- file_type = "audio"
- file_id = update.audio.file_id
- file_name = update.audio.file_name[0:-4]
- file_caption = update.caption if update.caption else ""
- file_size = update.audio.file_size
-
- elif update.document:
- file_type = "document"
- file_id = update.document.file_id
- file_name = update.document.file_name[0:-4]
- file_caption = update.caption if update.caption else ""
- file_size = update.document.file_size
-
- for i in ["_", "|", "-", "."]: # Work Around
- try:
- file_name = file_name.replace(i, " ")
- except Exception:
- pass
- except Exception as e:
- print(e)
- return
-
-
- file_link = update.link
- group_ids = await db.find_group_id(channel_id)
- unique_id = ''.join(
- random.choice(
- string.ascii_lowercase +
- string.ascii_uppercase +
- string.digits
- ) for _ in range(15)
- )
-
- data = []
-
- if group_ids:
- for group_id in group_ids:
- data_packets = dict(
- file_id=file_id, # File Id For Future Updates Maybe...
- unique_id=unique_id,
- file_name=file_name,
- file_caption=file_caption,
- file_size = file_size,
- file_type=file_type,
- file_link=file_link,
- chat_id=channel_id,
- group_id=group_id,
- )
-
- data.append(data_packets)
- await db.add_filters(data)
- return
-
diff --git a/bot/plugins/commands.py b/bot/plugins/commands.py
deleted file mode 100644
index 5fadbc96b..000000000
--- a/bot/plugins/commands.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-
-from pyrogram import filters, Client
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
-from bot import Translation, LOGGER # pylint: disable=import-error
-from bot.database import Database # pylint: disable=import-error
-
-db = Database()
-
-@Client.on_message(filters.command(["start"]) & filters.private, group=1)
-async def start(bot, update):
-
- try:
- file_uid = update.command[1]
- except IndexError:
- file_uid = False
-
- if file_uid:
- file_id, file_name, file_caption, file_type = await db.get_file(file_uid)
-
- if (file_id or file_type) == None:
- return
-
- caption = file_caption if file_caption != ("" or None) else ("" + file_name + "")
- try:
- await update.reply_cached_media(
- file_id,
- quote=True,
- caption = caption,
- parse_mode="html",
- reply_markup=InlineKeyboardMarkup(
- [
- [
- InlineKeyboardButton
- (
- 'Developers', url="https://t.me/CrazyBotsz"
- )
- ]
- ]
- )
- )
- except Exception as e:
- await update.reply_text(f"Error:\n{e}", True, parse_mode="html")
- LOGGER(__name__).error(e)
- return
-
- buttons = [[
- InlineKeyboardButton('Developers', url='https://t.me/CrazyBotsz'),
- InlineKeyboardButton('Source Code 🧾', url ='https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot-V2')
- ],[
- InlineKeyboardButton('Support 🛠', url='https://t.me/CrazyBotszGrp')
- ],[
- InlineKeyboardButton('Help ⚙', callback_data="help")
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await bot.send_message(
- chat_id=update.chat.id,
- text=Translation.START_TEXT.format(
- update.from_user.first_name),
- reply_markup=reply_markup,
- parse_mode="html",
- reply_to_message_id=update.message_id
- )
-
-
-@Client.on_message(filters.command(["help"]) & filters.private, group=1)
-async def help(bot, update):
- buttons = [[
- InlineKeyboardButton('Home ⚡', callback_data='start'),
- InlineKeyboardButton('About 🚩', callback_data='about')
- ],[
- InlineKeyboardButton('Close 🔐', callback_data='close')
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await bot.send_message(
- chat_id=update.chat.id,
- text=Translation.HELP_TEXT,
- reply_markup=reply_markup,
- parse_mode="html",
- reply_to_message_id=update.message_id
- )
-
-
-@Client.on_message(filters.command(["about"]) & filters.private, group=1)
-async def about(bot, update):
-
- buttons = [[
- InlineKeyboardButton('Home ⚡', callback_data='start'),
- InlineKeyboardButton('Close 🔐', callback_data='close')
- ]]
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await bot.send_message(
- chat_id=update.chat.id,
- text=Translation.ABOUT_TEXT,
- reply_markup=reply_markup,
- disable_web_page_preview=True,
- parse_mode="html",
- reply_to_message_id=update.message_id
- )
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
deleted file mode 100644
index a8fd1c5fa..000000000
--- a/bot/plugins/settings.py
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-
-import re
-from pyrogram import Client, filters
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-
-from bot import VERIFY # pylint: disable=import-error
-
-@Client.on_message(filters.command(["settings"]) & filters.group, group=1)
-async def settings(bot, update):
-
- chat_id = update.chat.id
- user_id = update.from_user.id if update.from_user else None
- global VERIFY
-
- if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
- admin_list = []
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
- admin_list.append(None)
- VERIFY[str(chat_id)] = admin_list
-
- if not user_id in VERIFY.get(str(chat_id)): # Checks if user is admin of the chat
- return
-
- bot_info = await bot.get_me()
- bot_first_name= bot_info.first_name
-
- text =f"{bot_first_name}'s Settings Pannel.....\n"
- text+=f"\nYou Can Use This Menu To Change Connectivity And Know Status Of Your Every Connected Channel, Change Filter Types, Configure Filter Results And To Know Status Of Your Group..."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "Channels", callback_data=f"channel_list({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Filter Types", callback_data=f"types({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Configure 🛠", callback_data=f"config({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Status", callback_data=f"status({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "About", callback_data=f"about({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await bot.send_message (
-
- chat_id=chat_id,
- text=text,
- reply_markup=reply_markup,
- parse_mode="html",
- reply_to_message_id=update.message_id
-
- )
-
-
-def remove_emoji(string):
- emoji_pattern = re.compile("["
- u"\U0001F600-\U0001F64F"
- u"\U0001F300-\U0001F5FF"
- u"\U0001F680-\U0001F6FF"
- u"\U0001F1E0-\U0001F1FF"
- u"\U00002500-\U00002BEF"
- u"\U00002702-\U000027B0"
- u"\U00002702-\U000027B0"
- u"\U000024C2-\U0001F251"
- u"\U0001f926-\U0001f937"
- u"\U00010000-\U0010ffff"
- u"\u2640-\u2642"
- u"\u2600-\u2B55"
- u"\u200d"
- u"\u23cf"
- u"\u23e9"
- u"\u231a"
- u"\ufe0f"
- u"\u3030"
- "]+", flags=re.UNICODE)
-
- return emoji_pattern.sub(r' ', str(string))
diff --git a/bot/translation.py b/bot/translation.py
deleted file mode 100644
index b72093ebb..000000000
--- a/bot/translation.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-
-class Translation(object):
-
- START_TEXT = """Hey {}!!
-Am Just A Advance Auto Filter Bot....😉
-
-Just Add Me To Your Group And Channel And Connect Them And See My Pevers 🔥🔥😝
-
-For More Details Click Help Button Below..
-@CrazyBotsz
-"""
-
- HELP_TEXT = """
-How To Use Me!?
-
-
--> Add Me To Any Group And Make Me Admin
--> Add Me To Your Desired Channel
-
-
-Bot Commands (Works Only In Groups) :
-
- -> /add chat_id
- OR - To Connect A Group With A Channel (Bot Should Be Admin With Full Previlages In Both Group And Channel)
- /add @Username
-
- -> /del chat_id
- OR - To disconnect A Group With A Channel
- /del @Username
-
- -> /delall - This Command Will Disconnect All Connected Channel With The Group And Deletes All Its File From DB
-
- -> /settings - This Command Will Display You A Settings Pannel Instance Which Can Be Used To Tweek Bot's Settings Accordingly
-
- -> Channel - Button Will Show You All The Connected Chats With The Group And Will Show Buttons Correspnding To There Order For Furthur Controls
-
- -> Filter Types - Button Will Show You The 3 Filter Option Available In Bot... Pressing Each Buttons Will Either Enable or Disable Them And This Will Take Into Action As Soon As You Use Them Without The Need Of A Restart
-
- -> Configure - Button Will Helps You To Change No. of Pages/ Buttons Per Page/ Total Result Without Acutally Editing The Repo... Also It Provide Option To Enable/Disable For Showing Invite Link In Each Results
-
- -> Status - Button Will Shows The Stats Of Your Channel
-
-@CrazyBotsz
-"""
-
- ABOUT_TEXT = """➥ Name : Auto Filter Bot
-
-➥ Creator : AlbertEinstein_TG
-
-➥ Language : Python3
-
-➥ Library : Pyrogram Asyncio 1.13.0
-
-➥ Source Code : Click Me
-"""
\ No newline at end of file
diff --git a/bot/user.py b/bot/user.py
deleted file mode 100644
index 6962cc876..000000000
--- a/bot/user.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-
-from pyrogram import Client, __version__
-
-from . import API_HASH, APP_ID, LOGGER, \
- USER_SESSION
-
-
-class User(Client):
- def __init__(self):
- super().__init__(
- USER_SESSION,
- api_hash=API_HASH,
- api_id=APP_ID,
- workers=4
- )
- self.LOGGER = LOGGER
-
- async def start(self):
- await super().start()
- usr_bot_me = await self.get_me()
- return (self, usr_bot_me.id)
-
- async def stop(self, *args):
- await super().stop()
- self.LOGGER(__name__).info("Bot stopped. Bye.")
From c62343962a8c2c796cb75c55d8c5197e0eddcddd Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 10:49:23 +0530
Subject: [PATCH 36/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Procfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Procfile b/Procfile
index 5765bf02b..3bf2661c4 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-worker: python3 -m bot
\ No newline at end of file
+worker: python3 -m DonLee_Robot
From e634edf7c590e1596e9e8eee555e9b6cf7ca8d6b Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 11:26:59 +0530
Subject: [PATCH 37/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Translation.py | 57 +++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100644 DonLee_Robot/Translation.py
diff --git a/DonLee_Robot/Translation.py b/DonLee_Robot/Translation.py
new file mode 100644
index 000000000..7416bba19
--- /dev/null
+++ b/DonLee_Robot/Translation.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @AlbertEinsteinTG
+
+class Translation(object):
+
+ START_TEXT = """🙋♂️Hey {}!!
+Am Just A Donlee Adv Auto Filter Bot....😉
+
+Just Add Me To Your Group And Channel And Connect Them And See My Pevers 🔥🔥😝
+Watch the video below to build an DonLee Adv Autofilter bot like me...
+Subscribe to the update channel to learn about my updates and activity...
+Press /help to know about available commands🤪"""
+
+ HELP_TEXT = """
+How To Use Me!?
+
+
+-> Add Me To Any Group And Make Me Admin
+-> Add Me To Your Desired Channel
+
+
+Bot Commands (Works Only In Groups) :
+
+ -> /add chat_id
+ OR - To Connect A Group With A Channel (Bot Should Be Admin With Full Previlages In Both Group And Channel)
+ /add @Username
+
+ -> /del chat_id
+ OR - To disconnect A Group With A Channel
+ /del @Username
+
+ -> /delall - This Command Will Disconnect All Connected Channel With The Group And Deletes All Its File From DB
+
+ -> /settings - This Command Will Display You A Settings Pannel Instance Which Can Be Used To Tweek Bot's Settings Accordingly
+
+ -> Channel - Button Will Show You All The Connected Chats With The Group And Will Show Buttons Correspnding To There Order For Furthur Controls
+
+ -> Filter Types - Button Will Show You The 3 Filter Option Available In Bot... Pressing Each Buttons Will Either Enable or Disable Them And This Will Take Into Action As Soon As You Use Them Without The Need Of A Restart
+
+ -> Configure - Button Will Helps You To Change No. of Pages/ Buttons Per Page/ Total Result Without Acutally Editing The Repo... Also It Provide Option To Enable/Disable For Showing Invite Link In Each Results
+
+ -> Status - Button Will Shows The Stats Of Your Channel
+
+@Mo_Tech_YT
+"""
+
+ ABOUT_TEXT = """➥ Name : Auto Filter Bot
+
+➥ Creator : Muhammed Rk
+
+➥ Language : Python3
+
+➥ Library : Pyrogram Asyncio 1.13.0
+
+➥ Source Code : Click Me
+"""
From 35ff684970750bb30c457c9432f95deee89db8f5 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 11:43:27 +0530
Subject: [PATCH 38/77] Update __main__.in
---
DonLee_Robot/__main__.in | 1 -
1 file changed, 1 deletion(-)
diff --git a/DonLee_Robot/__main__.in b/DonLee_Robot/__main__.in
index 491431ee6..0477a5756 100644
--- a/DonLee_Robot/__main__.in
+++ b/DonLee_Robot/__main__.in
@@ -6,7 +6,6 @@
# All rights reserved by PR0FESS0R-99
# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-
from .donlee_robot import Donlee_Robot
app = Donlee_Robot()
From f46ad0019bf548b50b1060a93b3167a97f7df13c Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 11:43:39 +0530
Subject: [PATCH 39/77] Delete __main__.in
---
DonLee_Robot/__main__.in | 12 ------------
1 file changed, 12 deletions(-)
delete mode 100644 DonLee_Robot/__main__.in
diff --git a/DonLee_Robot/__main__.in b/DonLee_Robot/__main__.in
deleted file mode 100644
index 0477a5756..000000000
--- a/DonLee_Robot/__main__.in
+++ /dev/null
@@ -1,12 +0,0 @@
-# !/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
-# Copyright permission under MIT License
-# All rights reserved by PR0FESS0R-99
-# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-
-from .donlee_robot import Donlee_Robot
-
-app = Donlee_Robot()
-app.run()
From e9fd6178982b8b74eb381adbd99ef63752716c5c Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 11:43:56 +0530
Subject: [PATCH 40/77] Create __main__.py
---
DonLee_Robot/__main__.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 DonLee_Robot/__main__.py
diff --git a/DonLee_Robot/__main__.py b/DonLee_Robot/__main__.py
new file mode 100644
index 000000000..0477a5756
--- /dev/null
+++ b/DonLee_Robot/__main__.py
@@ -0,0 +1,12 @@
+# !/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @AlbertEinsteinTG
+# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+from .donlee_robot import Donlee_Robot
+
+app = Donlee_Robot()
+app.run()
From 8465d068e1fa145da244029fab9f07eb1a0b87be Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 11:44:30 +0530
Subject: [PATCH 41/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/__main__.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/DonLee_Robot/__main__.py b/DonLee_Robot/__main__.py
index 0477a5756..633ed5f83 100644
--- a/DonLee_Robot/__main__.py
+++ b/DonLee_Robot/__main__.py
@@ -7,6 +7,5 @@
# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
from .donlee_robot import Donlee_Robot
-
app = Donlee_Robot()
app.run()
From 3288fd7ed13d28d72b75bbe05847b0696ccbdd8c Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 11:52:44 +0530
Subject: [PATCH 42/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/__main__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/DonLee_Robot/__main__.py b/DonLee_Robot/__main__.py
index 633ed5f83..1c62065e7 100644
--- a/DonLee_Robot/__main__.py
+++ b/DonLee_Robot/__main__.py
@@ -6,6 +6,6 @@
# All rights reserved by PR0FESS0R-99
# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-from .donlee_robot import Donlee_Robot
-app = Donlee_Robot()
+from .donlee_robot import DonLee_Robot
+app = DonLee_Robot()
app.run()
From 8774e6b77abcf17ab6fa5c9b5506e1438c607f76 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 12:04:45 +0530
Subject: [PATCH 43/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Settings.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/DonLee_Robot/Plugins/Settings.py b/DonLee_Robot/Plugins/Settings.py
index 35830c3d3..69c9edb73 100644
--- a/DonLee_Robot/Plugins/Settings.py
+++ b/DonLee_Robot/Plugins/Settings.py
@@ -9,7 +9,7 @@
import re
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-from DonLee_Robot.donlee_Robot import DonLee_Robot
+from DonLee_Robot.donlee_robot import DonLee_Robot
from DonLee_Robot import VERIFY # pylint: disable=import-error
@DonLee_Robot.on_message(filters.command(["settings"]) & filters.group, group=1)
From b4cffae3034d45a761ff64f686990fe4da1bcb98 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 12:17:19 +0530
Subject: [PATCH 44/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Channel.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/DonLee_Robot/Plugins/Channel.py b/DonLee_Robot/Plugins/Channel.py
index 773d1be3a..17824e6b1 100644
--- a/DonLee_Robot/Plugins/Channel.py
+++ b/DonLee_Robot/Plugins/Channel.py
@@ -5,15 +5,15 @@
from pyrogram import Client, filters
from pyrogram.errors import UserAlreadyParticipant, FloodWait
-from Donlee_Robot import VERIFY # pylint: disable=import-error
-from Donlee_Robot.donlee_robot import Donlee_Robot # pylint: disable=import-error
-from Donlee_Robot.Database import Database # pylint: disable=import-error
-from Donlee_Robot.Plugins.Auto_Filter import recacher # pylint: disable=import-error
+from DonLee_Robot import VERIFY # pylint: disable=import-error
+from DonLee_Robot.donlee_robot import DonLee_Robot # pylint: disable=import-error
+from DonLee_Robot.Database import Database # pylint: disable=import-error
+from DonLee_Robot.Plugins.Auto_Filter import recacher # pylint: disable=import-error
db = Database()
-@Donlee_Robot.on_message(filters.command(["add"]) & filters.group, group=1)
-async def connect(bot: Donlee_Robot, update):
+@DonLee_Robot.on_message(filters.command(["add"]) & filters.group, group=1)
+async def connect(bot: DonLee_Robot, update):
"""
A Funtion To Handle Incoming /add Command TO COnnect A Chat With Group
"""
@@ -193,8 +193,8 @@ async def connect(bot: Donlee_Robot, update):
await wait_msg.edit_text(f"Channel Was Sucessfully Added With {len(data)} Files..")
-@Donlee_Robot.on_message(filters.command(["del"]) & filters.group, group=1)
-async def disconnect(bot: Donlee_Robot, update):
+@DonLee_Robot.on_message(filters.command(["del"]) & filters.group, group=1)
+async def disconnect(bot: DonLee_Robot, update):
"""
A Funtion To Handle Incoming /del Command TO Disconnect A Chat With A Group
"""
@@ -258,8 +258,8 @@ async def disconnect(bot: Donlee_Robot, update):
await wait_msg.edit_text("Sucessfully Deleted All Files From DB....")
-@Donlee_Robot.on_message(filters.command(["delall"]) & filters.group, group=1)
-async def delall(bot: Donlee_Robot, update):
+@DonLee_Robot.on_message(filters.command(["delall"]) & filters.group, group=1)
+async def delall(bot: DonLee_Robot, update):
"""
A Funtion To Handle Incoming /delall Command TO Disconnect All Chats From A Group
"""
From 4452f8804c0c0f79ecc2a2cc5abf7b8099481d30 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 12:40:00 +0530
Subject: [PATCH 45/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Plugins/Channel.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/DonLee_Robot/Plugins/Channel.py b/DonLee_Robot/Plugins/Channel.py
index 17824e6b1..05a42a67a 100644
--- a/DonLee_Robot/Plugins/Channel.py
+++ b/DonLee_Robot/Plugins/Channel.py
@@ -284,8 +284,8 @@ async def delall(bot: DonLee_Robot, update):
await update.reply_text("Sucessfully Deleted All Connected Chats From This Group....")
-@Donlee_Robot.on_message(filters.channel & (filters.video | filters.audio | filters.document) & ~filters.edited, group=0)
-async def new_files(bot: Donlee_Robot, update):
+@DonLee_Robot.on_message(filters.channel & (filters.video | filters.audio | filters.document) & ~filters.edited, group=0)
+async def new_files(bot: DonLee_Robot, update):
"""
A Funtion To Handle Incoming New Files In A Channel ANd Add Them To Respective Channels..
"""
From 2b7102e81b6ec606be20a9cf1d11bb26d72fa6c1 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Sat, 9 Oct 2021 12:40:05 +0530
Subject: [PATCH 46/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From 470616a7cb749e8a0461c224d092a7ff3337a79c Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Wed, 13 Oct 2021 08:28:13 +0530
Subject: [PATCH 47/77] =?UTF-8?q?=F0=9F=98=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Database/Database.py | 498 --------
DonLee_Robot/Database/__init__.py | 1 -
DonLee_Robot/Plugins/Auto_Filter.py | 288 -----
DonLee_Robot/Plugins/Callback.py | 1713 ---------------------------
DonLee_Robot/Plugins/Channel.py | 358 ------
DonLee_Robot/Plugins/Commands.py | 113 --
DonLee_Robot/Plugins/Settings.py | 111 --
DonLee_Robot/Translation.py | 57 -
DonLee_Robot/User.py | 32 -
DonLee_Robot/__init__.py | 50 -
DonLee_Robot/__main__.py | 11 -
DonLee_Robot/donlee_robot.py | 43 -
12 files changed, 3275 deletions(-)
delete mode 100644 DonLee_Robot/Database/Database.py
delete mode 100644 DonLee_Robot/Database/__init__.py
delete mode 100644 DonLee_Robot/Plugins/Auto_Filter.py
delete mode 100644 DonLee_Robot/Plugins/Callback.py
delete mode 100644 DonLee_Robot/Plugins/Channel.py
delete mode 100644 DonLee_Robot/Plugins/Commands.py
delete mode 100644 DonLee_Robot/Plugins/Settings.py
delete mode 100644 DonLee_Robot/Translation.py
delete mode 100644 DonLee_Robot/User.py
delete mode 100644 DonLee_Robot/__init__.py
delete mode 100644 DonLee_Robot/__main__.py
delete mode 100644 DonLee_Robot/donlee_robot.py
diff --git a/DonLee_Robot/Database/Database.py b/DonLee_Robot/Database/Database.py
deleted file mode 100644
index 763d64aa8..000000000
--- a/DonLee_Robot/Database/Database.py
+++ /dev/null
@@ -1,498 +0,0 @@
-import os
-import motor.motor_asyncio # pylint: disable=import-error
-from DonLee_Robot import DB_URI
-
-DB_NAME = os.environ.get("DB_NAME", "DonLee_Robot")
-
-class Database:
-
- def __init__(self):
- self._client = motor.motor_asyncio.AsyncIOMotorClient(DB_URI)
- self.db = self._client[DB_NAME]
- self.col = self.db["Main"]
- self.acol = self.db["Active_Chats"]
- self.fcol = self.db["Filter_Collection"]
-
- self.cache = {}
- self.acache = {}
-
-
- async def create_index(self):
- """
- Create text index if not in db
- """
- await self.fcol.create_index([("file_name", "text")])
-
-
- def new_chat(self, group_id, channel_id, channel_name):
- """
- Create a document in db if the chat is new
- """
- try:
- group_id, channel_id = int(group_id), int(channel_id)
- except:
- pass
-
- return dict(
- _id = group_id,
- chat_ids = [{
- "chat_id": channel_id,
- "chat_name": channel_name
- }],
- types = dict(
- audio=False,
- document=True,
- video=True
- ),
- configs = dict(
- accuracy=0.80,
- max_pages=5,
- max_results=50,
- max_per_page=10,
- pm_fchat=True,
- show_invite_link=True
- )
- )
-
-
- async def status(self, group_id: int):
- """
- Get the total filters, total connected
- chats and total active chats of a chat
- """
- group_id = int(group_id)
-
- total_filter = await self.tf_count(group_id)
-
- chats = await self.find_chat(group_id)
- chats = chats.get("chat_ids")
- total_chats = len(chats) if chats is not None else 0
-
- achats = await self.find_active(group_id)
- if achats not in (None, False):
- achats = achats.get("chats")
- if achats == None:
- achats = []
- else:
- achats = []
- total_achats = len(achats)
-
- return total_filter, total_chats, total_achats
-
-
- async def find_group_id(self, channel_id: int):
- """
- Find all group id which is connected to a channel
- for add a new files to db
- """
- data = self.col.find({})
- group_list = []
-
- for group_id in await data.to_list(length=50): # No Need Of Even 50
- for y in group_id["chat_ids"]:
- if int(y["chat_id"]) == int(channel_id):
- group_list.append(group_id["_id"])
- else:
- continue
- return group_list
-
- # Related TO Finding Channel(s)
- async def find_chat(self, group_id: int):
- """
- A funtion to fetch a group's settings
- """
- connections = self.cache.get(str(group_id))
-
- if connections is not None:
- return connections
-
- connections = await self.col.find_one({'_id': group_id})
-
- if connections:
- self.cache[str(group_id)] = connections
-
- return connections
- else:
- return self.new_chat(None, None, None)
-
-
- async def add_chat(self, group_id: int, channel_id: int, channel_name):
- """
- A funtion to add/update a chat document when a new chat is connected
- """
- new = self.new_chat(group_id, channel_id, channel_name)
- update_d = {"$push" : {"chat_ids" : {"chat_id": channel_id, "chat_name" : channel_name}}}
- prev = await self.col.find_one({'_id':group_id})
-
- if prev:
- await self.col.update_one({'_id':group_id}, update_d)
- await self.update_active(group_id, channel_id, channel_name)
- await self.refresh_cache(group_id)
-
- return True
-
- self.cache[str(group_id)] = new
-
- await self.col.insert_one(new)
- await self.add_active(group_id, channel_id, channel_name)
- await self.refresh_cache(group_id)
-
- return True
-
-
- async def del_chat(self, group_id: int, channel_id: int):
- """
- A Funtion to delete a channel and its files from db of a chat connection
- """
- group_id, channel_id = int(group_id), int(channel_id) # group_id and channel_id Didnt type casted to int for some reason
-
- prev = self.col.find_one({"_id": group_id})
-
- if prev:
-
- await self.col.update_one(
- {"_id": group_id},
- {"$pull" :
- {"chat_ids" :
- {"chat_id":
- channel_id
- }
- }
- },
- False,
- True
- )
-
- await self.del_active(group_id, channel_id)
- await self.refresh_cache(group_id)
-
- return True
-
- return False
-
-
- async def in_db(self, group_id: int, channel_id: int):
- """
- Check whether if the given channel id is in db or not...
- """
- connections = self.cache.get(group_id)
-
- if connections is None:
- connections = await self.col.find_one({'_id': group_id})
-
- check_list = []
-
- if connections:
- for x in connections["chat_ids"]:
- check_list.append(int(x.get("chat_id")))
-
- if int(channel_id) in check_list:
- return True
-
- return False
-
-
- async def update_settings(self, group_id: int, settings):
- """
- A Funtion to update a chat's filter types in db
- """
- group_id = int(group_id)
- prev = await self.col.find_one({"_id": group_id})
-
- if prev:
- try:
- await self.col.update_one({"_id": group_id}, {"$set": {"types": settings}})
- await self.refresh_cache(group_id)
- return True
-
- except Exception as e:
- print (e)
- return False
- print("You Should First Connect To A Chat To Use This Funtion..... 'databse.py/#201' ")
- return False
-
-
- async def update_configs(self, group_id: int, configs):
- """
- A Funtion to update a chat's configs in db
- """
- prev = await self.col.find_one({"_id": group_id})
-
- if prev:
- try:
- await self.col.update_one(prev, {"$set":{"configs": configs}})
- await self.refresh_cache(group_id)
- return True
-
- except Exception as e:
- print (e)
- return False
- print("You Should First Connect To A Chat To Use This")
- return False
-
-
- async def delete_all(self, group_id: int):
- """
- A Funtion to delete all documents related to a
- chat from db
- """
- prev = await self.col.find_one({"_id": group_id})
- if prev:
- await self.delall_active(group_id)
- await self.delall_filters(group_id)
- await self.del_main(group_id)
- await self.refresh_cache(group_id)
-
- return
-
-
- async def del_main(self, group_id: int):
- """
- A Funtion To Delete the chat's main db document
- """
- await self.col.delete_one({"_id": group_id})
- await self.refresh_cache(group_id)
-
- return True
-
-
- async def refresh_cache(self, group_id: int):
- """
- A Funtion to refresh a chat's chase data
- in case of update in db
- """
- if self.cache.get(str(group_id)):
- self.cache.pop(str(group_id))
-
- prev = await self.col.find_one({"_id": group_id})
-
- if prev:
- self.cache[str(group_id)] = prev
- return True
-
- # Related To Finding Active Channel(s)
- async def add_active(self, group_id: int, channel_id: int, channel_name):
- """
- A Funtion to add a channel as an active chat the a connected group
- (This Funtion will be used only if its the first time)
- """
- templ = {"_id": group_id, "chats":[{"chat_id": channel_id, "chat_name": channel_name}]}
-
- try:
- await self.acol.insert_one(templ)
- await self.refresh_acache(group_id)
- except Exception as e:
- print(e)
- return False
-
- return True
-
-
- async def del_active(self, group_id: int, channel_id: int):
- """
- A funtion to delete a channel from active chat colletion in db
- """
- templ = {"$pull": {"chats": dict(chat_id = channel_id)}}
-
- try:
- await self.acol.update_one({"_id": group_id}, templ, False, True)
- except Exception as e:
- print(e)
- pass
-
- await self.refresh_acache(group_id)
- return True
-
-
- async def update_active(self, group_id: int, channel_id: int, channel_name):
- """
- A Funtion to add a new active chat to the connected group
- """
- group_id, channel_id = int(group_id), int(channel_id)
-
- prev = await self.acol.find_one({"_id": group_id})
- templ = {"$push" : {"chats" : dict(chat_id = channel_id, chat_name = channel_name)}}
- in_c = await self.in_active(group_id, channel_id)
-
- if prev:
- if not in_c:
- await self.acol.update_one({"_id": group_id}, templ)
- else:
- return False
- else:
- await self.add_active(group_id, channel_id, channel_name)
- return True
-
-
- async def find_active(self, group_id: int):
- """
- A Funtion to find all active chats of
- a group from db
- """
- if self.acache.get(str(group_id)):
- self.acache.get(str(group_id))
-
- connection = await self.acol.find_one({"_id": group_id})
-
- if connection:
- return connection
- return False
-
-
- async def in_active(self, group_id: int, channel_id: int):
- """
- A Funtion to check if a chat id is in the active
- chat id list in db
- """
- prev = await self.acol.find_one({"_id": group_id})
-
- if prev:
- for x in prev["chats"]:
- if x["chat_id"] == channel_id:
- return True
-
- return False
-
- return False
-
-
- async def delall_active(self, group_id: int):
- """
- A Funtion to Delete all active chats of
- a group from db
- """
- await self.acol.delete_one({"_id":int(group_id)})
- await self.refresh_acache(group_id)
- return
-
-
- async def refresh_acache(self, group_id: int):
- """
- A Funtion to refresh a active chat's chase data
- in case of update in db
- """
- if self.acache.get(str(group_id)):
- self.acache.pop(str(group_id))
-
- prev = await self.acol.find_one({"_id": group_id})
-
- if prev:
- self.acache[str(group_id)] = prev
- return True
-
- # Related To Finding Filter(s)
- async def add_filters(self, data):
- """
- A Funtion to add document as
- a bulk to db
- """
- try:
- await self.fcol.insert_many(data)
- except Exception as e:
- print(e)
-
- return True
-
-
- async def del_filters(self, group_id: int, channel_id: int):
- """
- A Funtion to delete all filters of a specific
- chat and group from db
- """
- group_id, channel_id = int(group_id), int(channel_id)
-
- try:
- await self.fcol.delete_many({"chat_id": channel_id, "group_id": group_id})
- print(await self.cf_count(group_id, channel_id))
- return True
- except Exception as e:
- print(e)
- return False
-
-
- async def delall_filters(self, group_id: int):
- """
- A Funtion To delete all filters of a group
- """
- await self.fcol.delete_many({"group_id": int(group_id)})
- return True
-
-
- async def get_filters(self, group_id: int, keyword: str):
- """
- A Funtion to fetch all similar results for a keyowrd
- from using text index
- """
- await self.create_index()
-
- chat = await self.find_chat(group_id)
- chat_accuracy = float(chat["configs"].get("accuracy", 0.80))
- achats = await self.find_active(group_id)
-
- achat_ids=[]
- if not achats:
- return False
-
- for chats in achats["chats"]:
- achat_ids.append(chats.get("chat_id"))
-
- filters = []
-
- pipeline= {
- 'group_id': int(group_id), '$text':{'$search': keyword}
- }
-
-
- db_list = self.fcol.find(
- pipeline,
- {'score': {'$meta':'textScore'}} # Makes A New Filed With Match Score In Each Document
- )
-
- db_list.sort([("score", {'$meta': 'textScore'})]) # Sort all document on the basics of the score field
-
- for document in await db_list.to_list(length=600):
- if document["score"] < chat_accuracy:
- continue
-
- if document["chat_id"] in achat_ids:
- filters.append(document)
- else:
- continue
-
- return filters
-
-
- async def get_file(self, unique_id: str):
- """
- A Funtion to get a specific files using its
- unique id
- """
- file = await self.fcol.find_one({"unique_id": unique_id})
- file_id = None
- file_type = None
- file_name = None
- file_caption = None
-
- if file:
- file_id = file.get("file_id")
- file_name = file.get("file_name")
- file_type = file.get("file_type")
- file_caption = file.get("file_caption")
- return file_id, file_name, file_caption, file_type
-
-
- async def cf_count(self, group_id: int, channel_id: int):
- """
- A Funtion To count number of filter in channel
- w.r.t the connect group
- """
- return await self.fcol.count_documents({"chat_id": channel_id, "group_id": group_id})
-
-
- async def tf_count(self, group_id: int):
- """
- A Funtion to count total filters of a group
- """
- return await self.fcol.count_documents({"group_id": group_id})
-
-
diff --git a/DonLee_Robot/Database/__init__.py b/DonLee_Robot/Database/__init__.py
deleted file mode 100644
index 07f7250da..000000000
--- a/DonLee_Robot/Database/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from .Database import Database
diff --git a/DonLee_Robot/Plugins/Auto_Filter.py b/DonLee_Robot/Plugins/Auto_Filter.py
deleted file mode 100644
index 07d2a1841..000000000
--- a/DonLee_Robot/Plugins/Auto_Filter.py
+++ /dev/null
@@ -1,288 +0,0 @@
-import re
-import logging
-import asyncio
-
-from pyrogram import Client, filters
-from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
-from pyrogram.errors import ButtonDataInvalid, FloodWait
-
-from DonLee_Robot.Database import Database # pylint: disable=import-error
-from DonLee_Robot.donlee_robot import DonLee_Robot # pylint: disable=import-error
-
-
-FIND = {}
-INVITE_LINK = {}
-ACTIVE_CHATS = {}
-db = Database()
-
-@DonLee_Robot.on_message(filters.text & filters.group & ~filters.bot, group=0)
-async def auto_filter(bot, update):
- """
- A Funtion To Handle Incoming Text And Reply With Appropriate Results
- """
- group_id = update.chat.id
-
- if re.findall(r"((^\/|^,|^\.|^[\U0001F600-\U000E007F]).*)", update.text):
- return
-
- if ("https://" or "http://") in update.text:
- return
-
- query = re.sub(r"[1-2]\d{3}", "", update.text) # Targetting Only 1000 - 2999 😁
-
- if len(query) < 2:
- return
-
- results = []
-
- global ACTIVE_CHATS
- global FIND
-
- configs = await db.find_chat(group_id)
- achats = ACTIVE_CHATS[str(group_id)] if ACTIVE_CHATS.get(str(group_id)) else await db.find_active(group_id)
- ACTIVE_CHATS[str(group_id)] = achats
-
- if not configs:
- return
-
- allow_video = configs["types"]["video"]
- allow_audio = configs["types"]["audio"]
- allow_document = configs["types"]["document"]
-
- max_pages = configs["configs"]["max_pages"] # maximum page result of a query
- pm_file_chat = configs["configs"]["pm_fchat"] # should file to be send from bot pm to user
- max_results = configs["configs"]["max_results"] # maximum total result of a query
- max_per_page = configs["configs"]["max_per_page"] # maximum buttom per page
- show_invite = configs["configs"]["show_invite_link"] # should or not show active chat invite link
-
- show_invite = (False if pm_file_chat == True else show_invite) # turn show_invite to False if pm_file_chat is True
-
- filters = await db.get_filters(group_id, query)
-
- if filters:
- for filter in filters: # iterating through each files
- file_name = filter.get("file_name")
- file_type = filter.get("file_type")
- file_link = filter.get("file_link")
- file_size = int(filter.get("file_size", "0"))
-
- # from B to MiB
-
- if file_size < 1024:
- file_size = f"[{file_size} B]"
- elif file_size < (1024**2):
- file_size = f"[{str(round(file_size/1024, 2))} KiB] "
- elif file_size < (1024**3):
- file_size = f"[{str(round(file_size/(1024**2), 2))} MiB] "
- elif file_size < (1024**4):
- file_size = f"[{str(round(file_size/(1024**3), 2))} GiB] "
-
-
- file_size = "" if file_size == ("[0 B]") else file_size
-
- # add emoji down below inside " " if you want..
- button_text = f"{file_size}{file_name}"
-
-
- if file_type == "video":
- if allow_video:
- pass
- else:
- continue
-
- elif file_type == "audio":
- if allow_audio:
- pass
- else:
- continue
-
- elif file_type == "document":
- if allow_document:
- pass
- else:
- continue
-
- if len(results) >= max_results:
- break
-
- if pm_file_chat:
- unique_id = filter.get("unique_id")
- if not FIND.get("bot_details"):
- try:
- bot_= await bot.get_me()
- FIND["bot_details"] = bot_
- except FloodWait as e:
- asyncio.sleep(e.x)
- bot_= await bot.get_me()
- FIND["bot_details"] = bot_
-
- bot_ = FIND.get("bot_details")
- file_link = f"https://t.me/{bot_.username}?start={unique_id}"
-
- results.append(
- [
- InlineKeyboardButton(button_text, url=file_link)
- ]
- )
-
- else:
- return # return if no files found for that query
-
-
- if len(results) == 0: # double check
- return
-
- else:
-
- result = []
- # seperating total files into chunks to make as seperate pages
- result += [results[i * max_per_page :(i + 1) * max_per_page ] for i in range((len(results) + max_per_page - 1) // max_per_page )]
- len_result = len(result)
- len_results = len(results)
- results = None # Free Up Memory
-
- FIND[query] = {"results": result, "total_len": len_results, "max_pages": max_pages} # TrojanzHex's Idea Of Dicts😅
-
- # Add next buttin if page count is not equal to 1
- if len_result != 1:
- result[0].append(
- [
- InlineKeyboardButton("Next ⏩", callback_data=f"navigate(0|next|{query})")
- ]
- )
-
- # Just A Decaration
- result[0].append([
- InlineKeyboardButton(f"🔰 Page 1/{len_result if len_result < max_pages else max_pages} 🔰", callback_data="ignore")
- ])
-
-
- # if show_invite is True Append invite link buttons
- if show_invite:
-
- ibuttons = []
- achatId = []
- await gen_invite_links(configs, group_id, bot, update)
-
- for x in achats["chats"] if isinstance(achats, dict) else achats:
- achatId.append(int(x["chat_id"])) if isinstance(x, dict) else achatId.append(x)
-
- ACTIVE_CHATS[str(group_id)] = achatId
-
- for y in INVITE_LINK.get(str(group_id)):
-
- chat_id = int(y["chat_id"])
-
- if chat_id not in achatId:
- continue
-
- chat_name = y["chat_name"]
- invite_link = y["invite_link"]
-
- if ((len(ibuttons)%2) == 0):
- ibuttons.append(
- [
- InlineKeyboardButton(f"⚜ {chat_name} ⚜", url=invite_link)
- ]
- )
-
- else:
- ibuttons[-1].append(
- InlineKeyboardButton(f"⚜ {chat_name} ⚜", url=invite_link)
- )
-
- for x in ibuttons:
- result[0].insert(0, x) #Insert invite link buttons at first of page
-
- ibuttons = None # Free Up Memory...
- achatId = None
-
-
- reply_markup = InlineKeyboardMarkup(result[0])
-
- try:
- await bot.send_message(
- chat_id = update.chat.id,
- text=f"Found {(len_results)} Results For Your Query: {query}",
- reply_markup=reply_markup,
- parse_mode="html",
- reply_to_message_id=update.message_id
- )
-
- except ButtonDataInvalid:
- print(result[0])
-
- except Exception as e:
- print(e)
-
-
-async def gen_invite_links(db, group_id, bot, update):
- """
- A Funtion To Generate Invite Links For All Active
- Connected Chats In A Group
- """
- chats = db.get("chat_ids")
- global INVITE_LINK
-
- if INVITE_LINK.get(str(group_id)):
- return
-
- Links = []
- if chats:
- for x in chats:
- Name = x["chat_name"]
-
- if Name == None:
- continue
-
- chatId=int(x["chat_id"])
-
- Link = await bot.export_chat_invite_link(chatId)
- Links.append({"chat_id": chatId, "chat_name": Name, "invite_link": Link})
-
- INVITE_LINK[str(group_id)] = Links
- return
-
-
-async def recacher(group_id, ReCacheInvite=True, ReCacheActive=False, bot=DonLee_Robot, update=Message):
- """
- A Funtion To rechase invite links and active chats of a specific chat
- """
- global INVITE_LINK, ACTIVE_CHATS
-
- if ReCacheInvite:
- if INVITE_LINK.get(str(group_id)):
- INVITE_LINK.pop(str(group_id))
-
- Links = []
- chats = await db.find_chat(group_id)
- chats = chats["chat_ids"]
-
- if chats:
- for x in chats:
- Name = x["chat_name"]
- chat_id = x["chat_id"]
- if (Name == None or chat_id == None):
- continue
-
- chat_id = int(chat_id)
-
- Link = await bot.export_chat_invite_link(chat_id)
- Links.append({"chat_id": chat_id, "chat_name": Name, "invite_link": Link})
-
- INVITE_LINK[str(group_id)] = Links
-
- if ReCacheActive:
-
- if ACTIVE_CHATS.get(str(group_id)):
- ACTIVE_CHATS.pop(str(group_id))
-
- achats = await db.find_active(group_id)
- achatId = []
- if achats:
- for x in achats["chats"]:
- achatId.append(int(x["chat_id"]))
-
- ACTIVE_CHATS[str(group_id)] = achatId
- return
-
diff --git a/DonLee_Robot/Plugins/Callback.py b/DonLee_Robot/Plugins/Callback.py
deleted file mode 100644
index 40feba6eb..000000000
--- a/DonLee_Robot/Plugins/Callback.py
+++ /dev/null
@@ -1,1713 +0,0 @@
-import re
-import time
-import asyncio
-
-from pyrogram import Client, filters
-from pyrogram.errors import FloodWait, UserNotParticipant
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
-
-from DonLee_Robot.donlee_robot import DonLee_Robot
-from DonLee_Robot import start_uptime, Translation, VERIFY # pylint: disable=import-error
-from DonLee_Robot.Plugins.Auto_Filter import ( # pylint: disable=import-error
- FIND,
- INVITE_LINK,
- ACTIVE_CHATS,
- recacher,
- gen_invite_links
- )
-from DonLee_Robot.Plugins.Settings import( # pylint: disable=import-error
- remove_emoji
-)
-from DonLee_Robot.Database import Database # pylint: disable=import-error
-
-db = Database()
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"navigate\((.+)\)"), group=2)
-async def cb_navg(bot, update: CallbackQuery):
- """
- A Callback Funtion For The Next Button Appearing In Results
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- index_val, btn, query = re.findall(r"navigate\((.+)\)", query_data)[0].split("|", 2)
- try:
- ruser_id = update.message.reply_to_message.from_user.id
- except Exception as e:
- print(e)
- ruser_id = None
-
- admin_list = VERIFY.get(str(chat_id))
- if admin_list == None: # Make Admin's ID List
-
- admin_list = []
-
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
-
- admin_list.append(None) # Just For Anonymous Admin....
- VERIFY[str(chat_id)] = admin_list
-
- if not ((user_id == ruser_id) or (user_id in admin_list)): # Checks if user is same as requested user or is admin
- await update.answer("Nice Try ;)",show_alert=True)
- return
-
-
- if btn == "next":
- index_val = int(index_val) + 1
- elif btn == "back":
- index_val = int(index_val) - 1
-
- achats = ACTIVE_CHATS[str(chat_id)]
- configs = await db.find_chat(chat_id)
- pm_file_chat = configs["configs"]["pm_fchat"]
- show_invite = configs["configs"]["show_invite_link"]
- show_invite = (False if pm_file_chat == True else show_invite)
-
- results = FIND.get(query).get("results")
- leng = FIND.get(query).get("total_len")
- max_pages = FIND.get(query).get("max_pages")
-
- try:
- temp_results = results[index_val].copy()
- except IndexError:
- return # Quick Fix🏃🏃
- except Exception as e:
- print(e)
- return
-
- if ((index_val + 1 )== max_pages) or ((index_val + 1) == len(results)): # Max Pages
- temp_results.append([
- InlineKeyboardButton("⏪ Back", callback_data=f"navigate({index_val}|back|{query})")
- ])
-
- elif int(index_val) == 0:
- pass
-
- else:
- temp_results.append([
- InlineKeyboardButton("⏪ Back", callback_data=f"navigate({index_val}|back|{query})"),
- InlineKeyboardButton("Next ⏩", callback_data=f"navigate({index_val}|next|{query})")
- ])
-
- if not int(index_val) == 0:
- temp_results.append([
- InlineKeyboardButton(f"🔰 Page {index_val + 1}/{len(results) if len(results) < max_pages else max_pages} 🔰", callback_data="ignore")
- ])
-
- if show_invite and int(index_val) !=0 :
-
- ibuttons = []
- achatId = []
- await gen_invite_links(configs, chat_id, bot, update)
-
- for x in achats["chats"] if isinstance(achats, dict) else achats:
- achatId.append(int(x["chat_id"])) if isinstance(x, dict) else achatId.append(x)
-
- for y in INVITE_LINK.get(str(chat_id)):
-
- chat_id = int(y["chat_id"])
-
- if chat_id not in achatId:
- continue
-
- chat_name = y["chat_name"]
- invite_link = y["invite_link"]
-
- if ((len(ibuttons)%2) == 0):
- ibuttons.append(
- [
- InlineKeyboardButton
- (
- f"⚜ {chat_name} ⚜", url=invite_link
- )
- ]
- )
-
- else:
- ibuttons[-1].append(
- InlineKeyboardButton
- (
- f"⚜ {chat_name} ⚜", url=invite_link
- )
- )
-
- for x in ibuttons:
- temp_results.insert(0, x)
- ibuttons = None
- achatId = None
-
- reply_markup = InlineKeyboardMarkup(temp_results)
-
- text=f"Found {leng} Results For Your Query: {query}"
-
- try:
- await update.message.edit(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
- except FloodWait as f: # Flood Wait Caused By Spamming Next/Back Buttons
- await asyncio.sleep(f.x)
- await update.message.edit(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"settings"), group=2)
-async def cb_settings(bot, update: CallbackQuery):
- """
- A Callback Funtion For Back Button in /settings Command
- """
- global VERIFY
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)): # Check If User Is Admin
- return
-
- bot_status = await bot.get_me()
- bot_fname= bot_status.first_name
-
- text =f"{bot_fname}'s Settings Pannel.....\n"
- text+=f"\nYou Can Use This Menu To Change Connectivity And Know Status Of Your Every Connected Channel, Change Filter Types, Configure Filter Results And To Know Status Of Your Group..."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "Channels", callback_data=f"channel_list({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Filter Types", callback_data=f"types({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Configure 🛠", callback_data=f"config({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Status", callback_data=f"status({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "About", callback_data=f"about({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"warn\((.+)\)"), group=2)
-async def cb_warn(bot, update: CallbackQuery):
- """
- A Callback Funtion For Acknowledging User's About What Are They Upto
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:35]
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name, action = re.findall(r"warn\((.+)\)", query_data)[0].split("|", 2)
-
- if action == "connect":
- text=f"Are You Sure You Want To Enable Connection With {channel_name}..???\n"
- text+=f"\nThis Will Show File Links From {channel_name} While Showing Results..."
-
- elif action == "disconnect":
- text=f"Are You Sure You Want To Disable {channel_name} Connection With The Group???....\n"
- text+=f"\nThe DB Files Will Still Be There And You Can Connect Back To This Channel Anytime From Settings Menu Without Adding Files To DB Again...\n"
- text+=f"\nThis Disabling Just Hide Results From The Filter Results..."
-
- elif action == "c_delete":
- text=f"Are You Sure You Want To Disconnect {channel_name} From This Group??\n"
- text+=f"\nThis Will Delete Channel And All Its Files From DB Too....!!\n"
- text+=f"\nYou Need To Add Channel Again If You Need To Shows It Result..."
-
-
- elif action=="f_delete":
- text=f"Are You Sure That You Want To Clear All Filter From This Chat {channel_name}???\n"
- text+=f"\nThis Will Erase All Files From DB.."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "Yes", callback_data=f"{action}({channel_id}|{channel_name})"
- ),
-
- InlineKeyboardButton
- (
- "No", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"channel_list\((.+)\)"), group=2)
-async def cb_channel_list(bot, update: CallbackQuery):
- """
- A Callback Funtion For Displaying All Channel List And Providing A Menu To Navigate
- To Every COnnect Chats For Furthur Control
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:35]
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id = re.findall(r"channel_list\((.+)\)", query_data)[0]
-
- text = "Semms Like You Dont Have Any Channel Connected...\n\nConnect To Any Chat To Continue With This Settings..."
-
- db_list = await db.find_chat(int(chat_id))
-
- channel_id_list = []
- channel_name_list = []
-
- if db_list:
- for x in db_list["chat_ids"]:
- channel_id = x["chat_id"]
- channel_name = x["chat_name"]
-
- try:
- if (channel_id == None or channel_name == None):
- continue
- except:
- break
-
- channel_name = remove_emoji(channel_name).encode('ascii', 'ignore').decode('ascii')[:35]
- channel_id_list.append(channel_id)
- channel_name_list.append(channel_name)
-
- buttons = []
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data="settings"
- ),
-
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- )
-
- if channel_name_list:
-
- text=f"List Of Connected Channels With {chat_name} With There Settings..\n"
-
- for x in range(1, (len(channel_name_list)+1)):
- text+=f"\n{x}. {channel_name_list[x-1]}\n"
-
- text += "\nChoose Appropriate Buttons To Navigate Through Respective Channels"
-
-
- btn_key = [
- "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟",
- "1️⃣1️⃣", "1️⃣2️⃣", "1️⃣3️⃣", "1️⃣4️⃣", "1️⃣5️⃣", "1️⃣6️⃣", "1️⃣7️⃣",
- "1️⃣8️⃣", "1️⃣9️⃣", "2️⃣0️⃣" # Just In Case 😂🤣
- ]
-
- for i in range(1, (len(channel_name_list) + 1)): # Append The Index Number of Channel In Just A Single Line
- if i == 1:
- buttons.insert(0,
- [
- InlineKeyboardButton
- (
- btn_key[i-1], callback_data=f"info({channel_id_list[i-1]}|{channel_name_list[i-1]})"
- )
- ]
- )
-
- else:
- buttons[0].append(
- InlineKeyboardButton
- (
- btn_key[i-1], callback_data=f"info({channel_id_list[i-1]}|{channel_name_list[i-1]})"
- )
- )
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text = text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"info\((.+)\)"), group=2)
-async def cb_info(bot, update: CallbackQuery):
- """
- A Callback Funtion For Displaying Details Of The Connected Chat And Provide
- Ability To Connect / Disconnect / Delete / Delete Filters of That Specific Chat
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"info\((.+)\)", query_data)[0].split("|", 1)
-
- f_count = await db.cf_count(chat_id, int(channel_id))
- active_chats = await db.find_active(chat_id)
-
- if active_chats: # Checks for active chats connected to a chat
- dicts = active_chats["chats"]
- db_cids = [ int(x["chat_id"]) for x in dicts ]
-
- if int(channel_id) in db_cids:
- active_chats = True
- status = "Connected"
-
- else:
- active_chats = False
- status = "Disconnected"
-
- else:
- active_chats = False
- status = "Disconnected"
-
- text=f"Info About {channel_name}\n"
- text+=f"\nChannel Name: {channel_name}\n"
- text+=f"\nChannel ID: {channel_id}\n"
- text+=f"\nChannel Files: {f_count}\n"
- text+=f"\nCurrent Status: {status}\n"
-
-
- if active_chats:
- buttons = [
- [
- InlineKeyboardButton
- (
- "🚨 Disconnect 🚨", callback_data=f"warn({channel_id}|{channel_name}|disconnect)"
- ),
-
- InlineKeyboardButton
- (
- "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
- )
- ]
- ]
-
- else:
- buttons = [
- [
- InlineKeyboardButton
- (
- "💠 Connect 💠", callback_data=f"warn({channel_id}|{channel_name}|connect)"
- ),
-
- InlineKeyboardButton
- (
- "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
- )
- ]
- ]
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
- )
- ]
- )
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"channel_list({chat_id})"
- )
- ]
- )
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"^connect\((.+)\)"), group=2)
-async def cb_connect(bot, update: CallbackQuery):
- """
- A Callback Funtion Helping The user To Make A Chat Active Chat Which Will
- Make The Bot To Fetch Results From This Channel Too
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"connect\((.+)\)", query_data)[0].split("|", 1)
- channel_id = int(channel_id)
-
- f_count = await db.cf_count(chat_id, channel_id)
-
- add_active = await db.update_active(chat_id, channel_id, channel_name)
-
- if not add_active:
- await update.answer(f"{channel_name} Is Aldready in Active Connection", show_alert=True)
- return
-
- text= f"Sucessfully Connected To {channel_name}\n"
- text+=f"\nInfo About {channel_name}\n"
- text+=f"\nChannel Name: {channel_name}\n"
- text+=f"\nChannel ID: {channel_id}\n"
- text+=f"\nChannel Files: {f_count}\n"
- text+=f"\nCurrent Status: Connected\n"
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "🚨 Disconnect 🚨", callback_data=f"warn({channel_id}|{channel_name}|disconnect)"
- ),
-
- InlineKeyboardButton
- (
- "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
- )
- ]
- ]
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
- )
- ]
- )
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"channel_list({chat_id})"
- )
- ]
- )
- await recacher(chat_id, False, True, bot, update)
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"disconnect\((.+)\)"), group=2)
-async def cb_disconnect(bot, update: CallbackQuery):
- """
- A Callback Funtion Helping The user To Make A Chat inactive Chat Which Will
- Make The Bot To Avoid Fetching Results From This Channel
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"connect\((.+)\)", query_data)[0].split("|", 1)
-
- f_count = await db.cf_count(chat_id, int(channel_id))
-
- remove_active = await db.del_active(chat_id, int(channel_id))
-
- if not remove_active:
- await update.answer("Couldnt Full Fill YOur Request...\n Report This @CrazyBotszGrp Along With Bot's Log", show_alert=True)
- return
-
- text= f"Sucessfully Disconnected From {channel_name}\n"
- text+=f"\nInfo About {channel_name}\n"
- text+=f"\nChannel Name: {channel_name}\n"
- text+=f"\nChannel ID: {channel_id}\n"
- text+=f"\nChannel Files: {f_count}\n"
- text+=f"\nCurrent Status: Disconnected\n"
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "💠 Connect 💠", callback_data=f"warn({channel_id}|{channel_name}|connect)"
- ),
-
- InlineKeyboardButton
- (
- "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
- )
- ]
- ]
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
- )
- ]
- )
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"channel_list({chat_id})"
- )
- ]
- )
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await recacher(chat_id, False, True, bot, update)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"c_delete\((.+)\)"), group=2)
-async def cb_channel_delete(bot, update: CallbackQuery):
- """
- A Callback Funtion For Delete A Channel Connection From A Group Chat History
- Along With All Its Filter Files
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"c_delete\((.+)\)", query_data)[0].split("|", 1)
- channel_id = int(channel_id)
-
- c_delete = await db.del_chat(chat_id, channel_id)
- a_delete = await db.del_active(chat_id, channel_id) # pylint: disable=unused-variable
- f_delete = await db.del_filters(chat_id, channel_id)
-
- if (c_delete and f_delete ):
- text=f"{channel_name} [ {channel_id} ] Has Been Sucessfully Deleted And All Its Files Were Cleared From DB...."
-
- else:
- text=f"Couldn't Delete Channel And All Its Files From DB Sucessfully....\nPlease Try Again After Sometimes...Also Make Sure To Check The Logs..!!"
- await update.answer(text=text, show_alert=True)
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"channel_list({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- await recacher(chat_id, True, True, bot, update)
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"f_delete\((.+)\)"), group=2)
-async def cb_filters_delete(bot, update: CallbackQuery):
- """
- A Callback Funtion For Delete A Specific Channel's Filters Connected To A Group
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- channel_id, channel_name = re.findall(r"f_delete\((.+)\)", query_data)[0].split("|", 1)
-
- f_delete = await db.del_filters(chat_id, int(channel_id))
-
- if not f_delete:
- text="Oops..!!\n\nEncountered Some Error While Deleteing Filters....\nPlease Check The Logs...."
- await update.answer(text=text, show_alert=True)
- return
-
- text =f"All Filters Of {channel_id}[{channel_name}] Has Been Deleted Sucessfully From My DB.."
-
- buttons=[
- [
- InlineKeyboardButton
- (
- "Back", callback_data="settings"
- ),
-
- InlineKeyboardButton
- (
- "Close", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"types\((.+)\)"), group=2)
-async def cb_types(bot, update: CallbackQuery):
- """
- A Callback Funtion For Changing The Result Types To Be Shown In While Sending Results
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id = re.findall(r"types\((.+)\)", query_data)[0]
-
- _types = await db.find_chat(int(chat_id))
-
- text=f"Filter Types Enabled/Disbled In {chat_name}\n"
-
- _types = _types["types"]
- vid = _types["video"]
- doc = _types["document"]
- aud = _types["audio"]
-
- buttons = []
-
- if vid:
- text+="\nVideo Index: Enabled\n"
- v_e = "✅"
- vcb_data = f"toggle({chat_id}|video|False)"
-
- else:
- text+="\nVideo Index: Disabled\n"
- v_e="❎"
- vcb_data = f"toggle({chat_id}|video|True)"
-
- if doc:
- text+="\nDocument Index: Enabled\n"
- d_e = "✅"
- dcb_data = f"toggle({chat_id}|document|False)"
-
- else:
- text+="\nDocument Index: Disabled\n"
- d_e="❎"
- dcb_data = f"toggle({chat_id}|document|True)"
-
- if aud:
- text+="\nAudio Index: Enabled\n"
- a_e = "✅"
- acb_data = f"toggle({chat_id}|audio|False)"
-
- else:
- text+="\nAudio Index: Disabled\n"
- a_e="❎"
- acb_data = f"toggle({chat_id}|audio|True)"
-
-
- text+="\nBelow Buttons Will Toggle Respective Media Types As Enabled Or Disabled....\n"
- text+="This Will Take Into Action As Soon As You Change Them...."
-
- buttons.append([InlineKeyboardButton(f"Video Index: {v_e}", callback_data=vcb_data)])
- buttons.append([InlineKeyboardButton(f"Audio Index: {a_e}", callback_data=acb_data)])
- buttons.append([InlineKeyboardButton(f"Document Index: {d_e}", callback_data=dcb_data)])
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"settings"
- )
- ]
- )
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"toggle\((.+)\)"), group=2)
-async def cb_toggle(bot, update: CallbackQuery):
- """
- A Callback Funtion Support handler For types()
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id, types, val = re.findall(r"toggle\((.+)\)", query_data)[0].split("|", 2)
-
- _types = await db.find_chat(int(chat_id))
-
- _types = _types["types"]
- vid = _types["video"]
- doc = _types["document"]
- aud = _types["audio"]
-
- if types == "video":
- vid = True if val=="True" else False
- elif types == "audio":
- aud = True if val=="True" else False
- elif types == "document":
- doc = True if val=="True" else False
-
-
- settings = {
- "video": vid,
- "audio": aud,
- "document": doc
- }
-
- process = await db.update_settings(chat_id, settings)
-
- if process:
- await update.answer(text="Filter Types Updated Sucessfully", show_alert=True)
-
- else:
- text="Something Wrong Please Check Bot Log For More Information...."
- await update.answer(text, show_alert=True)
- return
-
- _types = await db.find_chat(int(chat_id))
-
- text =f"Filter Types Enabled In {update.message.chat.title}\n"
-
- _types = _types["types"]
- vid = _types["video"]
- doc = _types["document"]
- aud = _types["audio"]
-
- buttons = []
-
- if vid:
- text+="\nVideo Index: Enabled\n"
- v_e = "✅"
- vcb_data = f"toggle({chat_id}|video|False)"
-
- else:
- text+="\nVideo Index: Disabled\n"
- v_e="❎"
- vcb_data = f"toggle({chat_id}|video|True)"
-
- if doc:
- text+="\nDocument Index: Enabled\n"
- d_e = "✅"
- dcb_data = f"toggle({chat_id}|document|False)"
-
- else:
- text+="\nDocument Index: Disabled\n"
- d_e="❎"
- dcb_data = f"toggle({chat_id}|document|True)"
-
- if aud:
- text+="\nAudio Index: Enabled\n"
- a_e = "✅"
- acb_data = f"toggle({chat_id}|audio|False)"
-
- else:
- text+="\nAudio Index: Disabled\n"
- a_e="❎"
- acb_data = f"toggle({chat_id}|audio|True)"
-
-
- text+="\nBelow Buttons Will Toggle Respective Media Types As Enabled Or Disabled....\n"
- text+="This Will Take Into Action As Soon As You Change Them...."
-
- buttons.append([InlineKeyboardButton(f"Video Index : {v_e}", callback_data=vcb_data)])
- buttons.append([InlineKeyboardButton(f"Audio Index : {a_e}", callback_data=acb_data)])
- buttons.append([InlineKeyboardButton(f"Document Index : {d_e}", callback_data=dcb_data)])
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"settings"
- )
- ]
- )
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"config\((.+)\)"), group=2)
-async def cb_config(bot, update: CallbackQuery):
- """
- A Callback Funtion For Chaning The Number Of Total Pages /
- Total Results / Results Per pages / Enable or Diable Invite Link /
- Enable or Disable PM File Chat
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id = re.findall(r"config\((.+)\)", query_data)[0]
-
- settings = await db.find_chat(int(chat_id))
-
- mp_count = settings["configs"]["max_pages"]
- mf_count = settings["configs"]["max_results"]
- mr_count = settings["configs"]["max_per_page"]
- show_invite = settings["configs"]["show_invite_link"]
- pm_file_chat = settings["configs"].get("pm_fchat", False)
- accuracy_point = settings["configs"].get("accuracy", 0.80)
-
- text=f"Configure Your {chat_name} Group's Filter Settings...\n"
-
- text+=f"\n{chat_name} Current Settings:\n"
-
- text+=f"\n - Max Filter: {mf_count}\n"
-
- text+=f"\n - Max Pages: {mp_count}\n"
-
- text+=f"\n - Max Filter Per Page: {mr_count}\n"
-
- text+=f"\n - Accuracy Percentage: {accuracy_point}\n"
-
- text+=f"\n - Show Invitation Link: {show_invite}\n"
-
- text+=f"\n - Provide File In Bot PM: {pm_file_chat}\n"
-
- text+="\nAdjust Above Value Using Buttons Below... "
- buttons=[
- [
- InlineKeyboardButton
- (
- "Filter Per Page", callback_data=f"mr_count({mr_count}|{chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Max Pages", callback_data=f"mp_count({mp_count}|{chat_id})"
- )
- ]
- ]
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Total Filter Count", callback_data=f"mf_count({mf_count}|{chat_id})"
- )
- ]
- )
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Show Invite Links", callback_data=f"show_invites({show_invite}|{chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Bot File Chat", callback_data=f"inPM({pm_file_chat}|{chat_id})"
- )
- ]
- )
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Result's Accuracy", callback_data=f"accuracy({accuracy_point}|{chat_id})"
- )
- ]
- )
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"settings"
- )
- ]
- )
-
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"mr_count\((.+)\)"), group=2)
-async def cb_max_buttons(bot, update: CallbackQuery):
- """
- A Callback Funtion For Changing The Count Of Result To Be Shown Per Page
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- count, chat_id = re.findall(r"mr_count\((.+)\)", query_data)[0].split("|", 1)
-
- text = f"Choose Your Desired 'Max Filter Count Per Page' For Every Filter Results Shown In {chat_name}"
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "5 Filters", callback_data=f"set(per_page|5|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "10 Filters", callback_data=f"set(per_page|10|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "15 Filters", callback_data=f"set(per_page|15|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "20 Filters", callback_data=f"set(per_page|20|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "25 Filters", callback_data=f"set(per_page|25|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "30 Filters", callback_data=f"set(per_page|30|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"mp_count\((.+)\)"), group=2)
-async def cb_max_page(bot, update: CallbackQuery):
- """
- A Callback Funtion For Changing The Count Of Maximum Result Pages To Be Shown
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- count, chat_id = re.findall(r"mp_count\((.+)\)", query_data)[0].split("|", 1)
-
- text = f"Choose Your Desired 'Max Filter Page Count' For Every Filter Results Shown In {chat_name}"
-
- buttons = [
-
- [
- InlineKeyboardButton
- (
- "2 Pages", callback_data=f"set(pages|2|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "4 Pages", callback_data=f"set(pages|4|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "6 Pages", callback_data=f"set(pages|6|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "8 Pages", callback_data=f"set(pages|8|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "10 Pages", callback_data=f"set(pages|10|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"config({chat_id})"
- )
- ]
-
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"mf_count\((.+)\)"), group=2)
-async def cb_max_results(bot, update: CallbackQuery):
- """
- A Callback Funtion For Changing The Count Of Maximum Files TO Be Fetched From Database
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- count, chat_id = re.findall(r"mf_count\((.+)\)", query_data)[0].split("|", 1)
-
- text = f"Choose Your Desired 'Max Filter' To Be Fetched From DB For Every Filter Results Shown In {chat_name}"
-
- buttons = [
-
- [
- InlineKeyboardButton
- (
- "50 Results", callback_data=f"set(results|50|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "100 Results", callback_data=f"set(results|100|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "150 Results", callback_data=f"set(results|150|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "200 Results", callback_data=f"set(results|200|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "250 Results", callback_data=f"set(results|250|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "300 Results", callback_data=f"set(results|300|{chat_id}|{count})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"show_invites\((.+)\)"), group=2)
-async def cb_show_invites(bot, update: CallbackQuery):
- """
- A Callback Funtion For Enabling Or Diabling Invite Link Buttons
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- value, chat_id = re.findall(r"show_invites\((.+)\)", query_data)[0].split("|", 1)
-
- value = True if value=="True" else False
-
- if value:
- buttons= [
- [
- InlineKeyboardButton
- (
- "Disable ❌", callback_data=f"set(showInv|False|{chat_id}|{value})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- else:
- buttons =[
- [
- InlineKeyboardButton
- (
- "Enable ✔", callback_data=f"set(showInv|True|{chat_id}|{value})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- text=f"This Config Will Help You To Show Invitation Link Of All Active Chats Along With The Filter Results For The Users To Join....."
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"inPM\((.+)\)"), group=2)
-async def cb_pm_file(bot, update: CallbackQuery):
- """
- A Callback Funtion For Enabling Or Diabling File Transfer Through Bot PM
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- value, chat_id = re.findall(r"inPM\((.+)\)", query_data)[0].split("|", 1)
-
- value = True if value=="True" else False
-
- if value:
- buttons= [
- [
- InlineKeyboardButton
- (
- "Disable ❎", callback_data=f"set(inPM|False|{chat_id}|{value})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- else:
- buttons =[
- [
- InlineKeyboardButton
- (
- "Enable ✅", callback_data=f"set(inPM|True|{chat_id}|{value})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- text=f"This Config Will Help You To Enable/Disable File Transfer Through Bot PM Without Redirecting Them To Channel...."
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"accuracy\((.+)\)"), group=2)
-async def cb_accuracy(bot, update: CallbackQuery):
- """
- A Callaback Funtion to control the accuracy of matching results
- that the bot should return for a query....
- """
- global VERIFY
- chat_id = update.message.chat.id
- chat_name = update.message.chat.title
- user_id = update.from_user.id
- query_data = update.data
-
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- val, chat_id = re.findall(r"accuracy\((.+)\)", query_data)[0].split("|", 1)
-
- text = f"Choose Your Desired 'Accuracy Perceentage' For Every Filter Results Shown In {chat_name}\n\n"
- text+= f"NB: Higher The Value Better Matching Results Will Be Provided... And If Value Is Lower It Will Show More Results \
- Which Is Fimilary To Query Search (Wont Be Accurate)...."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "100 %", callback_data=f"set(accuracy|1.00|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "80 %", callback_data=f"set(accuracy|0.80|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "65 %", callback_data=f"set(accuracy|0.65|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "60 %", callback_data=f"set(accuracy|0.60|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "55 %", callback_data=f"set(accuracy|0.55|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "50 %", callback_data=f"set(accuracy|0.50|{chat_id}|{val})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data=f"config({chat_id})"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"set\((.+)\)"), group=2)
-async def cb_set(bot, update: CallbackQuery):
- """
- A Callback Funtion Support For config()
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- action, val, chat_id, curr_val = re.findall(r"set\((.+)\)", query_data)[0].split("|", 3)
-
- try:
- val, chat_id, curr_val = float(val), int(chat_id), float(curr_val)
- except:
- chat_id = int(chat_id)
-
- if val == curr_val:
- await update.answer("New Value Cannot Be Old Value...Please Choose Different Value...!!!", show_alert=True)
- return
-
- prev = await db.find_chat(chat_id)
-
- accuracy = float(prev["configs"].get("accuracy", 0.80))
- max_pages = int(prev["configs"].get("max_pages"))
- max_results = int(prev["configs"].get("max_results"))
- max_per_page = int(prev["configs"].get("max_per_page"))
- pm_file_chat = True if prev["configs"].get("pm_fchat") == (True or "True") else False
- show_invite_link = True if prev["configs"].get("show_invite_link") == (True or "True") else False
-
- if action == "accuracy": # Scophisticated way 😂🤣
- accuracy = val
-
- elif action == "pages":
- max_pages = int(val)
-
- elif action == "results":
- max_results = int(val)
-
- elif action == "per_page":
- max_per_page = int(val)
-
- elif action =="showInv":
- show_invite_link = True if val=="True" else False
-
- elif action == "inPM":
- pm_file_chat = True if val=="True" else False
-
-
- new = dict(
- accuracy=accuracy,
- max_pages=max_pages,
- max_results=max_results,
- max_per_page=max_per_page,
- pm_fchat=pm_file_chat,
- show_invite_link=show_invite_link
- )
-
- append_db = await db.update_configs(chat_id, new)
-
- if not append_db:
- text="Something Wrong Please Check Bot Log For More Information...."
- await update.answer(text=text, show_alert=True)
- return
-
- text=f"Your Request Was Updated Sucessfully....\nNow All Upcoming Results Will Show According To This Settings..."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "Back 🔙", callback_data=f"config({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup=InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"status\((.+)\)"), group=2)
-async def cb_status(bot, update: CallbackQuery):
- """
- A Callback Funtion For Showing Overall Status Of A Group
- """
- global VERIFY
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = remove_emoji(update.message.chat.title)
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- chat_id = re.findall(r"status\((.+)\)", query_data)[0]
-
- total_filters, total_chats, total_achats = await db.status(chat_id)
-
- text = f"Status Of {chat_name}\n"
- text += f"\nTotal Connected Chats: {total_chats}\n"
- text += f"\nTotal Active Chats: {total_achats}\n"
- text += f"\nTotal Filters: {total_filters}"
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "🔙 Back", callback_data="settings"
- ),
-
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"about\((.+)\)"), group=2)
-async def cb_about(bot, update: CallbackQuery):
- """
- A Callback Funtion For Showing About Section In Bot Setting Menu
- """
- global VERIFY
- chat_id = update.message.chat.id
- user_id = update.from_user.id
-
- if user_id not in VERIFY.get(str(chat_id)):
- return
-
- text=f"Bot's Status\n"
- text+=f"\nBot's Uptime: {time_formatter(time.time() - start_uptime)}\n"
- text+=f"\nBot Funtion: Auto Filter Files\n"
- text+=f"""\nBot Support: @Mo_Tech_Group\n"""
- text+="""\nSource Code: Source"""
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "My Dev ⚡", url="https://t.me/MRK_YT"
- ),
-
- InlineKeyboardButton
- (
- "🔙 Back", callback_data="settings"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
-
-
-
-@DonLee_Robot.on_callback_query(filters.regex(r"^(start|help|about|close)$"), group=2)
-async def callback_data(bot, update: CallbackQuery):
-
- query_data = update.data
-
- if query_data == "start":
- buttons = [[
- InlineKeyboardButton('My Dev 👨🔬', url='https://t.me/Mrk_YT'),
- InlineKeyboardButton('Source Code 🧾', url ='https://github.com/PR0FESS0R-99/DonLee_Robot')
- ],[
- InlineKeyboardButton('🛠 Support 🛠', url='https://t.me/mo_Tech_yt')
- ],[
- InlineKeyboardButton('⚙ Help ⚙', callback_data="help")
- ],[
- InlineKeyboardButton('💫 Deploy Video 💫', url='https://youtu.be/uAHl5jvnrhk')
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- Translation.START_TEXT.format(update.from_user.mention),
- reply_markup=reply_markup,
- parse_mode="html",
- disable_web_page_preview=True
- )
-
-
- elif query_data == "help":
- buttons = [[
- InlineKeyboardButton('Home ⚡', callback_data='start'),
- InlineKeyboardButton('About 🚩', callback_data='about')
- ],[
- InlineKeyboardButton('Close 🔐', callback_data='close')
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- Translation.HELP_TEXT,
- reply_markup=reply_markup,
- parse_mode="html",
- disable_web_page_preview=True
- )
-
-
- elif query_data == "about":
- buttons = [[
- InlineKeyboardButton('Home ⚡', callback_data='start'),
- InlineKeyboardButton('Close 🔐', callback_data='close')
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await update.message.edit_text(
- Translation.ABOUT_TEXT,
- reply_markup=reply_markup,
- parse_mode="html"
- )
-
-
- elif query_data == "close":
- await update.message.delete()
-
-
-
-def time_formatter(seconds: float) -> str:
- """
- humanize time
- """
- minutes, seconds = divmod(int(seconds),60)
- hours, minutes = divmod(minutes, 60)
- days, hours = divmod(hours, 24)
- tmp = ((str(days) + "d, ") if days else "") + \
- ((str(hours) + "h, ") if hours else "") + \
- ((str(minutes) + "m, ") if minutes else "") + \
- ((str(seconds) + "s") if seconds else "")
- return tmp
-
diff --git a/DonLee_Robot/Plugins/Channel.py b/DonLee_Robot/Plugins/Channel.py
deleted file mode 100644
index 05a42a67a..000000000
--- a/DonLee_Robot/Plugins/Channel.py
+++ /dev/null
@@ -1,358 +0,0 @@
-import random
-import string
-import asyncio
-
-from pyrogram import Client, filters
-from pyrogram.errors import UserAlreadyParticipant, FloodWait
-
-from DonLee_Robot import VERIFY # pylint: disable=import-error
-from DonLee_Robot.donlee_robot import DonLee_Robot # pylint: disable=import-error
-from DonLee_Robot.Database import Database # pylint: disable=import-error
-from DonLee_Robot.Plugins.Auto_Filter import recacher # pylint: disable=import-error
-
-db = Database()
-
-@DonLee_Robot.on_message(filters.command(["add"]) & filters.group, group=1)
-async def connect(bot: DonLee_Robot, update):
- """
- A Funtion To Handle Incoming /add Command TO COnnect A Chat With Group
- """
- chat_id = update.chat.id
- user_id = update.from_user.id if update.from_user else None
- target_chat = update.text.split(None, 1)
- global VERIFY
-
- if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
- admin_list = []
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
- admin_list.append(None)
- VERIFY[str(chat_id)] = admin_list
-
- if not user_id in VERIFY.get(str(chat_id)):
- return
-
- try:
- if target_chat[1].startswith("@"):
- if len(target_chat[1]) < 5:
- await update.reply_text("Invalid Username...!!!")
- return
- target = target_chat[1]
-
- elif not target_chat[1].startswith("@"):
- if len(target_chat[1]) < 14:
- await update.reply_text("Invalid Chat Id...\nChat ID Should Be Something Like This: -100xxxxxxxxxx")
- return
- target = int(target_chat[1])
-
- except Exception:
- await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
- return
-
- try:
- join_link = await bot.export_chat_invite_link(target)
- except Exception as e:
- print(e)
- await update.reply_text(f"Make Sure Im Admin At {target} And Have Permission For 'Inviting Users via Link' And Try Again.....!!!")
- return
-
- userbot_info = await bot.USER.get_me()
- userbot_id = userbot_info.id
- userbot_name = userbot_info.first_name
-
- try:
- await bot.USER.join_chat(join_link)
-
- except UserAlreadyParticipant:
- pass
-
- except Exception:
- await update.reply_text(f"My UserBot [{userbot_name}](tg://user?id={userbot_id}) Couldnt Join The Channel `{target}` Make Sure Userbot Is Not Banned There Or Add It Manually And Try Again....!!")
- return
-
- try:
- c_chat = await bot.get_chat(target)
- channel_id = c_chat.id
- channel_name = c_chat.title
-
- except Exception as e:
- await update.reply_text("Encountered Some Issue..Please Check Logs..!!")
- raise e
-
-
- in_db = await db.in_db(chat_id, channel_id)
-
- if in_db:
- await update.reply_text("Channel Aldready In Db...!!!")
- return
-
- wait_msg = await update.reply_text("Please Wait Till I Add All Your Files From Channel To Db\n\nThis May Take 10 or 15 Mins Depending On Your No. Of Files In Channel.....\n\nUntil Then Please Dont Sent Any Other Command Or This Operation May Be Intrupted....")
-
- try:
- type_list = ["video", "audio", "document"]
- data = []
- skipCT = 0
-
- for typ in type_list:
-
- async for msgs in bot.USER.search_messages(channel_id,filter=typ): #Thanks To @PrgOfficial For Suggesting
-
- # Using 'if elif' instead of 'or' to determine 'file_type'
- # Better Way? Make A PR
- try:
- if msgs.video:
- try:
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except FloodWait as e:
- asyncio.sleep(e.x)
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except Exception as e:
- print(e)
- continue
- file_id = file_id.video.file_id
- file_name = msgs.video.file_name[0:-4]
- file_caption = msgs.caption if msgs.caption else ""
- file_size = msgs.video.file_size
- file_type = "video"
-
- elif msgs.audio:
- try:
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except FloodWait as e:
- asyncio.sleep(e.x)
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except Exception as e:
- print(e)
- continue
- file_id = file_id.audio.file_id
- file_name = msgs.audio.file_name[0:-4]
- file_caption = msgs.caption if msgs.caption else ""
- file_size = msgs.audio.file_size
- file_type = "audio"
-
- elif msgs.document:
- try:
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except FloodWait as e:
- asyncio.sleep(e.x)
- file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
- except Exception as e:
- print(str(e))
- continue
- file_id = file_id.document.file_id
- file_name = msgs.document.file_name[0:-4]
- file_caption = msgs.caption if msgs.caption else ""
- file_size = msgs.document.file_size
- file_type = "document"
-
- for i in ["_", "|", "-", "."]: # Work Around
- try:
- file_name = file_name.replace(i, " ")
- except Exception:
- pass
-
- file_link = msgs.link
- group_id = chat_id
- unique_id = ''.join(
- random.choice(
- string.ascii_lowercase +
- string.ascii_uppercase +
- string.digits
- ) for _ in range(15)
- )
-
- dicted = dict(
- file_id=file_id, # Done
- unique_id=unique_id,
- file_name=file_name,
- file_caption=file_caption,
- file_size=file_size,
- file_type=file_type,
- file_link=file_link,
- chat_id=channel_id,
- group_id=group_id,
- )
-
- data.append(dicted)
- except Exception as e:
- if 'NoneType' in str(e): # For Some Unknown Reason Some File Names are NoneType
- skipCT +=1
- continue
- print(e)
-
- print(f"{skipCT} Files Been Skipped Due To File Name Been None..... #BlameTG")
- except Exception as e:
- await wait_msg.edit_text("Couldnt Fetch Files From Channel... Please look Into Logs For More Details")
- raise e
-
- await db.add_filters(data)
- await db.add_chat(chat_id, channel_id, channel_name)
- await recacher(chat_id, True, True, bot, update)
-
- await wait_msg.edit_text(f"Channel Was Sucessfully Added With {len(data)} Files..")
-
-
-@DonLee_Robot.on_message(filters.command(["del"]) & filters.group, group=1)
-async def disconnect(bot: DonLee_Robot, update):
- """
- A Funtion To Handle Incoming /del Command TO Disconnect A Chat With A Group
- """
- chat_id = update.chat.id
- user_id = update.from_user.id if update.from_user else None
- target_chat = update.text.split(None, 1)
- global VERIFY
-
- if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
- admin_list = []
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
- admin_list.append(None)
- VERIFY[str(chat_id)] = admin_list
-
- if not user_id in VERIFY.get(str(chat_id)):
- return
-
- try:
- if target_chat[1].startswith("@"):
- if len(target_chat[1]) < 5:
- await update.reply_text("Invalid Username...!!!")
- return
- target = target_chat[1]
-
- elif not target_chat.startswith("@"):
- if len(target_chat[1]) < 14:
- await update.reply_text("Invalid Chat Id...\nChat ID Should Be Something Like This: -100xxxxxxxxxx")
- return
- target = int(target_chat[1])
-
- except Exception:
- await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
- return
-
- userbot = await bot.USER.get_me()
- userbot_name = userbot.first_name
- userbot_id = userbot.id
-
- try:
- channel_info = await bot.USER.get_chat(target)
- channel_id = channel_info.id
- except Exception:
- await update.reply_text(f"My UserBot [{userbot_name}](tg://user?id={userbot_id}) Couldnt Fetch Details Of `{target}` Make Sure Userbot Is Not Banned There Or Add It Manually And Try Again....!!")
- return
-
- in_db = await db.in_db(chat_id, channel_id)
-
- if not in_db:
- await update.reply_text("This Channel Is Not Connected With The Group...")
- return
-
- wait_msg = await update.reply_text("Deleting All Files Of This Channel From DB....!!!\n\nPlease Be Patience...Dont Sent Another Command Until This Process Finishes..")
-
- await db.del_filters(chat_id, channel_id)
- await db.del_active(chat_id, channel_id)
- await db.del_chat(chat_id, channel_id)
- await recacher(chat_id, True, True, bot, update)
-
- await wait_msg.edit_text("Sucessfully Deleted All Files From DB....")
-
-
-@DonLee_Robot.on_message(filters.command(["delall"]) & filters.group, group=1)
-async def delall(bot: DonLee_Robot, update):
- """
- A Funtion To Handle Incoming /delall Command TO Disconnect All Chats From A Group
- """
- chat_id=update.chat.id
- user_id = update.from_user.id if update.from_user else None
- global VERIFY
-
- if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
- admin_list = []
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
- admin_list.append(None)
- VERIFY[str(chat_id)] = admin_list
-
- if not user_id in VERIFY.get(str(chat_id)):
- return
-
- await db.delete_all(chat_id)
- await recacher(chat_id, True, True, bot, update)
-
- await update.reply_text("Sucessfully Deleted All Connected Chats From This Group....")
-
-
-@DonLee_Robot.on_message(filters.channel & (filters.video | filters.audio | filters.document) & ~filters.edited, group=0)
-async def new_files(bot: DonLee_Robot, update):
- """
- A Funtion To Handle Incoming New Files In A Channel ANd Add Them To Respective Channels..
- """
- channel_id = update.chat.id
-
- # Using 'if elif' instead of 'or' to determine 'file_type'
- # Better Way? Make A PR
-
- try:
- if update.video:
- file_type = "video"
- file_id = update.video.file_id
- file_name = update.video.file_name[0:-4]
- file_caption = update.caption if update.caption else ""
- file_size = update.video.file_size
-
- elif update.audio:
- file_type = "audio"
- file_id = update.audio.file_id
- file_name = update.audio.file_name[0:-4]
- file_caption = update.caption if update.caption else ""
- file_size = update.audio.file_size
-
- elif update.document:
- file_type = "document"
- file_id = update.document.file_id
- file_name = update.document.file_name[0:-4]
- file_caption = update.caption if update.caption else ""
- file_size = update.document.file_size
-
- for i in ["_", "|", "-", "."]: # Work Around
- try:
- file_name = file_name.replace(i, " ")
- except Exception:
- pass
- except Exception as e:
- print(e)
- return
-
-
- file_link = update.link
- group_ids = await db.find_group_id(channel_id)
- unique_id = ''.join(
- random.choice(
- string.ascii_lowercase +
- string.ascii_uppercase +
- string.digits
- ) for _ in range(15)
- )
-
- data = []
-
- if group_ids:
- for group_id in group_ids:
- data_packets = dict(
- file_id=file_id, # File Id For Future Updates Maybe...
- unique_id=unique_id,
- file_name=file_name,
- file_caption=file_caption,
- file_size = file_size,
- file_type=file_type,
- file_link=file_link,
- chat_id=channel_id,
- group_id=group_id,
- )
-
- data.append(data_packets)
- await db.add_filters(data)
- return
-
diff --git a/DonLee_Robot/Plugins/Commands.py b/DonLee_Robot/Plugins/Commands.py
deleted file mode 100644
index cc4c8015c..000000000
--- a/DonLee_Robot/Plugins/Commands.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# !/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
-# Copyright permission under MIT License
-# All rights reserved by PR0FESS0R-99
-# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-
-from pyrogram import filters, Client
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
-from DonLee_Robot import Translation, LOGGER # pylint: disable=import-error
-from DonLee_Robot.Database import Database # pylint: disable=import-error
-from DonLee_Robot.donlee_robot import DonLee_Robot
-
-db = Database()
-
-@DonLee_Robot.on_message(filters.command(["start"]) & filters.private, group=1)
-async def start(bot, update):
-
- try:
- file_uid = update.command[1]
- except IndexError:
- file_uid = False
-
- if file_uid:
- file_id, file_name, file_caption, file_type = await db.get_file(file_uid)
-
- if (file_id or file_type) == None:
- return
-
- caption = file_caption if file_caption != ("" or None) else ("" + file_name + "")
- try:
- await update.reply_cached_media(
- file_id,
- quote=True,
- caption = caption,
- parse_mode="html",
- reply_markup=InlineKeyboardMarkup(
- [
- [
- InlineKeyboardButton
- (
- 'Developers', url="https://t.me/mo_tech_YT"
- )
- ]
- ]
- )
- )
- except Exception as e:
- await update.reply_text(f"Error:\n{e}", True, parse_mode="html")
- LOGGER(__name__).error(e)
- return
-
- buttons = [[
- InlineKeyboardButton('My Dev 🧒', url='https://t.me/mrk_yt'),
- InlineKeyboardButton('Source Code 🧾', url ='https://github.com/PR0FESS0R-99/DonLee_Robot')
- ],[
- InlineKeyboardButton('🛠 Support 🛠', url='https://t.me/mo_tech_yt')
- ],[
- InlineKeyboardButton('⚙ Help ⚙', callback_data="help")
- ],[
- InlineKeyboardButton('💫 Deploy Video 💫', url='https://youtu.be/uAHl5jvnrhk')
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await bot.send_message(
- chat_id=update.chat.id,
- text=Translation.START_TEXT.format(
- update.from_user.first_name),
- reply_markup=reply_markup,
- parse_mode="html",
- reply_to_message_id=update.message_id
- )
-
-
-@DonLee_Robot.on_message(filters.command(["help"]) & filters.private, group=1)
-async def help(bot, update):
- buttons = [[
- InlineKeyboardButton('Home ⚡', callback_data='start'),
- InlineKeyboardButton('About 🚩', callback_data='about')
- ],[
- InlineKeyboardButton('Close 🔐', callback_data='close')
- ]]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await bot.send_message(
- chat_id=update.chat.id,
- text=Translation.HELP_TEXT,
- reply_markup=reply_markup,
- parse_mode="html",
- reply_to_message_id=update.message_id
- )
-
-
-@DonLee_Robot.on_message(filters.command(["about"]) & filters.private, group=1)
-async def about(bot, update):
-
- buttons = [[
- InlineKeyboardButton('Home ⚡', callback_data='start'),
- InlineKeyboardButton('Close 🔐', callback_data='close')
- ]]
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await bot.send_message(
- chat_id=update.chat.id,
- text=Translation.ABOUT_TEXT,
- reply_markup=reply_markup,
- disable_web_page_preview=True,
- parse_mode="html",
- reply_to_message_id=update.message_id
- )
diff --git a/DonLee_Robot/Plugins/Settings.py b/DonLee_Robot/Plugins/Settings.py
deleted file mode 100644
index 69c9edb73..000000000
--- a/DonLee_Robot/Plugins/Settings.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# !/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
-# Copyright permission under MIT License
-# All rights reserved by PR0FESS0R-99
-# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-
-import re
-from pyrogram import Client, filters
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-from DonLee_Robot.donlee_robot import DonLee_Robot
-from DonLee_Robot import VERIFY # pylint: disable=import-error
-
-@DonLee_Robot.on_message(filters.command(["settings"]) & filters.group, group=1)
-async def settings(bot, update):
-
- chat_id = update.chat.id
- user_id = update.from_user.id if update.from_user else None
- global VERIFY
-
- if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
- admin_list = []
- async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
- admin_id = x.user.id
- admin_list.append(admin_id)
- admin_list.append(None)
- VERIFY[str(chat_id)] = admin_list
-
- if not user_id in VERIFY.get(str(chat_id)): # Checks if user is admin of the chat
- return
-
- bot_info = await bot.get_me()
- bot_first_name= bot_info.first_name
-
- text =f"{bot_first_name}'s Settings Pannel.....\n"
- text+=f"\nYou Can Use This Menu To Change Connectivity And Know Status Of Your Every Connected Channel, Change Filter Types, Configure Filter Results And To Know Status Of Your Group..."
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "Channels", callback_data=f"channel_list({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "Filter Types", callback_data=f"types({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Configure 🛠", callback_data=f"config({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Status", callback_data=f"status({chat_id})"
- ),
-
- InlineKeyboardButton
- (
- "About", callback_data=f"about({chat_id})"
- )
- ],
- [
- InlineKeyboardButton
- (
- "Close 🔐", callback_data="close"
- )
- ]
- ]
-
- reply_markup = InlineKeyboardMarkup(buttons)
-
- await bot.send_message (
-
- chat_id=chat_id,
- text=text,
- reply_markup=reply_markup,
- parse_mode="html",
- reply_to_message_id=update.message_id
-
- )
-
-
-def remove_emoji(string):
- emoji_pattern = re.compile("["
- u"\U0001F600-\U0001F64F"
- u"\U0001F300-\U0001F5FF"
- u"\U0001F680-\U0001F6FF"
- u"\U0001F1E0-\U0001F1FF"
- u"\U00002500-\U00002BEF"
- u"\U00002702-\U000027B0"
- u"\U00002702-\U000027B0"
- u"\U000024C2-\U0001F251"
- u"\U0001f926-\U0001f937"
- u"\U00010000-\U0010ffff"
- u"\u2640-\u2642"
- u"\u2600-\u2B55"
- u"\u200d"
- u"\u23cf"
- u"\u23e9"
- u"\u231a"
- u"\ufe0f"
- u"\u3030"
- "]+", flags=re.UNICODE)
-
- return emoji_pattern.sub(r' ', str(string))
diff --git a/DonLee_Robot/Translation.py b/DonLee_Robot/Translation.py
deleted file mode 100644
index 7416bba19..000000000
--- a/DonLee_Robot/Translation.py
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-
-class Translation(object):
-
- START_TEXT = """🙋♂️Hey {}!!
-Am Just A Donlee Adv Auto Filter Bot....😉
-
-Just Add Me To Your Group And Channel And Connect Them And See My Pevers 🔥🔥😝
-Watch the video below to build an DonLee Adv Autofilter bot like me...
-Subscribe to the update channel to learn about my updates and activity...
-Press /help to know about available commands🤪"""
-
- HELP_TEXT = """
-How To Use Me!?
-
-
--> Add Me To Any Group And Make Me Admin
--> Add Me To Your Desired Channel
-
-
-Bot Commands (Works Only In Groups) :
-
- -> /add chat_id
- OR - To Connect A Group With A Channel (Bot Should Be Admin With Full Previlages In Both Group And Channel)
- /add @Username
-
- -> /del chat_id
- OR - To disconnect A Group With A Channel
- /del @Username
-
- -> /delall - This Command Will Disconnect All Connected Channel With The Group And Deletes All Its File From DB
-
- -> /settings - This Command Will Display You A Settings Pannel Instance Which Can Be Used To Tweek Bot's Settings Accordingly
-
- -> Channel - Button Will Show You All The Connected Chats With The Group And Will Show Buttons Correspnding To There Order For Furthur Controls
-
- -> Filter Types - Button Will Show You The 3 Filter Option Available In Bot... Pressing Each Buttons Will Either Enable or Disable Them And This Will Take Into Action As Soon As You Use Them Without The Need Of A Restart
-
- -> Configure - Button Will Helps You To Change No. of Pages/ Buttons Per Page/ Total Result Without Acutally Editing The Repo... Also It Provide Option To Enable/Disable For Showing Invite Link In Each Results
-
- -> Status - Button Will Shows The Stats Of Your Channel
-
-@Mo_Tech_YT
-"""
-
- ABOUT_TEXT = """➥ Name : Auto Filter Bot
-
-➥ Creator : Muhammed Rk
-
-➥ Language : Python3
-
-➥ Library : Pyrogram Asyncio 1.13.0
-
-➥ Source Code : Click Me
-"""
diff --git a/DonLee_Robot/User.py b/DonLee_Robot/User.py
deleted file mode 100644
index 4d47fa281..000000000
--- a/DonLee_Robot/User.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# !/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
-# Copyright permission under MIT License
-# All rights reserved by PR0FESS0R-99
-# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-
-from pyrogram import Client, __version__
-
-from . import API_HASH, APP_ID, LOGGER, \
- USER_SESSION
-
-
-class User(Client):
- def __init__(self):
- super().__init__(
- USER_SESSION,
- api_hash=API_HASH,
- api_id=APP_ID,
- workers=4
- )
- self.LOGGER = LOGGER
-
- async def start(self):
- await super().start()
- usr_bot_me = await self.get_me()
- return (self, usr_bot_me.id)
-
- async def stop(self, *args):
- await super().stop()
- self.LOGGER(__name__).info("Bot stopped. Bye.")
diff --git a/DonLee_Robot/__init__.py b/DonLee_Robot/__init__.py
deleted file mode 100644
index 719574f6e..000000000
--- a/DonLee_Robot/__init__.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# !/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
-# Copyright permission under MIT License
-# All rights reserved by PR0FESS0R-99
-# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-
-import os
-import logging
-import time
-
-from logging.handlers import RotatingFileHandler
-
-from .Translation import Translation
-
-# Change Accordingly While Deploying To A VPS
-# API_ID From https://youtu.be/5eEsvLAKVc0
-APP_ID = int(os.environ.get("APP_ID"))
-# API_HASH From https://youtu.be/5eEsvLAKVc0
-API_HASH = os.environ.get("API_HASH")
-# BOT_TOKEN From https://youtu.be/cB4UduCcNWs
-BOT_TOKEN = os.environ.get("BOT_TOKEN")
-# DD_URI From https://youtu.be/cB4UduCcNWs
-DB_URI = os.environ.get("DB_URI")
-# USER_SESSION From https://youtu.be/WUN_12-dYOM
-USER_SESSION = os.environ.get("USER_SESSION")
-
-VERIFY = {}
-
-logging.basicConfig(
- level=logging.INFO,
- format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",
- datefmt='%d-%b-%y %H:%M:%S',
- handlers=[
- RotatingFileHandler(
- "autofilterbot.txt",
- maxBytes=50000000,
- backupCount=10
- ),
- logging.StreamHandler()
- ]
-)
-logging.getLogger("pyrogram").setLevel(logging.WARNING)
-
-start_uptime = time.time()
-
-
-def LOGGER(name: str) -> logging.Logger:
- return logging.getLogger(name)
diff --git a/DonLee_Robot/__main__.py b/DonLee_Robot/__main__.py
deleted file mode 100644
index 1c62065e7..000000000
--- a/DonLee_Robot/__main__.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# !/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# (c) @AlbertEinsteinTG
-# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
-# Copyright permission under MIT License
-# All rights reserved by PR0FESS0R-99
-# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-
-from .donlee_robot import DonLee_Robot
-app = DonLee_Robot()
-app.run()
diff --git a/DonLee_Robot/donlee_robot.py b/DonLee_Robot/donlee_robot.py
deleted file mode 100644
index 92fc7d37f..000000000
--- a/DonLee_Robot/donlee_robot.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# (c) @SpEcHIDe
-# (c) @AlbertEinsteinTG
-# (e) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
-# Copyright permission under MIT License
-# All rights reserved by PR0FESS0R-99
-# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
-
-from pyrogram import Client, __version__
-
-from . import API_HASH, APP_ID, LOGGER, BOT_TOKEN
-
-from .User import User
-
-class DonLee_Robot(Client):
- USER: User = None
- USER_ID: int = None
-
- def __init__(self):
- super().__init__(
- "bot",
- api_hash=API_HASH,
- api_id=APP_ID,
- plugins={
- "root": "DonLee_Robot/Plugins"
- },
- workers=200,
- bot_token=BOT_TOKEN,
- sleep_threshold=10
- )
- self.LOGGER = LOGGER
-
- async def start(self):
- await super().start()
- bot_details = await self.get_me()
- self.set_parse_mode("html")
- self.LOGGER(__name__).info(
- f"@{bot_details.username} started! "
- )
- self.USER, self.USER_ID = await User().start()
-
- async def stop(self, *args):
- await super().stop()
- self.LOGGER(__name__).info("Bot stopped. Bye.")
From ef71ee1312641bfde72b5702153faf33d87d11db Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 09:56:05 +0530
Subject: [PATCH 48/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
New Update DonLee Robot Version 2.9
---
app.json | 54 ++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 10 deletions(-)
diff --git a/app.json b/app.json
index 70fdbee45..d06882916 100644
--- a/app.json
+++ b/app.json
@@ -1,24 +1,28 @@
{
- "name": "Auto Filter Bot V2",
- "description": "A Filter Bot Which Doesnt Need Manuall Filter Adding",
- "logo": "https://telegra.ph/file/667e15c821117633d07bd.png",
+ "name": "DonLee AutoFilter V2.9",
+ "description": "iam Adv Auto Filter Bot Version 2.9",
+ "logo": "https://telegra.ph/file/92daa86a5ceb28fa6962d.jpg",
"keywords": [
"Auto",
"Filter",
- "Mongo DB"
+ "v2.9"
],
- "website": "https://github.com/AlbertEinsteinTG",
- "repository": "https://github.com/AlbertEinsteinTG/Adv-Auto-Filter-Bot-V2",
- "success_url": "https://telegram.dog/CrazyBotsz",
+ "website": "https://youtube.com/channel/UCmGBpXoM-OEm-FacOccVKgQ",
+ "repository": "https://github.com/PR0FESS0R-99/DonLee_Robot/tree/MoTech",
+ "success_url": "https://youtube.com/channel/UCmGBpXoM-OEm-FacOccVKgQ",
"env": {
"APP_ID": {
- "description": "Your APP ID From my.telegram.org or @UseTGXBot",
+ "description": "Your APP ID From my.telegram.org or @MT_MytelegramOrg_Bot",
"value": ""
},
"API_HASH": {
- "description": "Your API Hash From my.telegram.org or @UseTGXBot",
+ "description": "Your API Hash From my.telegram.org or @MT_MytelegramOrg_Bot",
"value": ""
},
+ "BOT_NAME": {
+ "description": "Enter Your Bot Name From @BotFather",
+ "value": "DonLee_Robot"
+ },
"BOT_TOKEN": {
"description": "Your Bot Token From @BotFather",
"value": ""
@@ -27,8 +31,38 @@
"description": "Your Mongo DB URL Obtained From mongodb.com",
"value": ""
},
+ "SIZE_BUTTON": {
+ "description": "How To Use This Key Watch Tutorial Video - ()",
+ "value": "",
+ "required": false
+ },
+ "FSUB_TEXT": {
+ "description": "Forces Subscribers Text",
+ "value": "",
+ "required": false
+ },
+ "KITTUMO": {
+ "description": "Ayakko kitto sadhanangal 🤣",
+ "value": "ayakko kitto kittumo tharo tharumo ayakkamo send undo undaavo"
+ },
+ "EXPELL": {
+ "description": "The words if contained should be rejected",
+ "value": "movie Movie"
+ },
+ "IN_EXPELL": {
+ "description": "The words in Expelled you're okay with",
+ "value": "scary Scary emoji Emoji"
+ },
+ "OWNER_ID": {
+ "description": "You're id From @MT_Id_Bot",
+ "value": "1876193641"
+ },
"USER_SESSION": {
- "description": "A Pyrogram User Session String. Generated From @PyrogramStringBot",
+ "description": "A Pyrogram User Session String. Generated From @MT_usersession_Bot",
+ "value": ""
+ },
+ "FORCES_SUB": {
+ "description": "update Channel UserName (Without @)",
"value": ""
}
},
From 4fd20378e26efecbb0c2d0f047ebec0288a81ffb Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 09:57:49 +0530
Subject: [PATCH 49/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
New Update IMDB DonLee Robot @Mrk_YT
---
requirements.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/requirements.txt b/requirements.txt
index 57971149c..c56223baa 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,4 +3,7 @@ Motor
Pyrogram
Pymongo
Requests
-TgCrypto
+TgCrypto
+IMDbPY
+asyncio
+aiofiles
From 03a958f35a32792c8eee56aa9aab53a7fc90fecd Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 09:58:33 +0530
Subject: [PATCH 50/77] Create MoTech
---
DonLee_Robot/MoTech | 1 +
1 file changed, 1 insertion(+)
create mode 100644 DonLee_Robot/MoTech
diff --git a/DonLee_Robot/MoTech b/DonLee_Robot/MoTech
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/DonLee_Robot/MoTech
@@ -0,0 +1 @@
+
From df0333f2f1b1523bf48b1f6ff469ee5bd08ed7ee Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 09:59:53 +0530
Subject: [PATCH 51/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
NEW Updates DONLEE VERSION 2 ADDED IMDB SUPPORT
---
DonLee_Robot/Simple_Config.py | 19 +++++++++++++
DonLee_Robot/Translation.py | 53 +++++++++++++++++++++++++++++++++++
DonLee_Robot/User.py | 30 ++++++++++++++++++++
DonLee_Robot/__init__.py | 44 +++++++++++++++++++++++++++++
DonLee_Robot/__main__.py | 10 +++++++
DonLee_Robot/donlee_robot.py | 40 ++++++++++++++++++++++++++
6 files changed, 196 insertions(+)
create mode 100644 DonLee_Robot/Simple_Config.py
create mode 100644 DonLee_Robot/Translation.py
create mode 100644 DonLee_Robot/User.py
create mode 100644 DonLee_Robot/__init__.py
create mode 100644 DonLee_Robot/__main__.py
create mode 100644 DonLee_Robot/donlee_robot.py
diff --git a/DonLee_Robot/Simple_Config.py b/DonLee_Robot/Simple_Config.py
new file mode 100644
index 000000000..93c57a95a
--- /dev/null
+++ b/DonLee_Robot/Simple_Config.py
@@ -0,0 +1,19 @@
+import os
+from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
+class Mo_Tech_YT(object):
+ MO_TECH_YT_01 = InlineKeyboardMarkup
+ MO_TECH_YT_02 = InlineKeyboardButton
+ MO_TECH_YT_03 = os.environ.get("DB_URI")
+ MO_TECH_YT_04 = os.environ.get("DB_NAME", "mOtech")
+ MO_TECH_YT_05 = os.environ.get("EXPELL").split()
+ MO_TECH_YT_06 = os.environ.get("KITTUMO")
+ MO_TECH_YT_07 = bool(os.environ.get("SIZE_BUTTON"))
+ MO_TECH_YT_08 = os.environ.get("IN_EXPELL").split()
+ MO_TECH_YT_09 = set(int(x) for x in os.environ.get("OWNER_ID", "").split())
+ MO_TECH_YT_10 = int(os.environ.get("APP_ID"))
+ MO_TECH_YT_11 = os.environ.get("API_HASH")
+ MO_TECH_YT_12 = os.environ.get("BOT_TOKEN")
+ MO_TECH_YT_13 = os.environ.get("PHOTTO", "https://telegra.ph/file/7d04d3370126136c9c7a9.jpg")
+ text = "Join My Update Channel"
+ MO_TECH_YT_14 = os.environ.get("FSUB_TEXT", text)
+ MO_TECH_YT_15 = os.environ.get("FORCES_SUB", "Mo_Tech_YT")
diff --git a/DonLee_Robot/Translation.py b/DonLee_Robot/Translation.py
new file mode 100644
index 000000000..bc379f9c3
--- /dev/null
+++ b/DonLee_Robot/Translation.py
@@ -0,0 +1,53 @@
+import os
+class Translation(object):
+
+ START_TEXT = """🙋♂️Hey {}!!
+
+Am Just A Pro Auto Filter Bot....😉
+
+Just Add Me To Your Group And Channel And Connect Them And See My Pevers 🔥🔥😝
+
+Subscribe to the update channel to learn about my updates and activity...
+
+Press /help to know about available commands🤪
+
+Maintained By @Mo_Tech_YT"""
+
+ HELP_TEXT = """
+Notice
+Imdb Poster Imdb is available on this bot
+Rating Not Available
+
+Bot Commands (Works Only In Groups)
+
+☞ /add chat_id - To Connect A Group With A Channel (Bot Should Be Admin With Full Previlages In Both Group And Channel)
+
+☞ /del chat_id - To disconnect A Group With A Channel
+
+☞ /delall - This Command Will Disconnect All Connected Channel With The Group And Deletes All Its File From DB
+
+☞ /settings - This Command Will Display You A Settings Pannel Instance Which Can Be Used To Tweek Bot's Settings Accordingly
+
+ ☞ Channel - Button Will Show You All The Connected Chats With The Group And Will Show Buttons Correspnding To There Order For Furthur Controls
+
+ ☞ Filter Types - Button Will Show You The 3 Filter Option Available In Bot... Pressing Each Buttons Will Either Enable or Disable Them And This Will Take Into Action As Soon As You Use Them Without The Need Of A Restart
+
+ ☞ Configure - Button Will Helps You To Change No. of Pages/ Buttons Per Page/ Total Result Without Acutally Editing The Repo... Also It Provide Option To Enable/Disable For Showing Invite Link In Each Results
+
+ ☞ Status - Button Will Shows The Stats Of Your Channel
+
+Maintained By @Mo_Tech_YT"""
+
+ ABOUT_TEXT = """
+➥ 🤖Bot : Adv Auto Filter Bot v2.9
+
+➥ 😎Creator : @AlbertEinstein_TG
+
+➥ 👨💻Editor : @Mrk_YT
+
+➥ 🗣️Language : Python3
+
+➥ 📚Library : Pyrogram Asyncio 1.13.0
+
+➥ 📖Source Code : 💥Click Me
+"""
diff --git a/DonLee_Robot/User.py b/DonLee_Robot/User.py
new file mode 100644
index 000000000..1a8fe30b4
--- /dev/null
+++ b/DonLee_Robot/User.py
@@ -0,0 +1,30 @@
+# (c) @AlbertEinsteinTG
+# (c) @Muhammed_RK, @MRK_YT, @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+from pyrogram import Client, __version__
+
+from . import API_HASH, APP_ID, LOGGER, \
+ USER_SESSION
+
+
+class User(Client):
+ def __init__(self):
+ super().__init__(
+ USER_SESSION,
+ api_hash=API_HASH,
+ api_id=APP_ID,
+ workers=4
+ )
+ self.LOGGER = LOGGER
+
+ async def start(self):
+ await super().start()
+ usr_bot_me = await self.get_me()
+ return (self, usr_bot_me.id)
+
+ async def stop(self, *args):
+ await super().stop()
+ self.LOGGER(__name__).info("Bot stopped. Bye.")
diff --git a/DonLee_Robot/__init__.py b/DonLee_Robot/__init__.py
new file mode 100644
index 000000000..bd48ee1fd
--- /dev/null
+++ b/DonLee_Robot/__init__.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @AlbertEinsteinTG & MRK_YT
+
+import os
+import logging
+import time
+
+from logging.handlers import RotatingFileHandler
+
+from .Translation import Translation
+from .Simple_Config import Mo_Tech_YT
+
+# Change Accordingly While Deploying To A VPS
+APP_ID = Mo_Tech_YT.MO_TECH_YT_10
+API_HASH = Mo_Tech_YT.MO_TECH_YT_11
+BOT_TOKEN = Mo_Tech_YT.MO_TECH_YT_12
+
+DB_URI = os.environ.get("DB_URI")
+
+USER_SESSION = os.environ.get("USER_SESSION")
+
+VERIFY = {}
+
+logging.basicConfig(
+ level=logging.INFO,
+ format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",
+ datefmt='%d-%b-%y %H:%M:%S',
+ handlers=[
+ RotatingFileHandler(
+ "autofilterbot.txt",
+ maxBytes=50000000,
+ backupCount=10
+ ),
+ logging.StreamHandler()
+ ]
+)
+logging.getLogger("pyrogram").setLevel(logging.WARNING)
+
+start_uptime = time.time()
+
+
+def LOGGER(name: str) -> logging.Logger:
+ return logging.getLogger(name)
diff --git a/DonLee_Robot/__main__.py b/DonLee_Robot/__main__.py
new file mode 100644
index 000000000..fece727cc
--- /dev/null
+++ b/DonLee_Robot/__main__.py
@@ -0,0 +1,10 @@
+# (c) @AlbertEinsteinTG
+# (c) @Muhammed_RK, @MRK_YT, @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+from .donlee_robot import DonLee_Robot
+
+app = DonLee_Robot()
+app.run()
diff --git a/DonLee_Robot/donlee_robot.py b/DonLee_Robot/donlee_robot.py
new file mode 100644
index 000000000..a0283205c
--- /dev/null
+++ b/DonLee_Robot/donlee_robot.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# (c) @SpEcHIDe
+
+from pyrogram import Client, __version__
+
+from . import API_HASH, APP_ID, LOGGER, BOT_TOKEN
+
+from .User import User
+
+class DonLee_Robot(Client):
+ USER: User = None
+ USER_ID: int = None
+
+ def __init__(self):
+ super().__init__(
+ "DonLee_Robot",
+ api_hash=API_HASH,
+ api_id=APP_ID,
+ plugins={
+ "root": "DonLee_Robot/Modules"
+ },
+ workers=400,
+ bot_token=BOT_TOKEN,
+ sleep_threshold=10
+ )
+ self.LOGGER = LOGGER
+
+ async def start(self):
+ await super().start()
+ bot_details = await self.get_me()
+ self.set_parse_mode("html")
+ self.LOGGER(__name__).info(
+ f"@{bot_details.username} started! "
+ )
+ self.USER, self.USER_ID = await User().start()
+
+ async def stop(self, *args):
+ await super().stop()
+ self.LOGGER(__name__).info("Bot stopped. Bye.")
From ecd4df30ba182c307908c360cd1562e7f8c976cb Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:00:07 +0530
Subject: [PATCH 52/77] Delete MoTech
---
DonLee_Robot/MoTech | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 DonLee_Robot/MoTech
diff --git a/DonLee_Robot/MoTech b/DonLee_Robot/MoTech
deleted file mode 100644
index 8b1378917..000000000
--- a/DonLee_Robot/MoTech
+++ /dev/null
@@ -1 +0,0 @@
-
From 08772bc1409707bff058c12bfbe69f269189a699 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:01:42 +0530
Subject: [PATCH 53/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/__init__.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/DonLee_Robot/__init__.py b/DonLee_Robot/__init__.py
index bd48ee1fd..4802b191d 100644
--- a/DonLee_Robot/__init__.py
+++ b/DonLee_Robot/__init__.py
@@ -15,10 +15,7 @@
APP_ID = Mo_Tech_YT.MO_TECH_YT_10
API_HASH = Mo_Tech_YT.MO_TECH_YT_11
BOT_TOKEN = Mo_Tech_YT.MO_TECH_YT_12
-
-DB_URI = os.environ.get("DB_URI")
-
-USER_SESSION = os.environ.get("USER_SESSION")
+USER_SESSION = Mo_Tech_YT.MO_TECH_YT_16
VERIFY = {}
From 1a452cbb7c9fba081bc2ed77e95189c4205d8048 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:02:17 +0530
Subject: [PATCH 54/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Simple_Config.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/DonLee_Robot/Simple_Config.py b/DonLee_Robot/Simple_Config.py
index 93c57a95a..811949515 100644
--- a/DonLee_Robot/Simple_Config.py
+++ b/DonLee_Robot/Simple_Config.py
@@ -17,3 +17,4 @@ class Mo_Tech_YT(object):
text = "Join My Update Channel"
MO_TECH_YT_14 = os.environ.get("FSUB_TEXT", text)
MO_TECH_YT_15 = os.environ.get("FORCES_SUB", "Mo_Tech_YT")
+ MO_TECH_YT_16 = os.environ.get("USER_SESSION")
From fe4d5d6dd09c22a45b868ba03741005782e1801d Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:02:49 +0530
Subject: [PATCH 55/77] Create MoTech.md
---
DonLee_Robot/Modules/MoTech.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 DonLee_Robot/Modules/MoTech.md
diff --git a/DonLee_Robot/Modules/MoTech.md b/DonLee_Robot/Modules/MoTech.md
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/DonLee_Robot/Modules/MoTech.md
@@ -0,0 +1 @@
+
From eee1b53e71330452aac5f7f2f8f53acec67583b5 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:03:21 +0530
Subject: [PATCH 56/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Modules/__init__.py | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 DonLee_Robot/Modules/__init__.py
diff --git a/DonLee_Robot/Modules/__init__.py b/DonLee_Robot/Modules/__init__.py
new file mode 100644
index 000000000..160190019
--- /dev/null
+++ b/DonLee_Robot/Modules/__init__.py
@@ -0,0 +1,2 @@
+from .Filters import Database
+from .Channel import DEPLOY, HEROKU
From c7bd3ce629d5d87216f1fe5d46e0b718e38823c7 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:04:08 +0530
Subject: [PATCH 57/77] Create MoTech.md
---
DonLee_Robot/Modules/Channel/MoTech.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 DonLee_Robot/Modules/Channel/MoTech.md
diff --git a/DonLee_Robot/Modules/Channel/MoTech.md b/DonLee_Robot/Modules/Channel/MoTech.md
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/DonLee_Robot/Modules/Channel/MoTech.md
@@ -0,0 +1 @@
+
From 810eedbfef58783b2726f4d1329eb31e7618a273 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:04:36 +0530
Subject: [PATCH 58/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Modules/Channel/Connect_Channel.py | 363 ++++++++++++++++++
DonLee_Robot/Modules/Channel/__init__.py | 2 +
2 files changed, 365 insertions(+)
create mode 100644 DonLee_Robot/Modules/Channel/Connect_Channel.py
create mode 100644 DonLee_Robot/Modules/Channel/__init__.py
diff --git a/DonLee_Robot/Modules/Channel/Connect_Channel.py b/DonLee_Robot/Modules/Channel/Connect_Channel.py
new file mode 100644
index 000000000..03dff69a2
--- /dev/null
+++ b/DonLee_Robot/Modules/Channel/Connect_Channel.py
@@ -0,0 +1,363 @@
+# (C) AlbertEinstein_TG
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+import random
+import string
+import asyncio
+
+from pyrogram import Client, filters
+from pyrogram.errors import UserAlreadyParticipant, FloodWait
+
+from DonLee_Robot import VERIFY
+from DonLee_Robot.donlee_robot import DonLee_Robot
+from DonLee_Robot.Modules.Filters import Database, recacher
+
+db = Database()
+
+@Client.on_message(filters.command(["add"]) & filters.group, group=1)
+async def connect(bot: DonLee_Robot, update):
+ """
+ A Funtion To Handle Incoming /add Command TO COnnect A Chat With Group
+ """
+ chat_id = update.chat.id
+ user_id = update.from_user.id if update.from_user else None
+ target_chat = update.text.split(None, 1)
+ global VERIFY
+
+ if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
+ admin_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+ admin_list.append(None)
+ VERIFY[str(chat_id)] = admin_list
+
+ if not user_id in VERIFY.get(str(chat_id)):
+ return
+
+ try:
+ if target_chat[1].startswith("@"):
+ if len(target_chat[1]) < 5:
+ await update.reply_text("Invalid Username...!!!")
+ return
+ target = target_chat[1]
+
+ elif not target_chat[1].startswith("@"):
+ if len(target_chat[1]) < 14:
+ await update.reply_text("Invalid Chat Id...\nChat ID Should Be Something Like This: -100xxxxxxxxxx")
+ return
+ target = int(target_chat[1])
+
+ except Exception:
+ await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
+ return
+
+ try:
+ join_link = await bot.export_chat_invite_link(target)
+ except Exception as e:
+ print(e)
+ await update.reply_text(f"Make Sure Im Admin At {target} And Have Permission For 'Inviting Users via Link' And Try Again.....!!!")
+ return
+
+ userbot_info = await bot.USER.get_me()
+ userbot_id = userbot_info.id
+ userbot_name = userbot_info.first_name
+
+ try:
+ await bot.USER.join_chat(join_link)
+
+ except UserAlreadyParticipant:
+ pass
+
+ except Exception:
+ await update.reply_text(f"My UserBot [{userbot_name}](tg://user?id={userbot_id}) Couldnt Join The Channel `{target}` Make Sure Userbot Is Not Banned There Or Add It Manually And Try Again....!!")
+ return
+
+ try:
+ c_chat = await bot.get_chat(target)
+ channel_id = c_chat.id
+ channel_name = c_chat.title
+
+ except Exception as e:
+ await update.reply_text("Encountered Some Issue..Please Check Logs..!!")
+ raise e
+
+
+ in_db = await db.in_db(chat_id, channel_id)
+
+ if in_db:
+ await update.reply_text("Channel Aldready In Db...!!!")
+ return
+
+ wait_msg = await update.reply_text("Please Wait Till I Add All Your Files From Channel To Db\n\nThis May Take 10 or 15 Mins Depending On Your No. Of Files In Channel.....\n\nUntil Then Please Dont Sent Any Other Command Or This Operation May Be Intrupted....")
+
+ try:
+ type_list = ["video", "audio", "document"]
+ data = []
+ skipCT = 0
+
+ for typ in type_list:
+
+ async for msgs in bot.USER.search_messages(channel_id,filter=typ): #Thanks To @PrgOfficial For Suggesting
+
+ # Using 'if elif' instead of 'or' to determine 'file_type'
+ # Better Way? Make A PR
+ try:
+ if msgs.video:
+ try:
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except FloodWait as e:
+ asyncio.sleep(e.x)
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except Exception as e:
+ print(e)
+ continue
+ file_id = file_id.video.file_id
+ file_name = msgs.video.file_name[0:-4]
+ file_caption = msgs.caption if msgs.caption else ""
+ file_size = msgs.video.file_size
+ file_type = "video"
+
+ elif msgs.audio:
+ try:
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except FloodWait as e:
+ asyncio.sleep(e.x)
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except Exception as e:
+ print(e)
+ continue
+ file_id = file_id.audio.file_id
+ file_name = msgs.audio.file_name[0:-4]
+ file_caption = msgs.caption if msgs.caption else ""
+ file_size = msgs.audio.file_size
+ file_type = "audio"
+
+ elif msgs.document:
+ try:
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except FloodWait as e:
+ asyncio.sleep(e.x)
+ file_id = await bot.get_messages(channel_id, message_ids=msgs.message_id)
+ except Exception as e:
+ print(str(e))
+ continue
+ file_id = file_id.document.file_id
+ file_name = msgs.document.file_name[0:-4]
+ file_caption = msgs.caption if msgs.caption else ""
+ file_size = msgs.document.file_size
+ file_type = "document"
+
+ for i in ["_", "|", "-", "."]: # Work Around
+ try:
+ file_name = file_name.replace(i, " ")
+ except Exception:
+ pass
+
+ file_link = msgs.link
+ group_id = chat_id
+ unique_id = ''.join(
+ random.choice(
+ string.ascii_lowercase +
+ string.ascii_uppercase +
+ string.digits
+ ) for _ in range(15)
+ )
+
+ dicted = dict(
+ file_id=file_id, # Done
+ unique_id=unique_id,
+ file_name=file_name,
+ file_caption=file_caption,
+ file_size=file_size,
+ file_type=file_type,
+ file_link=file_link,
+ chat_id=channel_id,
+ group_id=group_id,
+ )
+
+ data.append(dicted)
+ except Exception as e:
+ if 'NoneType' in str(e): # For Some Unknown Reason Some File Names are NoneType
+ skipCT +=1
+ continue
+ print(e)
+
+ print(f"{skipCT} Files Been Skipped Due To File Name Been None..... #BlameTG")
+ except Exception as e:
+ await wait_msg.edit_text("Couldnt Fetch Files From Channel... Please look Into Logs For More Details")
+ raise e
+
+ await db.add_filters(data)
+ await db.add_chat(chat_id, channel_id, channel_name)
+ await recacher(chat_id, True, True, bot, update)
+
+ await wait_msg.edit_text(f"Channel Was Sucessfully Added With {len(data)} Files..")
+
+
+@Client.on_message(filters.command(["del"]) & filters.group, group=1)
+async def disconnect(bot: DonLee_Robot, update):
+ """
+ A Funtion To Handle Incoming /del Command TO Disconnect A Chat With A Group
+ """
+ chat_id = update.chat.id
+ user_id = update.from_user.id if update.from_user else None
+ target_chat = update.text.split(None, 1)
+ global VERIFY
+
+ if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
+ admin_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+ admin_list.append(None)
+ VERIFY[str(chat_id)] = admin_list
+
+ if not user_id in VERIFY.get(str(chat_id)):
+ return
+
+ try:
+ if target_chat[1].startswith("@"):
+ if len(target_chat[1]) < 5:
+ await update.reply_text("Invalid Username...!!!")
+ return
+ target = target_chat[1]
+
+ elif not target_chat.startswith("@"):
+ if len(target_chat[1]) < 14:
+ await update.reply_text("Invalid Chat Id...\nChat ID Should Be Something Like This: -100xxxxxxxxxx")
+ return
+ target = int(target_chat[1])
+
+ except Exception:
+ await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
+ return
+
+ userbot = await bot.USER.get_me()
+ userbot_name = userbot.first_name
+ userbot_id = userbot.id
+
+ try:
+ channel_info = await bot.USER.get_chat(target)
+ channel_id = channel_info.id
+ except Exception:
+ await update.reply_text(f"My UserBot [{userbot_name}](tg://user?id={userbot_id}) Couldnt Fetch Details Of `{target}` Make Sure Userbot Is Not Banned There Or Add It Manually And Try Again....!!")
+ return
+
+ in_db = await db.in_db(chat_id, channel_id)
+
+ if not in_db:
+ await update.reply_text("This Channel Is Not Connected With The Group...")
+ return
+
+ wait_msg = await update.reply_text("Deleting All Files Of This Channel From DB....!!!\n\nPlease Be Patience...Dont Sent Another Command Until This Process Finishes..")
+
+ await db.del_filters(chat_id, channel_id)
+ await db.del_active(chat_id, channel_id)
+ await db.del_chat(chat_id, channel_id)
+ await recacher(chat_id, True, True, bot, update)
+
+ await wait_msg.edit_text("Sucessfully Deleted All Files From DB....")
+
+
+@Client.on_message(filters.command(["delall"]) & filters.group, group=1)
+async def delall(bot: DonLee_Robot, update):
+ """
+ A Funtion To Handle Incoming /delall Command TO Disconnect All Chats From A Group
+ """
+ chat_id=update.chat.id
+ user_id = update.from_user.id if update.from_user else None
+ global VERIFY
+
+ if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
+ admin_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+ admin_list.append(None)
+ VERIFY[str(chat_id)] = admin_list
+
+ if not user_id in VERIFY.get(str(chat_id)):
+ return
+
+ await db.delete_all(chat_id)
+ await recacher(chat_id, True, True, bot, update)
+
+ await update.reply_text("Sucessfully Deleted All Connected Chats From This Group....")
+
+
+@Client.on_message(filters.channel & (filters.video | filters.audio | filters.document) & ~filters.edited, group=0)
+async def new_files(bot: DonLee_Robot, update):
+ """
+ A Funtion To Handle Incoming New Files In A Channel ANd Add Them To Respective Channels..
+ """
+ channel_id = update.chat.id
+
+ # Using 'if elif' instead of 'or' to determine 'file_type'
+ # Better Way? Make A PR
+
+ try:
+ if update.video:
+ file_type = "video"
+ file_id = update.video.file_id
+ file_name = update.video.file_name[0:-4]
+ file_caption = update.caption if update.caption else ""
+ file_size = update.video.file_size
+
+ elif update.audio:
+ file_type = "audio"
+ file_id = update.audio.file_id
+ file_name = update.audio.file_name[0:-4]
+ file_caption = update.caption if update.caption else ""
+ file_size = update.audio.file_size
+
+ elif update.document:
+ file_type = "document"
+ file_id = update.document.file_id
+ file_name = update.document.file_name[0:-4]
+ file_caption = update.caption if update.caption else ""
+ file_size = update.document.file_size
+
+ for i in ["_", "|", "-", "."]: # Work Around
+ try:
+ file_name = file_name.replace(i, " ")
+ except Exception:
+ pass
+ except Exception as e:
+ print(e)
+ return
+
+
+ file_link = update.link
+ group_ids = await db.find_group_id(channel_id)
+ unique_id = ''.join(
+ random.choice(
+ string.ascii_lowercase +
+ string.ascii_uppercase +
+ string.digits
+ ) for _ in range(15)
+ )
+
+ data = []
+
+ if group_ids:
+ for group_id in group_ids:
+ data_packets = dict(
+ file_id=file_id, # File Id For Future Updates Maybe...
+ unique_id=unique_id,
+ file_name=file_name,
+ file_caption=file_caption,
+ file_size = file_size,
+ file_type=file_type,
+ file_link=file_link,
+ chat_id=channel_id,
+ group_id=group_id,
+ )
+
+ data.append(data_packets)
+ await db.add_filters(data)
+ return
+
+runing = """Team mo tech"""
diff --git a/DonLee_Robot/Modules/Channel/__init__.py b/DonLee_Robot/Modules/Channel/__init__.py
new file mode 100644
index 000000000..12ecdaaba
--- /dev/null
+++ b/DonLee_Robot/Modules/Channel/__init__.py
@@ -0,0 +1,2 @@
+DEPLOY = "DEPLOY"
+HEROKU = "t.me/Mo_Tech_YT"
From d3485b422595b56ad544cbae988b56a21297fbf1 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:04:55 +0530
Subject: [PATCH 59/77] Delete MoTech.md
---
DonLee_Robot/Modules/MoTech.md | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 DonLee_Robot/Modules/MoTech.md
diff --git a/DonLee_Robot/Modules/MoTech.md b/DonLee_Robot/Modules/MoTech.md
deleted file mode 100644
index 8b1378917..000000000
--- a/DonLee_Robot/Modules/MoTech.md
+++ /dev/null
@@ -1 +0,0 @@
-
From c1a97268ceb597f353544d377dc746a184bc7d82 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:05:10 +0530
Subject: [PATCH 60/77] Delete MoTech.md
---
DonLee_Robot/Modules/Channel/MoTech.md | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 DonLee_Robot/Modules/Channel/MoTech.md
diff --git a/DonLee_Robot/Modules/Channel/MoTech.md b/DonLee_Robot/Modules/Channel/MoTech.md
deleted file mode 100644
index 8b1378917..000000000
--- a/DonLee_Robot/Modules/Channel/MoTech.md
+++ /dev/null
@@ -1 +0,0 @@
-
From a253b16e803d502c7f175e78e72e912fa36c18c8 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:13:45 +0530
Subject: [PATCH 61/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Modules/Channel/__init__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/DonLee_Robot/Modules/Channel/__init__.py b/DonLee_Robot/Modules/Channel/__init__.py
index 12ecdaaba..66db6e99d 100644
--- a/DonLee_Robot/Modules/Channel/__init__.py
+++ b/DonLee_Robot/Modules/Channel/__init__.py
@@ -1,2 +1,2 @@
-DEPLOY = "DEPLOY"
-HEROKU = "t.me/Mo_Tech_YT"
+DEPLOY = "💡 DEPLOY NOW 💡"
+HEROKU = "https://youtu.be/lI71HsWzTKE"
From 044f8828f3e6fa3c8daafe4b8ec3dfd8e1726a3d Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:19:53 +0530
Subject: [PATCH 62/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Modules/Commands/Commands.py | 170 ++++++++++++++++++++++
1 file changed, 170 insertions(+)
create mode 100644 DonLee_Robot/Modules/Commands/Commands.py
diff --git a/DonLee_Robot/Modules/Commands/Commands.py b/DonLee_Robot/Modules/Commands/Commands.py
new file mode 100644
index 000000000..4cf97e936
--- /dev/null
+++ b/DonLee_Robot/Modules/Commands/Commands.py
@@ -0,0 +1,170 @@
+# (c) @SpEcHIDe
+# (c) @AlbertEinsteinTG
+# (c) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+from pyrogram import filters, Client
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
+from pyrogram.errors import UserNotParticipant
+from DonLee_Robot import Translation, LOGGER, Mo_Tech_YT
+from DonLee_Robot.Modules.Filters import Database
+from DonLee_Robot.donlee_robot import DonLee_Robot
+from DonLee_Robot.Modules import DEPLOY, HEROKU
+db = Database()
+
+@DonLee_Robot.on_message(filters.command(["start"]) & filters.private, group=1)
+async def start(bot, update):
+ update_channel = Mo_Tech_YT.MO_TECH_YT_15
+ if update_channel:
+ try:
+ user = await bot.get_chat_member(update_channel, update.chat.id)
+ if user.status == "kicked out":
+ await update.reply_text("😔 Sorry Dude, You are **🅱︎🅰︎🅽︎🅽︎🅴︎🅳︎ 🤣🤣🤣**")
+ return
+ except UserNotParticipant:
+ #await update.reply_text(f"Join @{update_channel} To Use Me")
+ await update.reply_text(
+ text=Mo_Tech_YT.MO_TECH_YT_14,
+ reply_markup=InlineKeyboardMarkup([
+ [ InlineKeyboardButton(text=" 📢 Join My Update Channel 📢", url=f"https://t.me/{Mo_Tech_YT.MO_TECH_YT_15}")]
+ ])
+ )
+ return
+ except Exception:
+ await update.reply_text(f"This bot should be the admin on your update channel\n\n💢 ഈ ചാനലിൽ @{Mo_Tech_YT.MO_TECH_YT_15} ബോട്ടിനെ അഡ്മിൻ ആക്. എന്നിട്ട് /start കൊടുക്\n\n🗣️ any Doubt @Mo_Tech_Group")
+ return
+ try:
+ file_uid = update.command[1]
+ except IndexError:
+ file_uid = False
+
+ if file_uid:
+ file_id, file_name, file_caption, file_type = await db.get_file(file_uid)
+
+ if (file_id or file_type) == None:
+ return
+
+ caption = file_caption if file_caption != ("" or None) else ("" + file_name + "")
+ try:
+ await update.reply_cached_media(
+ file_id,
+ quote=True,
+ caption = caption,
+ parse_mode="html",
+ reply_markup=InlineKeyboardMarkup(
+ [
+ [
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ DEPLOY, url=HEROKU
+ )
+ ]
+ ]
+ )
+ )
+ except Exception as e:
+ await update.reply_text(f"Error:\n{e}", True, parse_mode="html")
+ LOGGER(__name__).error(e)
+ return
+
+ buttons = [
+ [
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ '📢Update Channel', url='t.me/Mo_Tech_YT'
+ ),
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ '💡More Botz', url='t.me/MT_Botz'
+ )
+ ],
+ [
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ DEPLOY, url=HEROKU
+ )
+ ],
+ [
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ '🚶Help', callback_data='help'
+ )
+ ]
+ ]
+
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.START_TEXT.format(
+ update.from_user.first_name),
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
+
+@DonLee_Robot.on_message(filters.command(["help"]) & filters.private, group=1)
+async def help(bot, update):
+ buttons = [
+ [
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ DEPLOY, url=HEROKU
+ )
+ ],
+ [
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ '🏡 Home', callback_data='start'
+ ),
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ 'About💡', callback_data='about'
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.HELP_TEXT,
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
+
+
+@DonLee_Robot.on_message(filters.command(["about"]) & filters.private, group=1)
+async def about(bot, update):
+
+ buttons = [
+ [
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ DEPLOY, url=HEROKU
+ )
+ ],
+ [
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ '🏠 Home', callback_data='start'
+ ),
+ Mo_Tech_YT.MO_TECH_YT_02
+ (
+ 'Close ❌️', callback_data='close'
+ )
+ ]
+ ]
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=Translation.ABOUT_TEXT,
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
From 11624f83403725c78da4672b59de1a1fed463241 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:21:26 +0530
Subject: [PATCH 63/77] Create MoTech.txt
---
DonLee_Robot/Modules/Filters/MoTech.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 DonLee_Robot/Modules/Filters/MoTech.txt
diff --git a/DonLee_Robot/Modules/Filters/MoTech.txt b/DonLee_Robot/Modules/Filters/MoTech.txt
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/DonLee_Robot/Modules/Filters/MoTech.txt
@@ -0,0 +1 @@
+
From c264d1d2015b76c734834cc4f39e0f52d240e72e Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:22:28 +0530
Subject: [PATCH 64/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Modules/Filters/Callback.py | 1785 ++++++++++++++++++++++
DonLee_Robot/Modules/Filters/Filter.py | 399 +++++
DonLee_Robot/Modules/Filters/Main.py | 521 +++++++
DonLee_Robot/Modules/Filters/__init__.py | 2 +
4 files changed, 2707 insertions(+)
create mode 100644 DonLee_Robot/Modules/Filters/Callback.py
create mode 100644 DonLee_Robot/Modules/Filters/Filter.py
create mode 100644 DonLee_Robot/Modules/Filters/Main.py
create mode 100644 DonLee_Robot/Modules/Filters/__init__.py
diff --git a/DonLee_Robot/Modules/Filters/Callback.py b/DonLee_Robot/Modules/Filters/Callback.py
new file mode 100644
index 000000000..b663cf405
--- /dev/null
+++ b/DonLee_Robot/Modules/Filters/Callback.py
@@ -0,0 +1,1785 @@
+# (C) AlbertEinstein_TG
+# (C) @Nacbots IMDB SUPPORT ADDED
+# (E) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# (E) @Jackbro007
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+import re
+import time
+import asyncio
+from pyrogram import Client, filters
+from pyrogram.errors import FloodWait, UserNotParticipant
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
+from DonLee_Robot.donlee_robot import DonLee_Robot
+from DonLee_Robot import start_uptime, Translation, VERIFY
+from DonLee_Robot.Modules.Filters import FIND, INVITE_LINK, ACTIVE_CHATS, recacher, gen_invite_links
+from DonLee_Robot.Modules.Settings import remove_emoji
+from DonLee_Robot.Modules.Filters import Database
+from DonLee_Robot.Modules import DEPLOY, HEROKU
+db = Database()
+
+@DonLee_Robot.on_callback_query(filters.regex(r"navigate\((.+)\)"), group=2)
+async def cb_navg(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For The Next Button Appearing In Results
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ index_val, btn, query = re.findall(r"navigate\((.+)\)", query_data)[0].split("|", 2)
+ try:
+ ruser_id = update.message.reply_to_message.from_user.id
+ except Exception as e:
+ print(e)
+ ruser_id = None
+
+ admin_list = VERIFY.get(str(chat_id))
+ if admin_list == None: # Make Admin's ID List
+
+ admin_list = []
+
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+
+ admin_list.append(None) # Just For Anonymous Admin....
+ VERIFY[str(chat_id)] = admin_list
+
+ if not ((user_id == ruser_id) or (user_id in admin_list)): # Checks if user is same as requested user or is admin
+ await update.answer("Ask for your own movie 🤗",show_alert=True)
+ return
+
+
+ if btn == "next":
+ index_val = int(index_val) + 1
+ elif btn == "back":
+ index_val = int(index_val) - 1
+
+ achats = ACTIVE_CHATS[str(chat_id)]
+ configs = await db.find_chat(chat_id)
+ pm_file_chat = configs["configs"]["pm_fchat"]
+ show_invite = configs["configs"]["show_invite_link"]
+ show_invite = (False if pm_file_chat == True else show_invite)
+
+ results = FIND.get(query).get("results")
+ leng = FIND.get(query).get("total_len")
+ max_pages = FIND.get(query).get("max_pages")
+
+ try:
+ temp_results = results[index_val].copy()
+ except IndexError:
+ return # Quick Fix🏃🏃
+ except Exception as e:
+ print(e)
+ return
+
+ if ((index_val + 1 )== max_pages) or ((index_val + 1) == len(results)): # Max Pages
+ temp_results.append([
+ InlineKeyboardButton("⪻⪻", callback_data=f"navigate({index_val}|back|{query})")
+ ])
+
+ elif int(index_val) == 0:
+ pass
+
+ else:
+ temp_results.append([
+ InlineKeyboardButton("⪻⪻", callback_data=f"navigate({index_val}|back|{query})"),
+ InlineKeyboardButton("⪼⪼", callback_data=f"navigate({index_val}|next|{query})")
+ ])
+
+ len_result = len(results)
+ page_btn = "⓵ ❷ ❸ ❹ ❺"
+ if index_val+1 == 2 :
+ page_btn = "❶ ⓶ ❸ ❹ ❺"
+ elif index_val+1 == 3 :
+ page_btn = "❶ ❷ ⓷ ❹ ❺" #Being a pro🤣😂
+ elif index_val+1 == 4 :
+ page_btn = "❶ ❷ ❸ ⓸ ❺"
+ elif index_val+1 == 5 :
+ page_btn = "❶ ❷ ❸ ❹ ⓹"
+
+ cutter = len_result if len_result < max_pages else max_pages
+ page_btn = page_btn[:cutter*2]
+
+ if not int(index_val) == 0:
+ temp_results.append([
+ InlineKeyboardButton(f"📑 {page_btn} 📑", callback_data="ignore")
+ ])
+
+ if show_invite and int(index_val) !=0 :
+
+ ibuttons = []
+ achatId = []
+ await gen_invite_links(configs, chat_id, bot, update)
+
+ for x in achats["chats"] if isinstance(achats, dict) else achats:
+ achatId.append(int(x["chat_id"])) if isinstance(x, dict) else achatId.append(x)
+
+ for y in INVITE_LINK.get(str(chat_id)):
+
+ chat_id = int(y["chat_id"])
+
+ if chat_id not in achatId:
+ continue
+
+ chat_name = y["chat_name"]
+ invite_link = y["invite_link"]
+
+ if ((len(ibuttons)%2) == 0):
+ ibuttons.append(
+ [
+ InlineKeyboardButton
+ (
+ f"⚜ {chat_name} ⚜", url=invite_link
+ )
+ ]
+ )
+
+ else:
+ ibuttons[-1].append(
+ InlineKeyboardButton
+ (
+ f"⚜ {chat_name} ⚜", url=invite_link
+ )
+ )
+
+ for x in ibuttons:
+ temp_results.insert(0, x)
+ ibuttons = None
+ achatId = None
+
+ reply_markup = InlineKeyboardMarkup(temp_results)
+
+ text=f"🎬 Title : {query}\n🗃️ Total Files : {len_results if len_results <= max_pages*8 else max_pages*8}\n👤 Requested By : {update.from_user.mention}\n☑️ Chat : {update.chat.title}"
+
+ try:
+ await update.message.edit_caption(
+ caption=text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+ except Exception as e:
+ print(e)
+ try:
+ await update.message.edit(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+ except FloodWait as f: # Flood Wait Caused By Spamming Next/Back Buttons
+ await asyncio.sleep(f.x)
+ try:
+
+ await update.message.edit_caption(
+ caption=text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+ except Exception :
+ await update.message.edit(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+@DonLee_Robot.on_callback_query(filters.regex(r"settings"), group=2)
+async def cb_settings(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Back Button in /settings Command
+ """
+ global VERIFY
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)): # Check If User Is Admin
+ return
+
+ bot_status = await bot.get_me()
+ bot_fname= bot_status.first_name
+
+ text =f"{bot_fname}'s Settings Pannel.....\n"
+ text+=f"\nYou Can Use This Menu To Change Connectivity And Know Status Of Your Every Connected Channel, Change Filter Types, Configure Filter Results And To Know Status Of Your Group..."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "Channels", callback_data=f"channel_list({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Filter Types", callback_data=f"types({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Configure 🛠", callback_data=f"config({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Status", callback_data=f"status({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "About", callback_data=f"about({chat_id})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"warn\((.+)\)"), group=2)
+async def cb_warn(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Acknowledging User's About What Are They Upto
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:35]
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name, action = re.findall(r"warn\((.+)\)", query_data)[0].split("|", 2)
+
+ if action == "connect":
+ text=f"Are You Sure You Want To Enable Connection With {channel_name}..???\n"
+ text+=f"\nThis Will Show File Links From {channel_name} While Showing Results..."
+
+ elif action == "disconnect":
+ text=f"Are You Sure You Want To Disable {channel_name} Connection With The Group???....\n"
+ text+=f"\nThe DB Files Will Still Be There And You Can Connect Back To This Channel Anytime From Settings Menu Without Adding Files To DB Again...\n"
+ text+=f"\nThis Disabling Just Hide Results From The Filter Results..."
+
+ elif action == "c_delete":
+ text=f"Are You Sure You Want To Disconnect {channel_name} From This Group??\n"
+ text+=f"\nThis Will Delete Channel And All Its Files From DB Too....!!\n"
+ text+=f"\nYou Need To Add Channel Again If You Need To Shows It Result..."
+
+
+ elif action=="f_delete":
+ text=f"Are You Sure That You Want To Clear All Filter From This Chat {channel_name}???\n"
+ text+=f"\nThis Will Erase All Files From DB.."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "Yes", callback_data=f"{action}({channel_id}|{channel_name})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "No", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"channel_list\((.+)\)"), group=2)
+async def cb_channel_list(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Displaying All Channel List And Providing A Menu To Navigate
+ To Every COnnect Chats For Furthur Control
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:35]
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id = re.findall(r"channel_list\((.+)\)", query_data)[0]
+
+ text = "Semms Like You Dont Have Any Channel Connected...\n\nConnect To Any Chat To Continue With This Settings..."
+
+ db_list = await db.find_chat(int(chat_id))
+
+ channel_id_list = []
+ channel_name_list = []
+
+ if db_list:
+ for x in db_list["chat_ids"]:
+ channel_id = x["chat_id"]
+ channel_name = x["chat_name"]
+
+ try:
+ if (channel_id == None or channel_name == None):
+ continue
+ except:
+ break
+
+ channel_name = remove_emoji(channel_name).encode('ascii', 'ignore').decode('ascii')[:35]
+ channel_id_list.append(channel_id)
+ channel_name_list.append(channel_name)
+
+ buttons = []
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data="settings"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ )
+
+ if channel_name_list:
+
+ text=f"List Of Connected Channels With {chat_name} With There Settings..\n"
+
+ for x in range(1, (len(channel_name_list)+1)):
+ text+=f"\n{x}. {channel_name_list[x-1]}\n"
+
+ text += "\nChoose Appropriate Buttons To Navigate Through Respective Channels"
+
+
+ btn_key = [
+ "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟",
+ "1️⃣1️⃣", "1️⃣2️⃣", "1️⃣3️⃣", "1️⃣4️⃣", "1️⃣5️⃣", "1️⃣6️⃣", "1️⃣7️⃣",
+ "1️⃣8️⃣", "1️⃣9️⃣", "2️⃣0️⃣" # Just In Case 😂🤣
+ ]
+
+ for i in range(1, (len(channel_name_list) + 1)): # Append The Index Number of Channel In Just A Single Line
+ if i == 1:
+ buttons.insert(0,
+ [
+ InlineKeyboardButton
+ (
+ btn_key[i-1], callback_data=f"info({channel_id_list[i-1]}|{channel_name_list[i-1]})"
+ )
+ ]
+ )
+
+ else:
+ buttons[0].append(
+ InlineKeyboardButton
+ (
+ btn_key[i-1], callback_data=f"info({channel_id_list[i-1]}|{channel_name_list[i-1]})"
+ )
+ )
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text = text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"info\((.+)\)"), group=2)
+async def cb_info(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Displaying Details Of The Connected Chat And Provide
+ Ability To Connect / Disconnect / Delete / Delete Filters of That Specific Chat
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"info\((.+)\)", query_data)[0].split("|", 1)
+
+ f_count = await db.cf_count(chat_id, int(channel_id))
+ active_chats = await db.find_active(chat_id)
+
+ if active_chats: # Checks for active chats connected to a chat
+ dicts = active_chats["chats"]
+ db_cids = [ int(x["chat_id"]) for x in dicts ]
+
+ if int(channel_id) in db_cids:
+ active_chats = True
+ status = "Connected"
+
+ else:
+ active_chats = False
+ status = "Disconnected"
+
+ else:
+ active_chats = False
+ status = "Disconnected"
+
+ text=f"Info About {channel_name}\n"
+ text+=f"\nChannel Name: {channel_name}\n"
+ text+=f"\nChannel ID: {channel_id}\n"
+ text+=f"\nChannel Files: {f_count}\n"
+ text+=f"\nCurrent Status: {status}\n"
+
+
+ if active_chats:
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "🚨 Disconnect 🚨", callback_data=f"warn({channel_id}|{channel_name}|disconnect)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
+ )
+ ]
+ ]
+
+ else:
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "💠 Connect 💠", callback_data=f"warn({channel_id}|{channel_name}|connect)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
+ )
+ ]
+ ]
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
+ )
+ ]
+ )
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"channel_list({chat_id})"
+ )
+ ]
+ )
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"^connect\((.+)\)"), group=2)
+async def cb_connect(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Helping The user To Make A Chat Active Chat Which Will
+ Make The Bot To Fetch Results From This Channel Too
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"connect\((.+)\)", query_data)[0].split("|", 1)
+ channel_id = int(channel_id)
+
+ f_count = await db.cf_count(chat_id, channel_id)
+
+ add_active = await db.update_active(chat_id, channel_id, channel_name)
+
+ if not add_active:
+ await update.answer(f"{channel_name} Is Aldready in Active Connection", show_alert=True)
+ return
+
+ text= f"Sucessfully Connected To {channel_name}\n"
+ text+=f"\nInfo About {channel_name}\n"
+ text+=f"\nChannel Name: {channel_name}\n"
+ text+=f"\nChannel ID: {channel_id}\n"
+ text+=f"\nChannel Files: {f_count}\n"
+ text+=f"\nCurrent Status: Connected\n"
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "🚨 Disconnect 🚨", callback_data=f"warn({channel_id}|{channel_name}|disconnect)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
+ )
+ ]
+ ]
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
+ )
+ ]
+ )
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"channel_list({chat_id})"
+ )
+ ]
+ )
+ await recacher(chat_id, False, True, bot, update)
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"disconnect\((.+)\)"), group=2)
+async def cb_disconnect(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Helping The user To Make A Chat inactive Chat Which Will
+ Make The Bot To Avoid Fetching Results From This Channel
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"connect\((.+)\)", query_data)[0].split("|", 1)
+
+ f_count = await db.cf_count(chat_id, int(channel_id))
+
+ remove_active = await db.del_active(chat_id, int(channel_id))
+
+ if not remove_active:
+ await update.answer("Couldnt Full Fill YOur Request...\n Report This @CrazyBotszGrp Along With Bot's Log", show_alert=True)
+ return
+
+ text= f"Sucessfully Disconnected From {channel_name}\n"
+ text+=f"\nInfo About {channel_name}\n"
+ text+=f"\nChannel Name: {channel_name}\n"
+ text+=f"\nChannel ID: {channel_id}\n"
+ text+=f"\nChannel Files: {f_count}\n"
+ text+=f"\nCurrent Status: Disconnected\n"
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "💠 Connect 💠", callback_data=f"warn({channel_id}|{channel_name}|connect)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Delete ❌", callback_data=f"warn({channel_id}|{channel_name}|c_delete)"
+ )
+ ]
+ ]
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete Filters ⚠", callback_data=f"warn({channel_id}|{channel_name}|f_delete)"
+ )
+ ]
+ )
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"channel_list({chat_id})"
+ )
+ ]
+ )
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await recacher(chat_id, False, True, bot, update)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"c_delete\((.+)\)"), group=2)
+async def cb_channel_delete(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Delete A Channel Connection From A Group Chat History
+ Along With All Its Filter Files
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"c_delete\((.+)\)", query_data)[0].split("|", 1)
+ channel_id = int(channel_id)
+
+ c_delete = await db.del_chat(chat_id, channel_id)
+ a_delete = await db.del_active(chat_id, channel_id) # pylint: disable=unused-variable
+ f_delete = await db.del_filters(chat_id, channel_id)
+
+ if (c_delete and f_delete ):
+ text=f"{channel_name} [ {channel_id} ] Has Been Sucessfully Deleted And All Its Files Were Cleared From DB...."
+
+ else:
+ text=f"Couldn't Delete Channel And All Its Files From DB Sucessfully....\nPlease Try Again After Sometimes...Also Make Sure To Check The Logs..!!"
+ await update.answer(text=text, show_alert=True)
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"channel_list({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ await recacher(chat_id, True, True, bot, update)
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"f_delete\((.+)\)"), group=2)
+async def cb_filters_delete(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Delete A Specific Channel's Filters Connected To A Group
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ channel_id, channel_name = re.findall(r"f_delete\((.+)\)", query_data)[0].split("|", 1)
+
+ f_delete = await db.del_filters(chat_id, int(channel_id))
+
+ if not f_delete:
+ text="Oops..!!\n\nEncountered Some Error While Deleteing Filters....\nPlease Check The Logs...."
+ await update.answer(text=text, show_alert=True)
+ return
+
+ text =f"All Filters Of {channel_id}[{channel_name}] Has Been Deleted Sucessfully From My DB.."
+
+ buttons=[
+ [
+ InlineKeyboardButton
+ (
+ "Back", callback_data="settings"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"types\((.+)\)"), group=2)
+async def cb_types(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Changing The Result Types To Be Shown In While Sending Results
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id = re.findall(r"types\((.+)\)", query_data)[0]
+
+ _types = await db.find_chat(int(chat_id))
+
+ text=f"Filter Types Enabled/Disbled In {chat_name}\n"
+
+ _types = _types["types"]
+ vid = _types["video"]
+ doc = _types["document"]
+ aud = _types["audio"]
+
+ buttons = []
+
+ if vid:
+ text+="\nVideo Index: Enabled\n"
+ v_e = "✅"
+ vcb_data = f"toggle({chat_id}|video|False)"
+
+ else:
+ text+="\nVideo Index: Disabled\n"
+ v_e="❎"
+ vcb_data = f"toggle({chat_id}|video|True)"
+
+ if doc:
+ text+="\nDocument Index: Enabled\n"
+ d_e = "✅"
+ dcb_data = f"toggle({chat_id}|document|False)"
+
+ else:
+ text+="\nDocument Index: Disabled\n"
+ d_e="❎"
+ dcb_data = f"toggle({chat_id}|document|True)"
+
+ if aud:
+ text+="\nAudio Index: Enabled\n"
+ a_e = "✅"
+ acb_data = f"toggle({chat_id}|audio|False)"
+
+ else:
+ text+="\nAudio Index: Disabled\n"
+ a_e="❎"
+ acb_data = f"toggle({chat_id}|audio|True)"
+
+
+ text+="\nBelow Buttons Will Toggle Respective Media Types As Enabled Or Disabled....\n"
+ text+="This Will Take Into Action As Soon As You Change Them...."
+
+ buttons.append([InlineKeyboardButton(f"Video Index: {v_e}", callback_data=vcb_data)])
+ buttons.append([InlineKeyboardButton(f"Audio Index: {a_e}", callback_data=acb_data)])
+ buttons.append([InlineKeyboardButton(f"Document Index: {d_e}", callback_data=dcb_data)])
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"settings"
+ )
+ ]
+ )
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"toggle\((.+)\)"), group=2)
+async def cb_toggle(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Support handler For types()
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id, types, val = re.findall(r"toggle\((.+)\)", query_data)[0].split("|", 2)
+
+ _types = await db.find_chat(int(chat_id))
+
+ _types = _types["types"]
+ vid = _types["video"]
+ doc = _types["document"]
+ aud = _types["audio"]
+
+ if types == "video":
+ vid = True if val=="True" else False
+ elif types == "audio":
+ aud = True if val=="True" else False
+ elif types == "document":
+ doc = True if val=="True" else False
+
+
+ settings = {
+ "video": vid,
+ "audio": aud,
+ "document": doc
+ }
+
+ process = await db.update_settings(chat_id, settings)
+
+ if process:
+ await update.answer(text="Filter Types Updated Sucessfully", show_alert=True)
+
+ else:
+ text="Something Wrong Please Check Bot Log For More Information...."
+ await update.answer(text, show_alert=True)
+ return
+
+ _types = await db.find_chat(int(chat_id))
+
+ text =f"Filter Types Enabled In {update.message.chat.title}\n"
+
+ _types = _types["types"]
+ vid = _types["video"]
+ doc = _types["document"]
+ aud = _types["audio"]
+
+ buttons = []
+
+ if vid:
+ text+="\nVideo Index: Enabled\n"
+ v_e = "✅"
+ vcb_data = f"toggle({chat_id}|video|False)"
+
+ else:
+ text+="\nVideo Index: Disabled\n"
+ v_e="❎"
+ vcb_data = f"toggle({chat_id}|video|True)"
+
+ if doc:
+ text+="\nDocument Index: Enabled\n"
+ d_e = "✅"
+ dcb_data = f"toggle({chat_id}|document|False)"
+
+ else:
+ text+="\nDocument Index: Disabled\n"
+ d_e="❎"
+ dcb_data = f"toggle({chat_id}|document|True)"
+
+ if aud:
+ text+="\nAudio Index: Enabled\n"
+ a_e = "✅"
+ acb_data = f"toggle({chat_id}|audio|False)"
+
+ else:
+ text+="\nAudio Index: Disabled\n"
+ a_e="❎"
+ acb_data = f"toggle({chat_id}|audio|True)"
+
+
+ text+="\nBelow Buttons Will Toggle Respective Media Types As Enabled Or Disabled....\n"
+ text+="This Will Take Into Action As Soon As You Change Them...."
+
+ buttons.append([InlineKeyboardButton(f"Video Index : {v_e}", callback_data=vcb_data)])
+ buttons.append([InlineKeyboardButton(f"Audio Index : {a_e}", callback_data=acb_data)])
+ buttons.append([InlineKeyboardButton(f"Document Index : {d_e}", callback_data=dcb_data)])
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"settings"
+ )
+ ]
+ )
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"config\((.+)\)"), group=2)
+async def cb_config(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Chaning The Number Of Total Pages /
+ Total Results / Results Per pages / Enable or Diable Invite Link /
+ Enable or Disable PM File Chat
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id = re.findall(r"config\((.+)\)", query_data)[0]
+
+ settings = await db.find_chat(int(chat_id))
+
+ mp_count = settings["configs"]["max_pages"]
+ mf_count = settings["configs"]["max_results"]
+ mr_count = settings["configs"]["max_per_page"]
+ show_invite = settings["configs"]["show_invite_link"]
+ pm_file_chat = settings["configs"].get("pm_fchat", False)
+ accuracy_point = settings["configs"].get("accuracy", 0.80)
+
+ text=f"Configure Your {chat_name} Group's Filter Settings...\n"
+
+ text+=f"\n{chat_name} Current Settings:\n"
+
+ text+=f"\n - Max Filter: {mf_count}\n"
+
+ text+=f"\n - Max Pages: {mp_count}\n"
+
+ text+=f"\n - Max Filter Per Page: {mr_count}\n"
+
+ text+=f"\n - Accuracy Percentage: {accuracy_point}\n"
+
+ text+=f"\n - Show Invitation Link: {show_invite}\n"
+
+ text+=f"\n - Provide File In Bot PM: {pm_file_chat}\n"
+
+ text+="\nAdjust Above Value Using Buttons Below... "
+ buttons=[
+ [
+ InlineKeyboardButton
+ (
+ "Filter Per Page", callback_data=f"mr_count({mr_count}|{chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Max Pages", callback_data=f"mp_count({mp_count}|{chat_id})"
+ )
+ ]
+ ]
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Total Filter Count", callback_data=f"mf_count({mf_count}|{chat_id})"
+ )
+ ]
+ )
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Show Invite Links", callback_data=f"show_invites({show_invite}|{chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Bot File Chat", callback_data=f"inPM({pm_file_chat}|{chat_id})"
+ )
+ ]
+ )
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Result's Accuracy", callback_data=f"accuracy({accuracy_point}|{chat_id})"
+ )
+ ]
+ )
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"settings"
+ )
+ ]
+ )
+
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"mr_count\((.+)\)"), group=2)
+async def cb_max_buttons(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Changing The Count Of Result To Be Shown Per Page
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ count, chat_id = re.findall(r"mr_count\((.+)\)", query_data)[0].split("|", 1)
+
+ text = f"Choose Your Desired 'Max Filter Count Per Page' For Every Filter Results Shown In {chat_name}"
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "5 Filters", callback_data=f"set(per_page|5|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "8 Filters", callback_data=f"set(per_page|8|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "16 Filters", callback_data=f"set(per_page|16|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "20 Filters", callback_data=f"set(per_page|20|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "25 Filters", callback_data=f"set(per_page|25|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "30 Filters", callback_data=f"set(per_page|30|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"mp_count\((.+)\)"), group=2)
+async def cb_max_page(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Changing The Count Of Maximum Result Pages To Be Shown
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ count, chat_id = re.findall(r"mp_count\((.+)\)", query_data)[0].split("|", 1)
+
+ text = f"Choose Your Desired 'Max Filter Page Count' For Every Filter Results Shown In {chat_name}"
+
+ buttons = [
+
+ [
+ InlineKeyboardButton
+ (
+ "2 Pages", callback_data=f"set(pages|2|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "4 Pages", callback_data=f"set(pages|4|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "6 Pages", callback_data=f"set(pages|6|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "8 Pages", callback_data=f"set(pages|8|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "10 Pages", callback_data=f"set(pages|10|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"config({chat_id})"
+ )
+ ]
+
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"mf_count\((.+)\)"), group=2)
+async def cb_max_results(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Changing The Count Of Maximum Files TO Be Fetched From Database
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ count, chat_id = re.findall(r"mf_count\((.+)\)", query_data)[0].split("|", 1)
+
+ text = f"Choose Your Desired 'Max Filter' To Be Fetched From DB For Every Filter Results Shown In {chat_name}"
+
+ buttons = [
+
+ [
+ InlineKeyboardButton
+ (
+ "50 Results", callback_data=f"set(results|50|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "100 Results", callback_data=f"set(results|100|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "150 Results", callback_data=f"set(results|150|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "200 Results", callback_data=f"set(results|200|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "250 Results", callback_data=f"set(results|250|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "300 Results", callback_data=f"set(results|300|{chat_id}|{count})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"show_invites\((.+)\)"), group=2)
+async def cb_show_invites(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Enabling Or Diabling Invite Link Buttons
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ value, chat_id = re.findall(r"show_invites\((.+)\)", query_data)[0].split("|", 1)
+
+ value = True if value=="True" else False
+
+ if value:
+ buttons= [
+ [
+ InlineKeyboardButton
+ (
+ "Disable ❌", callback_data=f"set(showInv|False|{chat_id}|{value})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ else:
+ buttons =[
+ [
+ InlineKeyboardButton
+ (
+ "Enable ✔", callback_data=f"set(showInv|True|{chat_id}|{value})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ text=f"This Config Will Help You To Show Invitation Link Of All Active Chats Along With The Filter Results For The Users To Join....."
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"inPM\((.+)\)"), group=2)
+async def cb_pm_file(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Enabling Or Diabling File Transfer Through Bot PM
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ value, chat_id = re.findall(r"inPM\((.+)\)", query_data)[0].split("|", 1)
+
+ value = True if value=="True" else False
+
+ if value:
+ buttons= [
+ [
+ InlineKeyboardButton
+ (
+ "Disable ❎", callback_data=f"set(inPM|False|{chat_id}|{value})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ else:
+ buttons =[
+ [
+ InlineKeyboardButton
+ (
+ "Enable ✅", callback_data=f"set(inPM|True|{chat_id}|{value})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ text=f"This Config Will Help You To Enable/Disable File Transfer Through Bot PM Without Redirecting Them To Channel...."
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"accuracy\((.+)\)"), group=2)
+async def cb_accuracy(bot, update: CallbackQuery):
+ """
+ A Callaback Funtion to control the accuracy of matching results
+ that the bot should return for a query....
+ """
+ global VERIFY
+ chat_id = update.message.chat.id
+ chat_name = update.message.chat.title
+ user_id = update.from_user.id
+ query_data = update.data
+
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ val, chat_id = re.findall(r"accuracy\((.+)\)", query_data)[0].split("|", 1)
+
+ text = f"Choose Your Desired 'Accuracy Perceentage' For Every Filter Results Shown In {chat_name}\n\n"
+ text+= f"NB: Higher The Value Better Matching Results Will Be Provided... And If Value Is Lower It Will Show More Results \
+ Which Is Fimilary To Query Search (Wont Be Accurate)...."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "100 %", callback_data=f"set(accuracy|1.00|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "80 %", callback_data=f"set(accuracy|0.80|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "65 %", callback_data=f"set(accuracy|0.65|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "60 %", callback_data=f"set(accuracy|0.60|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "55 %", callback_data=f"set(accuracy|0.55|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "50 %", callback_data=f"set(accuracy|0.50|{chat_id}|{val})"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data=f"config({chat_id})"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"set\((.+)\)"), group=2)
+async def cb_set(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Support For config()
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ action, val, chat_id, curr_val = re.findall(r"set\((.+)\)", query_data)[0].split("|", 3)
+
+ try:
+ val, chat_id, curr_val = float(val), int(chat_id), float(curr_val)
+ except:
+ chat_id = int(chat_id)
+
+ if val == curr_val:
+ await update.answer("New Value Cannot Be Old Value...Please Choose Different Value...!!!", show_alert=True)
+ return
+
+ prev = await db.find_chat(chat_id)
+
+ accuracy = float(prev["configs"].get("accuracy", 0.80))
+ max_pages = int(prev["configs"].get("max_pages"))
+ max_results = int(prev["configs"].get("max_results"))
+ max_per_page = int(prev["configs"].get("max_per_page"))
+ pm_file_chat = True if prev["configs"].get("pm_fchat") == (True or "True") else False
+ show_invite_link = True if prev["configs"].get("show_invite_link") == (True or "True") else False
+
+ if action == "accuracy": # Scophisticated way 😂🤣
+ accuracy = val
+
+ elif action == "pages":
+ max_pages = int(val)
+
+ elif action == "results":
+ max_results = int(val)
+
+ elif action == "per_page":
+ max_per_page = int(val)
+
+ elif action =="showInv":
+ show_invite_link = True if val=="True" else False
+
+ elif action == "inPM":
+ pm_file_chat = True if val=="True" else False
+
+
+ new = dict(
+ accuracy=accuracy,
+ max_pages=max_pages,
+ max_results=max_results,
+ max_per_page=max_per_page,
+ pm_fchat=pm_file_chat,
+ show_invite_link=show_invite_link
+ )
+
+ append_db = await db.update_configs(chat_id, new)
+
+ if not append_db:
+ text="Something Wrong Please Check Bot Log For More Information...."
+ await update.answer(text=text, show_alert=True)
+ return
+
+ text=f"Your Request Was Updated Sucessfully....\nNow All Upcoming Results Will Show According To This Settings..."
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "Back 🔙", callback_data=f"config({chat_id})"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup=InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+@DonLee_Robot.on_callback_query(filters.regex("instructions"), group=2)
+async def my_instructs(bot, update: CallbackQuery):
+ #Callback Function for instructions when no results are available
+
+ global VERIFY
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+ await update.answer("Check if your spelling is correct first and then try adding the year and quality of the movie 😉. If you still didn'get your movie add the language 😁. If there is no result it just is'nt available 😌.", show_alert=True)
+ return
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"status\((.+)\)"), group=2)
+async def cb_status(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Showing Overall Status Of A Group
+ """
+ global VERIFY
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ chat_id = re.findall(r"status\((.+)\)", query_data)[0]
+
+ total_filters, total_chats, total_achats = await db.status(chat_id)
+
+ text = f"Status Of {chat_name}\n"
+ text += f"\nTotal Connected Chats: {total_chats}\n"
+ text += f"\nTotal Active Chats: {total_achats}\n"
+ text += f"\nTotal Filters: {total_filters}"
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data="settings"
+ ),
+
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+
+
+@DonLee_Robot.on_callback_query(filters.regex(r"about\((.+)\)"), group=2)
+async def cb_about(bot, update: CallbackQuery):
+ """
+ A Callback Funtion For Showing About Section In Bot Setting Menu
+ """
+ global VERIFY
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ if user_id not in VERIFY.get(str(chat_id)):
+ return
+
+ text=f"Bot's Status\n"
+ text+=f"\nBot's Uptime: {time_formatter(time.time() - start_uptime)}\n"
+ text+=f"\nBot Funtion: Auto Filter Files\n"
+ text+=f"""\nBot Group: Mo Tech\n"""
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "My Dev ⚡", url="t.me/Mrk_yt"
+ ),
+
+ InlineKeyboardButton
+ (
+ "🔙 Back", callback_data="settings"
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ "Close 🔐", callback_data="close"
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ text, reply_markup=reply_markup, parse_mode="html"
+ )
+
+@DonLee_Robot.on_callback_query(filters.regex(r"^(start|help|about|mods|channel|main|malayalam_imdb|english_imdb|help_me|close)$"), group=2)
+async def callback_data(bot, update: CallbackQuery):
+
+ query_data = update.data
+ runing = "hi"
+ if query_data == "start":
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ '📢Update Channel', url='t.me/Mo_Tech_YT'
+ ),
+ InlineKeyboardButton
+ (
+ '💡More Botz', url='t.me/MT_Botz'
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ DEPLOY, url=HEROKU
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ '🚶Help🚶', callback_data='help'
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ Translation.START_TEXT.format(update.from_user.mention),
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+ elif query_data == "help":
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ DEPLOY, url=HEROKU
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ '🏡Home', callback_data='start'
+ ),
+ InlineKeyboardButton
+ (
+ 'About💡', callback_data='about'
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ Translation.HELP_TEXT.format(runing),
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+ elif query_data == "about":
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ DEPLOY, url=HEROKU
+ )
+ ],
+ [
+ InlineKeyboardButton
+ (
+ '🏠Home', callback_data='start'
+ ),
+ InlineKeyboardButton
+ (
+ 'Close❎️', callback_data='close'
+ )
+ ]
+ ]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await update.message.edit_text(
+ Translation.ABOUT_TEXT,
+ reply_markup=reply_markup,
+ parse_mode="html"
+ )
+
+
+ elif query_data == "help_me":
+ await update.answer("Do not add the word MOVIE with your movie name 😉.\nദയവ് ചെയ്ത് സിനിമയുടെ പേരിന്റെ കൂടെ Movie എന്ന വാക്ക് ഇടരുത് 😝.", show_alert=True)
+
+ elif query_data == "close":
+ await update.message.delete()
+
+
+
+def time_formatter(seconds: float) -> str:
+ """
+ humanize time
+ """
+ minutes, seconds = divmod(int(seconds),60)
+ hours, minutes = divmod(minutes, 60)
+ days, hours = divmod(hours, 24)
+ tmp = ((str(days) + "d, ") if days else "") + \
+ ((str(hours) + "h, ") if hours else "") + \
+ ((str(minutes) + "m, ") if minutes else "") + \
+ ((str(seconds) + "s") if seconds else "")
+ return tmp
diff --git a/DonLee_Robot/Modules/Filters/Filter.py b/DonLee_Robot/Modules/Filters/Filter.py
new file mode 100644
index 000000000..f550f7542
--- /dev/null
+++ b/DonLee_Robot/Modules/Filters/Filter.py
@@ -0,0 +1,399 @@
+# (C) AlbertEinstein_TG
+# (C) @Nacbots
+# (E) @Muhammed_RK, @Mo_Tech_YT , @Mo_Tech_Group, @MT_Botz
+# (M) @Jackbro007
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+import re
+import logging
+import asyncio
+from time import time
+from pyrogram import Client, filters
+from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
+from pyrogram.errors import ButtonDataInvalid, FloodWait
+from DonLee_Robot.Modules.Filters.Main import Database
+from DonLee_Robot.donlee_robot import DonLee_Robot
+from DonLee_Robot import Translation, Mo_Tech_YT
+import imdb
+
+FIND = {}
+INVITE_LINK = {}
+ACTIVE_CHATS = {}
+db = Database()
+
+@DonLee_Robot.on_message(filters.text & filters.group & ~filters.bot, group=0)
+async def auto_filter(bot, update):
+ """
+ A Funtion To Handle Incoming Text And Reply With Appropriate Results
+ """
+ group_id = update.chat.id
+ the_query = update.text
+ query = re.sub(r"[1-2]\d{3}", "", update.text) # Targetting Only 1000 - 2999 😁
+ tester = 2
+
+ for i in Mo_Tech_YT.MO_TECH_YT_05 :
+ if i in the_query.split() :
+ for a in Mo_Tech_YT.MO_TECH_YT_08 :
+ if a in the_query.split() :
+ tester = 0
+ break
+ else :
+ tester = 1
+ if tester==0 :
+ break
+
+ if tester==1 :
+ buttons = [[
+ InlineKeyboardButton("Help🥴",callback_data="help_me")
+ ]]
+ reply_markup = InlineKeyboardMarkup(buttons)
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text="Please dont send the word Movie with your Movie name 😪\nTry Reading the help box below 👇🏽",
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id)
+ return
+
+ for i in Mo_Tech_YT.MO_TECH_YT_06.split() :
+ if i in the_query.lower() :
+ buttons = [[
+ InlineKeyboardButton("Help🥴",callback_data="help_me")
+ ]]
+ reply_markup = InlineKeyboardMarkup(buttons)
+ await bot.send_message(
+ text=" കിട്ടോ, അയക്കോ, ഉണ്ടോ, തരുമോ എന്ന് ഒന്നും ചോദിക്കേണ്ട സിനിമയുടെ പേര് മാത്രം കൃത്യമായി അയക്കുക 😪",
+ chat_id=update.chat.id,
+ reply_to_message_id=update.message_id,
+ parse_mode="html",
+ reply_markup=reply_markup)
+ return
+
+ for i in "#admins #admin #complaint #report @admin @admins".split():
+ if i in the_query.lower() :
+ await update.forward(chat_id=Mo_Tech_YT.MO_TECH_YT_09)
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text="Your report was successfully sent to admins please wait for a reply 😉",
+ reply_to_message_id=update.message_id,
+ parse_mode="html")
+ return
+
+ if re.findall(r"((^\/|^,|^\.|^[\U0001F600-\U000E007F]).*)", update.text):
+ return
+
+ for a in "https:// http:// thanks thank tnx tnq tq tqsm #".split():
+ if a in update.text.lower():
+ return
+
+ if len(query) < 2:
+ return
+
+ results = []
+
+ global ACTIVE_CHATS
+ global FIND
+
+ configs = await db.find_chat(group_id)
+ achats = ACTIVE_CHATS[str(group_id)] if ACTIVE_CHATS.get(str(group_id)) else await db.find_active(group_id)
+ ACTIVE_CHATS[str(group_id)] = achats
+
+ if not configs:
+ return
+
+ allow_video = configs["types"]["video"]
+ allow_audio = configs["types"]["audio"]
+ allow_document = configs["types"]["document"]
+
+ max_pages = configs["configs"]["max_pages"] # maximum page result of a query
+ pm_file_chat = configs["configs"]["pm_fchat"] # should file to be send from bot pm to user
+ max_results = configs["configs"]["max_results"] # maximum total result of a query
+ max_per_page = configs["configs"]["max_per_page"] # maximum buttom per page
+ show_invite = configs["configs"]["show_invite_link"] # should or not show active chat invite link
+
+ show_invite = (False if pm_file_chat == True else show_invite) # turn show_invite to False if pm_file_chat is True
+
+ filters = await db.get_filters(group_id, query)
+
+ if filters:
+ for filter in filters: # iterating through each files
+ file_name = filter.get("file_name")
+ file_type = filter.get("file_type")
+ file_link = filter.get("file_link")
+ file_size = int(filter.get("file_size", "0"))
+
+ # from B to MiB
+
+ if file_size < 1024:
+ file_size = f"[{file_size} B]"
+ elif file_size < (1024**2):
+ file_size = f" {str(round(file_size/1024, 2))} KB "
+ elif file_size < (1024**3):
+ file_size = f" {str(round(file_size/(1024**2), 2))} MB "
+ elif file_size < (1024**4):
+ file_size = f"{str(round(file_size/(1024**3), 2))} GB "
+
+
+ file_size = "" if file_size == ("[0 B]") else file_size
+
+ # add emoji down below inside " " if you want..
+
+
+
+ if file_type == "video":
+ if allow_video:
+ pass
+ else:
+ continue
+
+ elif file_type == "audio":
+ if allow_audio:
+ pass
+ else:
+ continue
+
+ elif file_type == "document":
+ if allow_document:
+ pass
+ else:
+ continue
+
+ if len(results) >= max_results:
+ break
+
+ if pm_file_chat:
+ unique_id = filter.get("unique_id")
+ if not FIND.get("bot_details"):
+ try:
+ bot_= await bot.get_me()
+ FIND["bot_details"] = bot_
+ except FloodWait as e:
+ asyncio.sleep(e.x)
+ bot_= await bot.get_me()
+ FIND["bot_details"] = bot_
+
+ bot_ = FIND.get("bot_details")
+ file_link = f"https://t.me/{bot_.username}?start={unique_id}"
+ if not Mo_Tech_YT.MO_TECH_YT_07:
+ button_text = f"[{file_size}]📽️ {file_name}"
+ results.append(
+
+ [
+
+ InlineKeyboardButton(button_text, url=file_link)
+
+ ]
+
+ )
+ else:
+ results.append(
+ [
+ InlineKeyboardButton(f"{file_name}", url=file_link),
+ InlineKeyboardButton(f"{file_size}", url=file_link)
+ ]
+ )
+
+
+ else:
+ pass # return if no files found for that query
+
+
+ if len(results) == 0 : # double check
+ buttons = [[
+ InlineKeyboardButton("Instructions 📑",callback_data="instructions")
+ ]]
+ reply_markup = InlineKeyboardMarkup(buttons)
+ await bot.send_message(
+ chat_id=update.chat.id,
+ text=f"Sorry I couldn't find anything for {the_query} 🤧\nTry Reading the instructions below 👇🏽",
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id)
+ return
+
+ else:
+
+ result = []
+ # seperating total files into chunks to make as seperate pages
+ result += [results[i * max_per_page :(i + 1) * max_per_page ] for i in range((len(results) + max_per_page - 1) // max_per_page )]
+ len_result = len(result)
+ len_results = len(results)
+ results = None # Free Up Memory
+
+ FIND[query] = {"results": result, "total_len": len_results, "max_pages": max_pages} # TrojanzHex's Idea Of Dicts😅
+
+ # Add next buttin if page count is not equal to 1
+ page_btn = "⓵ ❷ ❸ ❹ ❺ "
+ cutter = len_result if len_result < max_pages else max_pages
+ page_btn = page_btn[:cutter*2]
+
+ if len_result != 1:
+ result[0].append(
+ [
+ InlineKeyboardButton("⪼⪼", callback_data=f"navigate(0|next|{query})")
+ ]
+ )
+
+ # Just A Decaration
+ result[0].append([
+ InlineKeyboardButton(f"📑 {page_btn} 📑", callback_data="ignore")
+ ])
+
+
+ # if show_invite is True Append invite link buttons
+ if show_invite:
+
+ ibuttons = []
+ achatId = []
+ await gen_invite_links(configs, group_id, bot, update)
+
+ for x in achats["chats"] if isinstance(achats, dict) else achats:
+ achatId.append(int(x["chat_id"])) if isinstance(x, dict) else achatId.append(x)
+
+ ACTIVE_CHATS[str(group_id)] = achatId
+
+ for y in INVITE_LINK.get(str(group_id)):
+
+ chat_id = int(y["chat_id"])
+
+ if chat_id not in achatId:
+ continue
+
+ chat_name = y["chat_name"]
+ invite_link = y["invite_link"]
+
+ if ((len(ibuttons)%2) == 0):
+ ibuttons.append(
+ [
+ InlineKeyboardButton(f"⚜ {chat_name} ⚜", url=invite_link)
+ ]
+ )
+
+ else:
+ ibuttons[-1].append(
+ InlineKeyboardButton(f"⚜ {chat_name} ⚜", url=invite_link)
+ )
+
+ for x in ibuttons:
+ result[0].insert(0, x) #Insert invite link buttons at first of page
+
+ ibuttons = None # Free Up Memory...
+ achatId = None
+
+
+ reply_markup = InlineKeyboardMarkup(result[0])
+
+ #To find any number in the query and remove it.
+ year = 2021
+ for i in the_query.split():
+ try :
+ year = int(i)
+ the_query = the_query.replace(i,"")
+ except :
+ pass
+ for i in "movie malayalam english tamil kannada telugu subtitles esub esubs".split():
+ if i in the_query.lower().split():
+ the_query = the_query.replace(i,"")
+
+ try:
+ ia = imdb.IMDb()
+ my_movie=the_query
+ movies = ia.search_movie(my_movie)
+ #print(f"{movies[0].movieID} {movies[0]['title']}")
+ movie_url = movies[0].get_fullsizeURL()
+
+ await bot.send_photo(
+ photo=movie_url,
+ caption=f"""🎬 Title : {query}\n🗃️ Total Files : {len_results if len_results <= max_pages*8 else max_pages*8}""",
+ reply_markup=reply_markup,
+ chat_id=update.chat.id,
+ reply_to_message_id=update.message_id,
+ parse_mode="html"
+ )
+
+ except Exception as e:
+ print(e)
+
+ try:
+ await bot.send_message(
+ chat_id = update.chat.id,
+ text=f"📀 Title : {query} \n🗃️ Total Files : {len_results if len_results <= max_pages*8 else max_pages*8}",
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
+
+ except ButtonDataInvalid:
+ print(result[0])
+
+async def gen_invite_links(db, group_id, bot, update):
+ """
+ A Funtion To Generate Invite Links For All Active
+ Connected Chats In A Group
+ """
+ chats = db.get("chat_ids")
+ global INVITE_LINK
+
+ if INVITE_LINK.get(str(group_id)):
+ return
+
+ Links = []
+ if chats:
+ for x in chats:
+ Name = x["chat_name"]
+
+ if Name == None:
+ continue
+
+ chatId=int(x["chat_id"])
+
+ Link = await bot.export_chat_invite_link(chatId)
+ Links.append({"chat_id": chatId, "chat_name": Name, "invite_link": Link})
+
+ INVITE_LINK[str(group_id)] = Links
+ return
+
+
+async def recacher(group_id, ReCacheInvite=True, ReCacheActive=False, bot=DonLee_Robot, update=Message):
+ """
+ A Funtion To rechase invite links and active chats of a specific chat
+ """
+ global INVITE_LINK, ACTIVE_CHATS
+
+ if ReCacheInvite:
+ if INVITE_LINK.get(str(group_id)):
+ INVITE_LINK.pop(str(group_id))
+
+ Links = []
+ chats = await db.find_chat(group_id)
+ chats = chats["chat_ids"]
+
+ if chats:
+ for x in chats:
+ Name = x["chat_name"]
+ chat_id = x["chat_id"]
+ if (Name == None or chat_id == None):
+ continue
+
+ chat_id = int(chat_id)
+
+ Link = await bot.export_chat_invite_link(chat_id)
+ Links.append({"chat_id": chat_id, "chat_name": Name, "invite_link": Link})
+
+ INVITE_LINK[str(group_id)] = Links
+
+ if ReCacheActive:
+
+ if ACTIVE_CHATS.get(str(group_id)):
+ ACTIVE_CHATS.pop(str(group_id))
+
+ achats = await db.find_active(group_id)
+ achatId = []
+ if achats:
+ for x in achats["chats"]:
+ achatId.append(int(x["chat_id"]))
+
+ ACTIVE_CHATS[str(group_id)] = achatId
+ return
diff --git a/DonLee_Robot/Modules/Filters/Main.py b/DonLee_Robot/Modules/Filters/Main.py
new file mode 100644
index 000000000..df4305848
--- /dev/null
+++ b/DonLee_Robot/Modules/Filters/Main.py
@@ -0,0 +1,521 @@
+# (C) AlbertEinstein_TG
+# (E) PR0FESS0R_99
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+import re
+import datetime
+import motor.motor_asyncio
+from DonLee_Robot.Simple_Config import Mo_Tech_YT
+
+class Database:
+
+ def __init__(self):
+ self._client = motor.motor_asyncio.AsyncIOMotorClient(Mo_Tech_YT.MO_TECH_YT_03)
+ self.db = self._client[Mo_Tech_YT.MO_TECH_YT_04]
+ self.col = self.db["Main"]
+ self.acol = self.db["Active_Chats"]
+ self.fcol = self.db["Filter_Collection"]
+ self.dcol = self.db.users
+
+ self.cache = {}
+ self.acache = {}
+ def new_user(self, id):
+ return dict(
+ id = id,
+ join_date = datetime.date.today().isoformat()
+ )
+ async def add_user(self, id):
+ user = self.new_user(id)
+ await self.dcol.insert_one(user)
+ async def is_user_exist(self, id):
+ user = await self.dcol.find_one({'id':int(id)})
+ return True if user else False
+ async def total_users_count(self):
+ count = await self.dcol.count_documents({})
+ return count
+ async def get_all_users(self):
+ all_users = self.dcol.find({})
+ return all_users
+ async def delete_user(self, user_id):
+ await self.dcol.delete_many({'id': int(user_id)})
+
+ async def create_index(self):
+ """
+ Create text index if not in db
+ """
+ await self.fcol.create_index([("file_name", "text")])
+
+
+ def new_chat(self, group_id, channel_id, channel_name):
+ """
+ Create a document in db if the chat is new
+ """
+ try:
+ group_id, channel_id = int(group_id), int(channel_id)
+ except:
+ pass
+
+ return dict(
+ _id = group_id,
+ chat_ids = [{
+ "chat_id": channel_id,
+ "chat_name": channel_name
+ }],
+ types = dict(
+ audio=False,
+ document=True,
+ video=True
+ ),
+ configs = dict(
+ accuracy=0.80,
+ max_pages=5,
+ max_results=50,
+ max_per_page=10,
+ pm_fchat=True,
+ show_invite_link=True
+ )
+ )
+
+
+ async def status(self, group_id: int):
+ """
+ Get the total filters, total connected
+ chats and total active chats of a chat
+ """
+ group_id = int(group_id)
+
+ total_filter = await self.tf_count(group_id)
+
+ chats = await self.find_chat(group_id)
+ chats = chats.get("chat_ids")
+ total_chats = len(chats) if chats is not None else 0
+
+ achats = await self.find_active(group_id)
+ if achats not in (None, False):
+ achats = achats.get("chats")
+ if achats == None:
+ achats = []
+ else:
+ achats = []
+ total_achats = len(achats)
+
+ return total_filter, total_chats, total_achats
+
+
+ async def find_group_id(self, channel_id: int):
+ """
+ Find all group id which is connected to a channel
+ for add a new files to db
+ """
+ data = self.col.find({})
+ group_list = []
+
+ for group_id in await data.to_list(length=50): # No Need Of Even 50
+ for y in group_id["chat_ids"]:
+ if int(y["chat_id"]) == int(channel_id):
+ group_list.append(group_id["_id"])
+ else:
+ continue
+ return group_list
+
+ # Related TO Finding Channel(s)
+ async def find_chat(self, group_id: int):
+ """
+ A funtion to fetch a group's settings
+ """
+ connections = self.cache.get(str(group_id))
+
+ if connections is not None:
+ return connections
+
+ connections = await self.col.find_one({'_id': group_id})
+
+ if connections:
+ self.cache[str(group_id)] = connections
+
+ return connections
+ else:
+ return self.new_chat(None, None, None)
+
+
+ async def add_chat(self, group_id: int, channel_id: int, channel_name):
+ """
+ A funtion to add/update a chat document when a new chat is connected
+ """
+ new = self.new_chat(group_id, channel_id, channel_name)
+ update_d = {"$push" : {"chat_ids" : {"chat_id": channel_id, "chat_name" : channel_name}}}
+ prev = await self.col.find_one({'_id':group_id})
+
+ if prev:
+ await self.col.update_one({'_id':group_id}, update_d)
+ await self.update_active(group_id, channel_id, channel_name)
+ await self.refresh_cache(group_id)
+
+ return True
+
+ self.cache[str(group_id)] = new
+
+ await self.col.insert_one(new)
+ await self.add_active(group_id, channel_id, channel_name)
+ await self.refresh_cache(group_id)
+
+ return True
+
+
+ async def del_chat(self, group_id: int, channel_id: int):
+ """
+ A Funtion to delete a channel and its files from db of a chat connection
+ """
+ group_id, channel_id = int(group_id), int(channel_id) # group_id and channel_id Didnt type casted to int for some reason
+
+ prev = self.col.find_one({"_id": group_id})
+
+ if prev:
+
+ await self.col.update_one(
+ {"_id": group_id},
+ {"$pull" :
+ {"chat_ids" :
+ {"chat_id":
+ channel_id
+ }
+ }
+ },
+ False,
+ True
+ )
+
+ await self.del_active(group_id, channel_id)
+ await self.refresh_cache(group_id)
+
+ return True
+
+ return False
+
+
+ async def in_db(self, group_id: int, channel_id: int):
+ """
+ Check whether if the given channel id is in db or not...
+ """
+ connections = self.cache.get(group_id)
+
+ if connections is None:
+ connections = await self.col.find_one({'_id': group_id})
+
+ check_list = []
+
+ if connections:
+ for x in connections["chat_ids"]:
+ check_list.append(int(x.get("chat_id")))
+
+ if int(channel_id) in check_list:
+ return True
+
+ return False
+
+
+ async def update_settings(self, group_id: int, settings):
+ """
+ A Funtion to update a chat's filter types in db
+ """
+ group_id = int(group_id)
+ prev = await self.col.find_one({"_id": group_id})
+
+ if prev:
+ try:
+ await self.col.update_one({"_id": group_id}, {"$set": {"types": settings}})
+ await self.refresh_cache(group_id)
+ return True
+
+ except Exception as e:
+ print (e)
+ return False
+ print("You Should First Connect To A Chat To Use This Funtion..... 'databse.py/#201' ")
+ return False
+
+
+ async def update_configs(self, group_id: int, configs):
+ """
+ A Funtion to update a chat's configs in db
+ """
+ prev = await self.col.find_one({"_id": group_id})
+
+ if prev:
+ try:
+ await self.col.update_one(prev, {"$set":{"configs": configs}})
+ await self.refresh_cache(group_id)
+ return True
+
+ except Exception as e:
+ print (e)
+ return False
+ print("You Should First Connect To A Chat To Use This")
+ return False
+
+
+ async def delete_all(self, group_id: int):
+ """
+ A Funtion to delete all documents related to a
+ chat from db
+ """
+ prev = await self.col.find_one({"_id": group_id})
+ if prev:
+ await self.delall_active(group_id)
+ await self.delall_filters(group_id)
+ await self.del_main(group_id)
+ await self.refresh_cache(group_id)
+
+ return
+
+
+ async def del_main(self, group_id: int):
+ """
+ A Funtion To Delete the chat's main db document
+ """
+ await self.col.delete_one({"_id": group_id})
+ await self.refresh_cache(group_id)
+
+ return True
+
+
+ async def refresh_cache(self, group_id: int):
+ """
+ A Funtion to refresh a chat's chase data
+ in case of update in db
+ """
+ if self.cache.get(str(group_id)):
+ self.cache.pop(str(group_id))
+
+ prev = await self.col.find_one({"_id": group_id})
+
+ if prev:
+ self.cache[str(group_id)] = prev
+ return True
+
+ # Related To Finding Active Channel(s)
+ async def add_active(self, group_id: int, channel_id: int, channel_name):
+ """
+ A Funtion to add a channel as an active chat the a connected group
+ (This Funtion will be used only if its the first time)
+ """
+ templ = {"_id": group_id, "chats":[{"chat_id": channel_id, "chat_name": channel_name}]}
+
+ try:
+ await self.acol.insert_one(templ)
+ await self.refresh_acache(group_id)
+ except Exception as e:
+ print(e)
+ return False
+
+ return True
+
+
+ async def del_active(self, group_id: int, channel_id: int):
+ """
+ A funtion to delete a channel from active chat colletion in db
+ """
+ templ = {"$pull": {"chats": dict(chat_id = channel_id)}}
+
+ try:
+ await self.acol.update_one({"_id": group_id}, templ, False, True)
+ except Exception as e:
+ print(e)
+ pass
+
+ await self.refresh_acache(group_id)
+ return True
+
+
+ async def update_active(self, group_id: int, channel_id: int, channel_name):
+ """
+ A Funtion to add a new active chat to the connected group
+ """
+ group_id, channel_id = int(group_id), int(channel_id)
+
+ prev = await self.acol.find_one({"_id": group_id})
+ templ = {"$push" : {"chats" : dict(chat_id = channel_id, chat_name = channel_name)}}
+ in_c = await self.in_active(group_id, channel_id)
+
+ if prev:
+ if not in_c:
+ await self.acol.update_one({"_id": group_id}, templ)
+ else:
+ return False
+ else:
+ await self.add_active(group_id, channel_id, channel_name)
+ return True
+
+
+ async def find_active(self, group_id: int):
+ """
+ A Funtion to find all active chats of
+ a group from db
+ """
+ if self.acache.get(str(group_id)):
+ self.acache.get(str(group_id))
+
+ connection = await self.acol.find_one({"_id": group_id})
+
+ if connection:
+ return connection
+ return False
+
+
+ async def in_active(self, group_id: int, channel_id: int):
+ """
+ A Funtion to check if a chat id is in the active
+ chat id list in db
+ """
+ prev = await self.acol.find_one({"_id": group_id})
+
+ if prev:
+ for x in prev["chats"]:
+ if x["chat_id"] == channel_id:
+ return True
+
+ return False
+
+ return False
+
+
+ async def delall_active(self, group_id: int):
+ """
+ A Funtion to Delete all active chats of
+ a group from db
+ """
+ await self.acol.delete_one({"_id":int(group_id)})
+ await self.refresh_acache(group_id)
+ return
+
+
+ async def refresh_acache(self, group_id: int):
+ """
+ A Funtion to refresh a active chat's chase data
+ in case of update in db
+ """
+ if self.acache.get(str(group_id)):
+ self.acache.pop(str(group_id))
+
+ prev = await self.acol.find_one({"_id": group_id})
+
+ if prev:
+ self.acache[str(group_id)] = prev
+ return True
+
+ # Related To Finding Filter(s)
+ async def add_filters(self, data):
+ """
+ A Funtion to add document as
+ a bulk to db
+ """
+ try:
+ await self.fcol.insert_many(data)
+ except Exception as e:
+ print(e)
+
+ return True
+
+
+ async def del_filters(self, group_id: int, channel_id: int):
+ """
+ A Funtion to delete all filters of a specific
+ chat and group from db
+ """
+ group_id, channel_id = int(group_id), int(channel_id)
+
+ try:
+ await self.fcol.delete_many({"chat_id": channel_id, "group_id": group_id})
+ print(await self.cf_count(group_id, channel_id))
+ return True
+ except Exception as e:
+ print(e)
+ return False
+
+
+ async def delall_filters(self, group_id: int):
+ """
+ A Funtion To delete all filters of a group
+ """
+ await self.fcol.delete_many({"group_id": int(group_id)})
+ return True
+
+
+ async def get_filters(self, group_id: int, keyword: str):
+ """
+ A Funtion to fetch all similar results for a keyowrd
+ from using text index
+ """
+ await self.create_index()
+
+ chat = await self.find_chat(group_id)
+ chat_accuracy = float(chat["configs"].get("accuracy", 0.80))
+ achats = await self.find_active(group_id)
+
+ achat_ids=[]
+ if not achats:
+ return False
+
+ for chats in achats["chats"]:
+ achat_ids.append(chats.get("chat_id"))
+
+ filters = []
+
+ pipeline= {
+ 'group_id': int(group_id), '$text':{'$search': keyword}
+ }
+
+
+ db_list = self.fcol.find(
+ pipeline,
+ {'score': {'$meta':'textScore'}} # Makes A New Filed With Match Score In Each Document
+ )
+
+ db_list.sort([("score", {'$meta': 'textScore'})]) # Sort all document on the basics of the score field
+
+ for document in await db_list.to_list(length=600):
+ if document["score"] < chat_accuracy:
+ continue
+
+ if document["chat_id"] in achat_ids:
+ filters.append(document)
+ else:
+ continue
+
+ return filters
+
+
+ async def get_file(self, unique_id: str):
+ """
+ A Funtion to get a specific files using its
+ unique id
+ """
+ file = await self.fcol.find_one({"unique_id": unique_id})
+ file_id = None
+ file_type = None
+ file_name = None
+ file_caption = None
+
+ if file:
+ file_id = file.get("file_id")
+ file_name = file.get("file_name")
+ file_type = file.get("file_type")
+ file_caption = file.get("file_caption")
+ return file_id, file_name, file_caption, file_type
+
+
+ async def cf_count(self, group_id: int, channel_id: int):
+ """
+ A Funtion To count number of filter in channel
+ w.r.t the connect group
+ """
+ return await self.fcol.count_documents({"chat_id": channel_id, "group_id": group_id})
+
+
+ async def tf_count(self, group_id: int):
+ """
+ A Funtion to count total filters of a group
+ """
+ return await self.fcol.count_documents({"group_id": group_id})
+
diff --git a/DonLee_Robot/Modules/Filters/__init__.py b/DonLee_Robot/Modules/Filters/__init__.py
new file mode 100644
index 000000000..ded8c2fa9
--- /dev/null
+++ b/DonLee_Robot/Modules/Filters/__init__.py
@@ -0,0 +1,2 @@
+from .Main import Database
+from .Filter import FIND, INVITE_LINK, ACTIVE_CHATS, recacher, gen_invite_links, recacher
From 09f2dc97b5dc77806f98eb26cdb4318b40fb59db Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:23:19 +0530
Subject: [PATCH 65/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Modules/Filters/MoTech.txt | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 DonLee_Robot/Modules/Filters/MoTech.txt
diff --git a/DonLee_Robot/Modules/Filters/MoTech.txt b/DonLee_Robot/Modules/Filters/MoTech.txt
deleted file mode 100644
index 8b1378917..000000000
--- a/DonLee_Robot/Modules/Filters/MoTech.txt
+++ /dev/null
@@ -1 +0,0 @@
-
From 26b1527a686d8feb964de1cbbab40fdf668ba429 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:24:21 +0530
Subject: [PATCH 66/77] Create motech.py
---
DonLee_Robot/Modules/Settings/motech.py | 1 +
1 file changed, 1 insertion(+)
create mode 100644 DonLee_Robot/Modules/Settings/motech.py
diff --git a/DonLee_Robot/Modules/Settings/motech.py b/DonLee_Robot/Modules/Settings/motech.py
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/DonLee_Robot/Modules/Settings/motech.py
@@ -0,0 +1 @@
+
From 9cf43d9e76a9911e918bd31bd0f3598f48a04219 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:25:11 +0530
Subject: [PATCH 67/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Modules/Settings/Settings.py | 82 +++++++++++++++++++++++
DonLee_Robot/Modules/Settings/__init__.py | 3 +
2 files changed, 85 insertions(+)
create mode 100644 DonLee_Robot/Modules/Settings/Settings.py
create mode 100644 DonLee_Robot/Modules/Settings/__init__.py
diff --git a/DonLee_Robot/Modules/Settings/Settings.py b/DonLee_Robot/Modules/Settings/Settings.py
new file mode 100644
index 000000000..a3cc3c41c
--- /dev/null
+++ b/DonLee_Robot/Modules/Settings/Settings.py
@@ -0,0 +1,82 @@
+# (c) @AlbertEinsteinTG
+# (c) @Muhammed_RK, @MRK_YT, @Mo_Tech_Group, @MT_Botz
+# Copyright permission under MIT License
+# All rights reserved by PR0FESS0R-99
+# License -> https://github.com/PR0FESS0R-99/DonLee_Robot/blob/main/LICENSE
+
+import re
+from pyrogram import filters
+from pyrogram import Client as DonLee_Robot
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
+
+from DonLee_Robot import VERIFY # pylint: disable=import-error
+
+@DonLee_Robot.on_message(filters.command(["settings"]) & filters.group, group=1)
+async def settings(bot, update):
+
+ chat_id = update.chat.id
+ user_id = update.from_user.id if update.from_user else None
+ global VERIFY
+
+ if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List
+ admin_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admin_list.append(admin_id)
+ admin_list.append(None)
+ VERIFY[str(chat_id)] = admin_list
+
+ if not user_id in VERIFY.get(str(chat_id)): # Checks if user is admin of the chat
+ return
+
+ bot_info = await bot.get_me()
+ bot_first_name= bot_info.first_name
+
+ text =f"{bot_first_name}'s Settings Pannel.....\n"
+ text+=f"\nYou Can Use This Menu To Change Connectivity And Know Status Of Your Every Connected Channel, Change Filter Types, Configure Filter Results And To Know Status Of Your Group..."
+
+ buttons = [[
+ InlineKeyboardButton("Channels", callback_data=f"channel_list({chat_id})"),
+ InlineKeyboardButton("Filter Types", callback_data=f"types({chat_id})")
+ ],[
+ InlineKeyboardButton("Configure 🛠", callback_data=f"config({chat_id})")
+ ],[
+ InlineKeyboardButton("Status", callback_data=f"status({chat_id})"),
+ InlineKeyboardButton("About", callback_data=f"about({chat_id})")
+ ],[
+ InlineKeyboardButton("Close 🔐", callback_data="close")
+ ]]
+
+ reply_markup = InlineKeyboardMarkup(buttons)
+
+ await bot.send_message (
+ chat_id=chat_id,
+ text=text,
+ reply_markup=reply_markup,
+ parse_mode="html",
+ reply_to_message_id=update.message_id
+ )
+
+def remove_emoji(string):
+ emoji_pattern = re.compile("["
+ u"\U0001F600-\U0001F64F"
+ u"\U0001F300-\U0001F5FF"
+ u"\U0001F680-\U0001F6FF"
+ u"\U0001F1E0-\U0001F1FF"
+ u"\U00002500-\U00002BEF"
+ u"\U00002702-\U000027B0"
+ u"\U00002702-\U000027B0"
+ u"\U000024C2-\U0001F251"
+ u"\U0001f926-\U0001f937"
+ u"\U00010000-\U0010ffff"
+ u"\u2640-\u2642"
+ u"\u2600-\u2B55"
+ u"\u200d"
+ u"\u23cf"
+ u"\u23e9"
+ u"\u231a"
+ u"\ufe0f"
+ u"\u3030"
+ "]+", flags=re.UNICODE)
+
+ return emoji_pattern.sub(r' ', str(string))
diff --git a/DonLee_Robot/Modules/Settings/__init__.py b/DonLee_Robot/Modules/Settings/__init__.py
new file mode 100644
index 000000000..906cb95ec
--- /dev/null
+++ b/DonLee_Robot/Modules/Settings/__init__.py
@@ -0,0 +1,3 @@
+from .Settings import(
+ remove_emoji
+)
From cefc1cde7437c5fcaf717ad3d3db66e14f2cc840 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:25:45 +0530
Subject: [PATCH 68/77] Delete motech.py
---
DonLee_Robot/Modules/Settings/motech.py | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 DonLee_Robot/Modules/Settings/motech.py
diff --git a/DonLee_Robot/Modules/Settings/motech.py b/DonLee_Robot/Modules/Settings/motech.py
deleted file mode 100644
index 8b1378917..000000000
--- a/DonLee_Robot/Modules/Settings/motech.py
+++ /dev/null
@@ -1 +0,0 @@
-
From 0d5bc9e8229358e3de276d96a3c54370bbe8584e Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:30:02 +0530
Subject: [PATCH 69/77] =?UTF-8?q?=F0=9F=92=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DonLee_Robot/Modules/Filters/Main.py | 23 +----------------------
1 file changed, 1 insertion(+), 22 deletions(-)
diff --git a/DonLee_Robot/Modules/Filters/Main.py b/DonLee_Robot/Modules/Filters/Main.py
index df4305848..126447893 100644
--- a/DonLee_Robot/Modules/Filters/Main.py
+++ b/DonLee_Robot/Modules/Filters/Main.py
@@ -19,27 +19,7 @@ def __init__(self):
self.fcol = self.db["Filter_Collection"]
self.dcol = self.db.users
- self.cache = {}
- self.acache = {}
- def new_user(self, id):
- return dict(
- id = id,
- join_date = datetime.date.today().isoformat()
- )
- async def add_user(self, id):
- user = self.new_user(id)
- await self.dcol.insert_one(user)
- async def is_user_exist(self, id):
- user = await self.dcol.find_one({'id':int(id)})
- return True if user else False
- async def total_users_count(self):
- count = await self.dcol.count_documents({})
- return count
- async def get_all_users(self):
- all_users = self.dcol.find({})
- return all_users
- async def delete_user(self, user_id):
- await self.dcol.delete_many({'id': int(user_id)})
+
async def create_index(self):
"""
@@ -518,4 +498,3 @@ async def tf_count(self, group_id: int):
A Funtion to count total filters of a group
"""
return await self.fcol.count_documents({"group_id": group_id})
-
From 0529d71cc54dd4a517be4cbb172dbe125f2d4093 Mon Sep 17 00:00:00 2001
From: PR0FESS0R-99 <74817426+PR0FESS0R-99@users.noreply.github.com>
Date: Thu, 14 Oct 2021 10:39:22 +0530
Subject: [PATCH 70/77] Update Readme.md
---
Readme.md | 140 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 83 insertions(+), 57 deletions(-)
diff --git a/Readme.md b/Readme.md
index dd4166006..45f20648b 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,28 +1,80 @@
-# Adv Auto Filter Bot V2
+# DONLEE_ROBOT
-__This Is Just An Simple Advance Auto Filter Bot Complete Rewritten Version Of [Adv-Filter-Bot](https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot)..__
+--------
-__Just Sent Any Text As Query It Will Search For All Connected Chat's Files In Its MongoDB And Reply You With The Message Link As A Button__
+This Is Just An Simple Advance Auto Filter Bot Complete Rewritten Version Of [Adv-Auto-Filter-Bot-v1](https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot)
+Just Sent Any Text As Query It Will Search For All Connected Chat's Files In Its MongoDB And Reply You With The Message Link As A Button
-## Usage
+------
-**__How To Use Me!?__**
+#### FEATURE
-* -> Add me to any group and make me admin
-* -> Add me to your channel as admin with full previlages
+* IMDB Poster Available
+* Spelling Mode
+* Main Text Mode (Kitto, Undo, Ille, Therumo)
+* Button Mode
+* Movie Text Mode (movie, Movie)
+
+--------
+##### Available DonLee Bots
+
+Auto Filter Orginal
+
+
+### Notice
+* This [Deploy button](https://heroku.com/deploy?template=https://github.com/PR0FESS0R-99/DonLee_Robot/tree/main) is the original
+* Click [Deploy Video](https://youtu.be/uAHl5jvnrhk) to watch the video
+
+#### Deploy Video
+
+
+
+#### Deploy To Heroku
+
+Auto Filter 3 Editing Repo
+
+
+### Notice
+* This [Deploy button](https://heroku.com/deploy?template=https://github.com/PR0FESS0R-99/DonLee_Robot/tree/MoTech) is the original
+* Click [Deploy Video](https://youtu.be/lI71HsWzTKE) to watch the video
+
+#### Deploy Video
+
+
+
+#### Deploy To Heroku
+
+
+
+
+* Add me to your channel as admin with full previlages
**Bot Commands (Works Only In Groups) :**
@@ -41,70 +93,44 @@ OR
`/del @Username`
- * -> `/delall` - To delete all connections of a group and deletes all its file from DB
+ * `/delall` - To delete all connections of a group and deletes all its file from DB
- * -> `/settings` - To disaply a Settings Pannel Instance which can be used to tweek bot's settings accordingly
+ * `/settings` - To disaply a Settings Pannel Instance which can be used to tweek bot's settings accordingly
- * -> Channel - Button will show you all the connected chats with the group along with there index buttons correspnding to there order for furthur controls...
+ * Channel - Button will show you all the connected chats with the group along with there index buttons correspnding to there order for furthur controls...
- * -> Filter Types - Button will show you the 3 filter types available in bot... Pressing each buttons will either enable or disable them and this will take into action as soon as you use them...without the need of a restart....
+ * Filter Types - Button will show you the 3 filter types available in bot... Pressing each buttons will either enable or disable them and this will take into action as soon as you use them...without the need of a restart....
- * -> Configure - Button will help you to change no. of pages/ buttons per page/ total result without acutally editing the repo... Also it provide option to Enable/Disable showing Invite Link in each results
+ * Configure - Button will help you to change no. of pages/ buttons per page/ total result without acutally editing the repo... Also it provide option to Enable/Disable showing Invite Link in each results
- * -> Status - Button will show the stats of your current group
+ * Status - Button will show the stats of your current group
-### Pre Requisites
------------------
-* ->__Your Bot Token From [@BotFather](http://www.telegram.dog/BotFather)__
-
-* ->__Your APP ID And API Harsh From [Telegram](http://www.my.telegram.org) or [@UseTGXBot](http://www.telegram.dog/UseTGXBot)__
+##### Main Pre Requisites
-* ->__Your User Session String Obtained From [@PyrogramStringBot](http://www.telegram.dog/PyrogramStringBot)__
+* Your Bot Token From [@BotFather](https://youtu.be/cB4UduCcNWs)__
-* ->__Mongo DB URL Obtained From [Mongo DB](http://www.mongodb.com)__
+* Your APP ID And API Harsh From [Telegram](https://youtu.be/5eEsvLAKVc0) or [@MT_MytelegramOrg_Bit](https://youtu.be/5eEsvLAKVc0)
-#### PR's Are Very Welcome
+* Your User Session String Obtained From [Telegram Bot](https://youtu.be/WUN_12-dYOM)
-## Deploy
-You can deploy this bot anywhere.
+* Mongo DB URL Obtained From [Mongo DB](https://youtu.be/gBLTsH-IXr0)
-**[Watch Deploying Tutorial...](https://youtu.be/KTearEPhumc)**
-
-Deploy To Heroku
-
-
-
-
-
Deploy To VPS
-
-git clone https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot-V2
-cd Adv-Auto-Filter-Bot-V2
-pip3 install -r requirements.txt
-# Change The Vars Of bot/__init__.py File Accordingly
-python3 -m bot
-
-
@@ -61,7 +61,7 @@ Just Sent Any Text As Query It Will Search For All Connected Chat's Files In Its
#### Deploy To Heroku
-
+
+
@@ -53,7 +53,7 @@ Just Sent Any Text As Query It Will Search For All Connected Chat's Files In Its
+
From 0e0320217bf1ee42e0b13a515467af77655c77c5 Mon Sep 17 00:00:00 2001
From: sara1541 <66244144+sara1541@users.noreply.github.com>
Date: Wed, 9 Feb 2022 22:52:47 +0530
Subject: [PATCH 77/77] Update Readme.md
---
Readme.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Readme.md b/Readme.md
index 3f6a5bd12..86213a755 100644
--- a/Readme.md
+++ b/Readme.md
@@ -2,12 +2,12 @@
@@ -44,7 +44,7 @@ Just Sent Any Text As Query It Will Search For All Connected Chat's Files In Its
+
@@ -61,7 +61,7 @@ Just Sent Any Text As Query It Will Search For All Connected Chat's Files In Its
+