From 12d62cf58a0b0538e0163efc5e846d9762b56513 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Mon, 5 Apr 2021 21:51:27 +0530
Subject: [PATCH 01/34] =?UTF-8?q?Yeh=20Maybe=20Fixed=20It=20=F0=9F=98=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
bot/plugins/settings.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
index ad776c8..5350c99 100644
--- a/bot/plugins/settings.py
+++ b/bot/plugins/settings.py
@@ -14,7 +14,7 @@ async def settings(bot, update):
chat_id = update.chat.id
chat_name = (remove_emoji(update.chat.title)).encode('ascii', 'ignore').decode('ascii')[:38]
- if hasattr(update, "from_user"): # Anonymous Admin Bypass
+ if not update.sender_chat: # Anonymous Admin Bypass
user_id = update.from_user.id
try:
user_info = await bot.get_chat_member(chat_id, user_id)
From 51134e6289857089a177ebbfd3c727edc21ceaa9 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Tue, 6 Apr 2021 08:57:35 +0530
Subject: [PATCH 02/34] Update callback.py
---
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 ab7c418..1cfd7cc 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -275,7 +275,7 @@ async def callback_data(bot, update: CallbackQuery):
A Callback Funtion For Displaying All Channel List And Providing A Menu To Navigate
To Every COnnect Chats For Furthur Control
"""
- if hasattr(update.message.reply_to_message, "from_user"): # Just To Make Sure If Its Anonymous Admin Or Not
+ if not update.message.reply_to_message.sender_chat: #hasattr(update.message.reply_to_message, "from_user"): # Just To Make Sure If Its Anonymous Admin Or Not
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
From a94f85691fc2cbc932486a970cff2f58adb3ce4e Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Tue, 6 Apr 2021 12:48:00 +0530
Subject: [PATCH 03/34] Update callback.py
---
bot/plugins/callback.py | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
index 1cfd7cc..f7bc9ed 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -36,7 +36,7 @@ async def callback_data(bot, update: CallbackQuery):
index_val, btn, query = re.findall(r"navigate\((.+)\)", query_data)[0].split("|", 2)
- if hasattr(update.message.reply_to_message, "from_user"): # Anonymous Admin Bypass
+ if update.message.reply_to_message.sender_chat == None: # Anonymous Admin Bypass
ruser_id = update.message.reply_to_message.from_user.id or None
auser_id = update.from_user.id
try:
@@ -162,7 +162,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Back Button in /settings Command
"""
- if hasattr(update.message.reply_to_message, "from_user"): # Anonymous Admin Bypass
+ if update.message.reply_to_message.sender_chat == None: # Anonymous Admin Bypass
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -222,7 +222,8 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Acknowledging User's About What Are They Upto
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
+
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -275,7 +276,8 @@ async def callback_data(bot, update: CallbackQuery):
A Callback Funtion For Displaying All Channel List And Providing A Menu To Navigate
To Every COnnect Chats For Furthur Control
"""
- if not update.message.reply_to_message.sender_chat: #hasattr(update.message.reply_to_message, "from_user"): # Just To Make Sure If Its Anonymous Admin Or Not
+ if update.message.reply_to_message.sender_chat == None: # Just To Make Sure If Its Anonymous Admin Or Not
+
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -369,7 +371,7 @@ async def callback_data(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
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -461,7 +463,8 @@ async def callback_data(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
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -528,7 +531,7 @@ async def callback_data(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
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -595,7 +598,7 @@ async def callback_data(bot, update: CallbackQuery):
A Callback Funtion For Delete A Channel Connection From A Group Chat History
Along With All Its Filter Files
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -640,7 +643,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Delete A Specific Channel's Filters Connected To A Group
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -680,7 +683,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Changing The Result Types To Be Shown In While Sending Results
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -757,7 +760,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion Support handler For types()
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -866,7 +869,7 @@ async def callback_data(bot, update: CallbackQuery):
A Callback Funtion For Chaning The Number Of Total Pages /
Total Results / Results Per pages / Enable or Diable Invite Link
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -946,7 +949,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Changing The Count Of Result To Be Shown Per Page
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -1010,7 +1013,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Changing The Count Of Maximum Result Pages To Be Shown
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -1070,7 +1073,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Changing The Count Of Maximum Files TO Be Fetched From Database
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -1135,7 +1138,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Enabling Or Diabling Invite Link Buttons
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -1190,7 +1193,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion Support For config()
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -1266,7 +1269,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Showing Overall Status Of A Group
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
@@ -1304,7 +1307,7 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Showing About Section In Bot Setting Menu
"""
- if hasattr(update.message.reply_to_message, "from_user"):
+ if update.message.reply_to_message.sender_chat == None:
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
From 62b3f9709b83ea07f6979f2b8752b9202441c884 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Tue, 6 Apr 2021 12:54:40 +0530
Subject: [PATCH 04/34] Update settings.py
---
bot/plugins/settings.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
index 5350c99..0b84968 100644
--- a/bot/plugins/settings.py
+++ b/bot/plugins/settings.py
@@ -25,7 +25,9 @@ async def settings(bot, update):
return
verify[str(update.message_id)] = user_id
-
+ else:
+ verify[str(update.message_id)] = chat_id
+
bot_status = await bot.get_me()
bot_fname= bot_status.first_name
From a1e591bc09b7b1771d2649974f5a4d69c5eeb1d2 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Tue, 6 Apr 2021 13:05:59 +0530
Subject: [PATCH 05/34] Update callback.py
---
bot/plugins/callback.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
index f7bc9ed..b6585cb 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -277,10 +277,19 @@ async def callback_data(bot, update: CallbackQuery):
To Every COnnect Chats For Furthur Control
"""
if update.message.reply_to_message.sender_chat == None: # Just To Make Sure If Its Anonymous Admin Or Not
-
if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
return
-
+ else:
+ print("2nd If")
+ print(verify.get(str(update.message.reply_to_message.message_id)))
+ print(update.from_user.id)
+ print(verify)
+ else:
+ print("1st If")
+ print(update.message.reply_to_message)
+ print()
+ print()
+ print(update.message.reply_to_message.sender_chat)
chat_id, chat_name = re.findall(r"channel_list\((.+)\)", query_data)[0].split("|", 1)
From c2a1654df5de041acf44af9629830a2e152d67bc Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Tue, 6 Apr 2021 15:16:24 +0530
Subject: [PATCH 06/34] Pure Testing
---
bot/plugins/callback.py | 26 +++++++++++++++-----------
bot/plugins/settings.py | 2 --
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
index b6585cb..cbb5b8d 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -276,20 +276,24 @@ async def callback_data(bot, update: CallbackQuery):
A Callback Funtion For Displaying All Channel List And Providing A Menu To Navigate
To Every COnnect Chats For Furthur Control
"""
+ user_id = update.from_user.id
if update.message.reply_to_message.sender_chat == None: # Just To Make Sure If Its Anonymous Admin Or Not
- if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
+ if verify.get(str(update.message.reply_to_message.message_id)) != user_id:
return
- else:
- print("2nd If")
- print(verify.get(str(update.message.reply_to_message.message_id)))
- print(update.from_user.id)
- print(verify)
else:
- print("1st If")
- print(update.message.reply_to_message)
- print()
- print()
- print(update.message.reply_to_message.sender_chat)
+ if not verify.get(str(update.message.reply_to_message.message_id)):
+ try:
+ user_info = await bot.get_chat_member(chat_id, user_id)
+ except Exception:
+ return
+ if user_info.status in ["member"]:
+ return
+ global verify
+ verify[str(update.message.reply_to_message.message_id)] = user_id
+
+ elif verify.get(str(update.message.reply_to_message.message_id)) != user_id:
+ return
+
chat_id, chat_name = re.findall(r"channel_list\((.+)\)", query_data)[0].split("|", 1)
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
index 0b84968..6f633a4 100644
--- a/bot/plugins/settings.py
+++ b/bot/plugins/settings.py
@@ -25,8 +25,6 @@ async def settings(bot, update):
return
verify[str(update.message_id)] = user_id
- else:
- verify[str(update.message_id)] = chat_id
bot_status = await bot.get_me()
bot_fname= bot_status.first_name
From b21411d507beffe735ee69879e08a727959f614f Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Tue, 6 Apr 2021 17:00:20 +0530
Subject: [PATCH 07/34] Update callback.py
---
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 cbb5b8d..8341150 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -25,6 +25,7 @@
@Client.on_callback_query()
async def callback_data(bot, update: CallbackQuery):
+ global verify
query_data = update.data
chat_id = update.message.chat.id
chat_name = remove_emoji(update.message.chat.title).encode('ascii', 'ignore').decode('ascii')[:38]
@@ -288,7 +289,6 @@ async def callback_data(bot, update: CallbackQuery):
return
if user_info.status in ["member"]:
return
- global verify
verify[str(update.message.reply_to_message.message_id)] = user_id
elif verify.get(str(update.message.reply_to_message.message_id)) != user_id:
From a40d550722476786e5b020b416780a5d97bbe213 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 14 Apr 2021 19:47:30 +0530
Subject: [PATCH 08/34] just developing
out of time now
---
bot/__init__.py | 1 +
bot/plugins/settings.py | 30 ++++++++++++++++++++----------
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/bot/__init__.py b/bot/__init__.py
index 936a6b9..595b322 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -21,6 +21,7 @@
USER_SESSION = os.environ.get("USER_SESSION")
+verify = {}
logging.basicConfig(
level=logging.INFO,
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
index 6f633a4..5e1e43c 100644
--- a/bot/plugins/settings.py
+++ b/bot/plugins/settings.py
@@ -6,26 +6,36 @@
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-verify={}
+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
+<<<<<<< Updated upstream
chat_name = (remove_emoji(update.chat.title)).encode('ascii', 'ignore').decode('ascii')[:38]
+=======
+ user_id = update.from_user.id or None
+ chat_name = remove_emoji(update.chat.title)
+ chat_name = chat_name.encode('ascii', 'ignore')
+ chat_name = chat_name.decode('ascii')[:38]
+>>>>>>> Stashed changes
- if not update.sender_chat: # Anonymous Admin Bypass
- user_id = update.from_user.id
- try:
- user_info = await bot.get_chat_member(chat_id, user_id)
- except Exception:
- return
-
- if user_info.status == ("member"):
- return
+ if not verify[str(chat_id)]: # Admin List
+ admin_list = []
+<<<<<<< Updated upstream
verify[str(update.message_id)] = user_id
+=======
+ await bot.get_chat_members(chat_id)
+
+ verify[str(chat_id)] = user_id
+ else:
+ if not user_id in verify.get(str(chat_id)):
+ return
+
+>>>>>>> Stashed changes
bot_status = await bot.get_me()
bot_fname= bot_status.first_name
From b63306b3fb2710d3470e2d837d530592d030bf41 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 14 Apr 2021 20:54:07 +0530
Subject: [PATCH 09/34] Sort Of Testing
---
bot/plugins/callback.py | 30 +++++++++++-------------
bot/plugins/channel.py | 52 +++++++++++++++++++++++++++++------------
bot/plugins/settings.py | 32 ++++++++++---------------
3 files changed, 63 insertions(+), 51 deletions(-)
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
index 8341150..0c6288b 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -6,7 +6,7 @@
from pyrogram.errors import FloodWait, UserNotParticipant
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
-from bot import start_uptime, Translation # pylint: disable=import-error
+from bot import start_uptime, Translation, verify # pylint: disable=import-error
from bot.plugins.auto_filter import ( # pylint: disable=import-error
Find,
InviteLink,
@@ -29,7 +29,9 @@ async def callback_data(bot, update: CallbackQuery):
query_data = update.data
chat_id = update.message.chat.id
chat_name = remove_emoji(update.message.chat.title).encode('ascii', 'ignore').decode('ascii')[:38]
-
+ user_id = update.from_user.id
+
+
if re.fullmatch(r"navigate\((.+)\)", query_data):
"""
A Callback Funtion For The Next Button Appearing In Results
@@ -40,19 +42,16 @@ async def callback_data(bot, update: CallbackQuery):
if update.message.reply_to_message.sender_chat == None: # Anonymous Admin Bypass
ruser_id = update.message.reply_to_message.from_user.id or None
auser_id = update.from_user.id
- try:
- user = await bot.get_chat_member(update.message.chat.id, auser_id)
-
- except UserNotParticipant:
- await update.answer("Nice Try ;)",show_alert=True)
- return
- except Exception as e:
- print(e)
- return
+ if not verify[str(chat_id)]: # 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 (auser_id != ruser_id) or (user.status == "member"):
-
+ if (auser_id != ruser_id) or (auser_id not in verify.get(str(chat_id))):
await update.answer("Nice Try ;)",show_alert=True)
return
@@ -163,9 +162,8 @@ async def callback_data(bot, update: CallbackQuery):
"""
A Callback Funtion For Back Button in /settings Command
"""
- if update.message.reply_to_message.sender_chat == None: # Anonymous Admin Bypass
- if verify.get(str(update.message.reply_to_message.message_id)) != update.from_user.id:
- return
+ if user_id not in verify.get(str(chat_id)):
+ return
bot_status = await bot.get_me()
bot_fname= bot_status.first_name
diff --git a/bot/plugins/channel.py b/bot/plugins/channel.py
index a6a6f23..b001312 100644
--- a/bot/plugins/channel.py
+++ b/bot/plugins/channel.py
@@ -1,6 +1,7 @@
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
@@ -13,12 +14,19 @@ 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
+ user_id = update.from_user.id or None
target_chat = update.text.split(None, 1)[1]
-
- user_info = await bot.get_chat_member(chat_id, user_id)
-
- if user_info.status == ("member"):
+ global verify
+
+ if not verify[str(chat_id)]: # 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:
@@ -145,12 +153,19 @@ 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
+ user_id = update.from_user.id or None
target_chat = update.text.split(None, 1)[1]
-
- user_info = await bot.get_chat_member(chat_id, user_id)
-
- if user_info.status == ("member"):
+ global verify
+
+ if not verify[str(chat_id)]: # 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:
@@ -177,7 +192,6 @@ async def disconnect(bot: Bot, update):
try:
channel_info = await bot.USER.get_chat(target)
channel_id = channel_info.id
- channel_name = channel_info.title
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
@@ -205,10 +219,17 @@ async def delall(bot: Bot, update):
"""
chat_id=update.chat.id
user_id = update.from_user.id
-
- user_info = await bot.get_chat_member(chat_id, user_id)
-
- if user_info.status == ("member"):
+ global verify
+
+ if not verify[str(chat_id)]: # 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)
@@ -272,3 +293,4 @@ async def new_files(bot: Bot, update):
data.append(data_packets)
await db.add_filters(data)
return
+
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
index 5e1e43c..8fe6364 100644
--- a/bot/plugins/settings.py
+++ b/bot/plugins/settings.py
@@ -12,30 +12,22 @@
async def settings(bot, update):
chat_id = update.chat.id
-<<<<<<< Updated upstream
- chat_name = (remove_emoji(update.chat.title)).encode('ascii', 'ignore').decode('ascii')[:38]
-=======
user_id = update.from_user.id or None
chat_name = remove_emoji(update.chat.title)
- chat_name = chat_name.encode('ascii', 'ignore')
- chat_name = chat_name.decode('ascii')[:38]
->>>>>>> Stashed changes
+ chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:38]
+ global verify
- if not verify[str(chat_id)]: # Admin List
+ if not verify[str(chat_id)]: # Make Admin's ID List
admin_list = []
-
-<<<<<<< Updated upstream
- verify[str(update.message_id)] = user_id
-
-=======
- await bot.get_chat_members(chat_id)
-
- verify[str(chat_id)] = user_id
- else:
- if not user_id in verify.get(str(chat_id)):
- return
+ 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
->>>>>>> Stashed changes
bot_status = await bot.get_me()
bot_fname= bot_status.first_name
@@ -114,4 +106,4 @@ def remove_emoji(string):
u"\u3030"
"]+", flags=re.UNICODE)
- return emoji_pattern.sub(r' ', string)
\ No newline at end of file
+ return emoji_pattern.sub(r' ', str(string))
From 1fa5923d729518cf271e77046e838a10d8c4d239 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 14 Apr 2021 21:20:58 +0530
Subject: [PATCH 10/34] test 2
---
bot/plugins/callback.py | 2 +-
bot/plugins/channel.py | 6 +++---
bot/plugins/settings.py | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
index 0c6288b..949aa33 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -29,7 +29,7 @@ async def callback_data(bot, update: CallbackQuery):
query_data = update.data
chat_id = update.message.chat.id
chat_name = remove_emoji(update.message.chat.title).encode('ascii', 'ignore').decode('ascii')[:38]
- user_id = update.from_user.id
+ user_id = update.from_user.id if update.from_user else None
if re.fullmatch(r"navigate\((.+)\)", query_data):
diff --git a/bot/plugins/channel.py b/bot/plugins/channel.py
index b001312..02cbde3 100644
--- a/bot/plugins/channel.py
+++ b/bot/plugins/channel.py
@@ -14,7 +14,7 @@ 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 or None
+ user_id = update.from_user.id if update.from_user else None
target_chat = update.text.split(None, 1)[1]
global verify
@@ -153,7 +153,7 @@ 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 or None
+ user_id = update.from_user.id if update.from_user else None
target_chat = update.text.split(None, 1)[1]
global verify
@@ -218,7 +218,7 @@ 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
+ user_id = update.from_user.id if update.from_user else None
global verify
if not verify[str(chat_id)]: # Make Admin's ID List
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
index 8fe6364..25d048a 100644
--- a/bot/plugins/settings.py
+++ b/bot/plugins/settings.py
@@ -12,7 +12,7 @@
async def settings(bot, update):
chat_id = update.chat.id
- user_id = update.from_user.id or None
+ user_id = update.from_user.id if update.from_user else None
chat_name = remove_emoji(update.chat.title)
chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:38]
global verify
From 2a52805f72236eefb2f4d50e8ceafb8b1a4e672f Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 14 Apr 2021 21:28:22 +0530
Subject: [PATCH 11/34] test 3
---
bot/plugins/callback.py | 2 +-
bot/plugins/channel.py | 6 +++---
bot/plugins/settings.py | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
index 949aa33..3bc6d4f 100644
--- a/bot/plugins/callback.py
+++ b/bot/plugins/callback.py
@@ -43,7 +43,7 @@ async def callback_data(bot, update: CallbackQuery):
ruser_id = update.message.reply_to_message.from_user.id or None
auser_id = update.from_user.id
- if not verify[str(chat_id)]: # Make Admin's ID List
+ if not verify.get(str(chat_id)): # 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
diff --git a/bot/plugins/channel.py b/bot/plugins/channel.py
index 02cbde3..5ae0b9e 100644
--- a/bot/plugins/channel.py
+++ b/bot/plugins/channel.py
@@ -18,7 +18,7 @@ async def connect(bot: Bot, update):
target_chat = update.text.split(None, 1)[1]
global verify
- if not verify[str(chat_id)]: # Make Admin's ID List
+ if not verify.get(str(chat_id)): # 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
@@ -157,7 +157,7 @@ async def disconnect(bot: Bot, update):
target_chat = update.text.split(None, 1)[1]
global verify
- if not verify[str(chat_id)]: # Make Admin's ID List
+ if not verify.get(str(chat_id)): # 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
@@ -221,7 +221,7 @@ async def delall(bot: Bot, update):
user_id = update.from_user.id if update.from_user else None
global verify
- if not verify[str(chat_id)]: # Make Admin's ID List
+ if not verify.get(str(chat_id)): # 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
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
index 25d048a..f5f3b0e 100644
--- a/bot/plugins/settings.py
+++ b/bot/plugins/settings.py
@@ -17,7 +17,7 @@ async def settings(bot, update):
chat_name = chat_name.encode('ascii', 'ignore').decode('ascii')[:38]
global verify
- if not verify[str(chat_id)]: # Make Admin's ID List
+ if not verify.get(str(chat_id)): # 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
From 9d8afa29f6ac4538aa2c09bae021d7de4a0b154f Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 14 Apr 2021 21:35:35 +0530
Subject: [PATCH 12/34] test
---
bot/plugins/channel.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/bot/plugins/channel.py b/bot/plugins/channel.py
index 5ae0b9e..11be011 100644
--- a/bot/plugins/channel.py
+++ b/bot/plugins/channel.py
@@ -15,7 +15,7 @@ async def connect(bot: Bot, update):
"""
chat_id = update.chat.id
user_id = update.from_user.id if update.from_user else None
- target_chat = update.text.split(None, 1)[1]
+ target_chat = update.text.split(None, 1)
global verify
if not verify.get(str(chat_id)): # Make Admin's ID List
@@ -30,17 +30,17 @@ async def connect(bot: Bot, update):
return
try:
- if target_chat.startswith("@"):
- if len(target_chat) < 5:
+ if target_chat[1].startswith("@"):
+ if len(target_chat[1]) < 5:
await update.reply_text("Invalid Username...!!!")
return
- target = target_chat
+ target = target_chat[1]
- elif not target_chat.startswith("@"):
- if len(target_chat) < 14:
+ 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)
+ target = int(target_chat[1])
except Exception:
await update.reply_text("Invalid Input...\nYou Should Specify Valid chat_id(-100xxxxxxxxxx) or @username")
From 9d04108fcd3bc525d404b6777b872e94dde1b473 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 18 Apr 2021 17:19:23 +0530
Subject: [PATCH 13/34] Update database.py
---
bot/database/database.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/database/database.py b/bot/database/database.py
index 1f0aa31..49154b5 100644
--- a/bot/database/database.py
+++ b/bot/database/database.py
@@ -364,7 +364,7 @@ async def delall_filters(self, g_id: int):
async def get_filters(self, g_id: int, keyword: str):
- await self.create_index()
+# await self.create_index()
achats = await self.find_active(g_id)
@@ -378,7 +378,7 @@ async def get_filters(self, g_id: int, keyword: str):
filters = []
pipeline= {
- "group_id": g_id, "$text":{"$search": keyword}
+ "group_id": g_id, "file_name": keyword
}
db_list = self.fcol.find(pipeline)
From 871d2d39de857f0def2c31222fd9842c8a8795d5 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 18 Apr 2021 17:36:20 +0530
Subject: [PATCH 14/34] Update database.py
---
bot/database/database.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/database/database.py b/bot/database/database.py
index 49154b5..23caa9b 100644
--- a/bot/database/database.py
+++ b/bot/database/database.py
@@ -380,7 +380,7 @@ async def get_filters(self, g_id: int, keyword: str):
pipeline= {
"group_id": g_id, "file_name": keyword
}
-
+ print(pipeline)
db_list = self.fcol.find(pipeline)
for document in await db_list.to_list(length=600):
From b8e5cc2473dc2076936a84f3cddfcfaf5ec90e9f Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 18 Apr 2021 17:41:36 +0530
Subject: [PATCH 15/34] Update database.py
---
bot/database/database.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/bot/database/database.py b/bot/database/database.py
index 23caa9b..950d964 100644
--- a/bot/database/database.py
+++ b/bot/database/database.py
@@ -380,7 +380,10 @@ async def get_filters(self, g_id: int, keyword: str):
pipeline= {
"group_id": g_id, "file_name": keyword
}
+
print(pipeline)
+ print(await self.fcol.count_documents(pipeline))
+
db_list = self.fcol.find(pipeline)
for document in await db_list.to_list(length=600):
From 3bbe4364841d37bffb041fc8229da7ffb929ced0 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sat, 8 May 2021 11:13:27 +0530
Subject: [PATCH 16/34] Sorted All
---
bot/__init__.py | 2 +-
bot/plugins/Callbacks/About Btn/__init__.py | 14 +
.../Callbacks/About Btn/abt_main_cb.py | 61 +
.../Callbacks/Channels Btn/__init__.py | 14 +
.../Callbacks/Channels Btn/chnl_main_cb.py | 359 ++++
.../Callbacks/Channels Btn/chnl_sub_cb.py | 428 +++++
.../Callbacks/Configure Btn/__init__.py | 14 +
.../Callbacks/Configure Btn/config_main_cb.py | 142 ++
.../Callbacks/Configure Btn/config_sub_cb.py | 463 +++++
bot/plugins/Callbacks/Status Btn/__init__.py | 14 +
.../Callbacks/Status Btn/status_main_cb.py | 72 +
bot/plugins/Callbacks/Types Btn/__init__.py | 14 +
.../Callbacks/Types Btn/typs_main_cb.py | 231 +++
bot/plugins/Callbacks/__init__.py | 13 +
bot/plugins/Callbacks/af_main_cb.py | 419 ++++
bot/plugins/__init__.py | 5 +
bot/plugins/callback.py | 1712 -----------------
bot/plugins/channel.py | 57 +-
bot/plugins/settings.py | 21 +-
bot/plugins/utils.py | 30 +
20 files changed, 2331 insertions(+), 1754 deletions(-)
create mode 100644 bot/plugins/Callbacks/About Btn/__init__.py
create mode 100644 bot/plugins/Callbacks/About Btn/abt_main_cb.py
create mode 100644 bot/plugins/Callbacks/Channels Btn/__init__.py
create mode 100644 bot/plugins/Callbacks/Channels Btn/chnl_main_cb.py
create mode 100644 bot/plugins/Callbacks/Channels Btn/chnl_sub_cb.py
create mode 100644 bot/plugins/Callbacks/Configure Btn/__init__.py
create mode 100644 bot/plugins/Callbacks/Configure Btn/config_main_cb.py
create mode 100644 bot/plugins/Callbacks/Configure Btn/config_sub_cb.py
create mode 100644 bot/plugins/Callbacks/Status Btn/__init__.py
create mode 100644 bot/plugins/Callbacks/Status Btn/status_main_cb.py
create mode 100644 bot/plugins/Callbacks/Types Btn/__init__.py
create mode 100644 bot/plugins/Callbacks/Types Btn/typs_main_cb.py
create mode 100644 bot/plugins/Callbacks/__init__.py
create mode 100644 bot/plugins/Callbacks/af_main_cb.py
create mode 100644 bot/plugins/__init__.py
delete mode 100644 bot/plugins/callback.py
create mode 100644 bot/plugins/utils.py
diff --git a/bot/__init__.py b/bot/__init__.py
index 23d2a30..3cc958d 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -21,7 +21,7 @@
USER_SESSION = os.environ.get("USER_SESSION")
-VERIFY = {}
+CHAT_DETAILS = {}
logging.basicConfig(
level=logging.INFO,
diff --git a/bot/plugins/Callbacks/About Btn/__init__.py b/bot/plugins/Callbacks/About Btn/__init__.py
new file mode 100644
index 0000000..5195b22
--- /dev/null
+++ b/bot/plugins/Callbacks/About Btn/__init__.py
@@ -0,0 +1,14 @@
+from .. import (
+ FIND,
+
+ recacher,
+ admin_list,
+ Database,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ time_formatter,
+ gen_invite_links,
+)
+from .... import start_uptime
\ No newline at end of file
diff --git a/bot/plugins/Callbacks/About Btn/abt_main_cb.py b/bot/plugins/Callbacks/About Btn/abt_main_cb.py
new file mode 100644
index 0000000..45e4612
--- /dev/null
+++ b/bot/plugins/Callbacks/About Btn/abt_main_cb.py
@@ -0,0 +1,61 @@
+import re
+import time
+
+from pyrogram import Client, filters
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
+
+from . import (
+ CHAT_DETAILS,
+ admin_list,
+ time_formatter,
+ start_uptime
+)
+
+@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 CHAT_DETAILS
+ chat_id = update.message.chat.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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"
+ )
\ No newline at end of file
diff --git a/bot/plugins/Callbacks/Channels Btn/__init__.py b/bot/plugins/Callbacks/Channels Btn/__init__.py
new file mode 100644
index 0000000..a4f0a15
--- /dev/null
+++ b/bot/plugins/Callbacks/Channels Btn/__init__.py
@@ -0,0 +1,14 @@
+from .. import (
+ FIND,
+
+ recacher,
+
+ admin_list,
+ Database,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ time_formatter,
+ gen_invite_links,
+)
\ No newline at end of file
diff --git a/bot/plugins/Callbacks/Channels Btn/chnl_main_cb.py b/bot/plugins/Callbacks/Channels Btn/chnl_main_cb.py
new file mode 100644
index 0000000..b579d30
--- /dev/null
+++ b/bot/plugins/Callbacks/Channels Btn/chnl_main_cb.py
@@ -0,0 +1,359 @@
+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 . import (
+ FIND,
+ recacher,
+ Database,
+ admin_list,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ gen_invite_links,
+)
+
+db = Database()
+
+@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 CHAT_DETAILS
+ 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
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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
+ (
+ "Global Connections", callback_data=f"global({chat_id})"
+ )
+ ])
+
+
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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"^global\((.+)\)"), group=2)
+async def cb_global_chats(bot, update:CallbackQuery):
+ """
+ A Callback Funtion For Displaying Details Of All The Connected Chat And Provide
+ Ability To Connect, Disconnect, Delete, Delete Filters of, All Connected Chat In
+ 1 Go
+ """
+ global CHAT_DETAILS
+
+ chat_id = update.message.chat.id
+ chat_name = update.message.chat.title
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ return
+
+ f_count = await db.tf_count(chat_id)
+ connected_chats = await db.find_chat(chat_id)
+ active_chats = await db.find_active(chat_id)
+
+ db_cids = None
+ db_cnames = None
+ total_chats = 0
+
+ if connected_chats: # Checks for active chats connected to a chat
+ dicts = connected_chats["chat_ids"]
+ adicts = active_chats["chats"]
+ adb_cids = [ int(x["chat_id"]) for x in adicts ]
+ db_cids = []
+ db_cnames = []
+ for x in dicts:
+ cid = x["chat_id"]
+ cname = x["chat_name"]
+ print(cname)
+
+ db_cids.append(cid)
+ if cid in adb_cids:
+ cname + " (A)"
+ db_cnames.append(cname)
+
+ print(db_cnames)
+
+ total_chats = len(db_cids)
+
+ text=f"Info About All Connected Of {chat_name}\n"
+ text+=f"\nTotal Connected Chats: {total_chats}\n"
+
+ text+=f"\nChannel Names:\n"
+
+ for y in db_cnames:
+ text+=f"\n {y}"
+
+ text+=f"\nChannel ID's:\n"
+
+ for z in db_cids:
+ text+=f"\n {z}"
+
+ text+=f"\nTotal Files In DB: {f_count}\n"
+
+
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "π Connect All π ", callback_data=f"warn({chat_id}|conn|gcmds)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "π¨ Disconnect All π¨", callback_data=f"warn({chat_id}|disconn|gcmds)"
+ )
+ ]
+ ]
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete All Chats β", callback_data=f"warn({chat_id}|c_delete|gcmds)"
+ )
+ ]
+ )
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete All Filters β ", callback_data=f"warn({chat_id}|f_delete|gcmds)"
+ )
+ ]
+ )
+
+ 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"
+ )
+
diff --git a/bot/plugins/Callbacks/Channels Btn/chnl_sub_cb.py b/bot/plugins/Callbacks/Channels Btn/chnl_sub_cb.py
new file mode 100644
index 0000000..9919995
--- /dev/null
+++ b/bot/plugins/Callbacks/Channels Btn/chnl_sub_cb.py
@@ -0,0 +1,428 @@
+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 . import (
+ FIND,
+ recacher,
+ Database,
+ admin_list,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ gen_invite_links,
+)
+
+db = Database()
+
+
+@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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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"^gcmds\((.)\)"), group=2)
+async def cb_gcmds(bot, update: CallbackQuery):
+ """
+ A Callback Funtion to Connect, Disconnect, Delete, Delete Filters of,
+ All Connected Chat in 1 GO
+ """
+ global CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = update.message.chat.title
+ user_id = update.from_user.id
+
+ print(user_id)
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ print(user_id)
+ print(chat_admins)
+ return
+
+ chat_id, action = re.findall(r"gcmds\((.)\)", query_data)[0].split("|", 1)
+
+ if action == "conn":
+ await db.add_all_chat_as_active(chat_id)
+ await update.answer("Sucessfully Made All Chat Connection Active.....")
+
+ elif action == "disconn":
+ await db.delall_active(chat_id)
+ await update.answer("Sucessfully Disabled All Active Chats.....")
+
+ elif action == "c_delete":
+ await db.delete_all(chat_id)
+ await update.answer("Sucessfully Deleted All Data About This Group From DB")
+
+ elif action == "f_delete":
+ await db.delall_filters(chat_id)
+ await update.answer("Sucessfully Deleted All Files Connected With This Chat...")
+
+
+
+ f_count = await db.tf_count(chat_id)
+ connected_chats = await db.find_chat(chat_id)
+ active_chats = await db.find_active(chat_id)
+
+ db_cids = None
+ db_cnames = None
+ total_chats = 0
+
+ if connected_chats: # Checks for active chats connected to a chat
+ dicts = connected_chats["chat_ids"]
+ adicts = active_chats["chats"]
+ adb_cids = [ int(x["chat_id"]) for x in adicts ]
+ db_cids = []
+ db_cnames = []
+ for x in dicts:
+ cid = x["chat_id"]
+ cname = x["chat_name"]
+
+ db_cids.append(cid)
+ if cid in adb_cids:
+ cname + " (A)"
+ db_cnames.append(db_cnames)
+
+ total_chats = len(db_cids)
+
+ text=f"Info About All Connected Of {chat_name}\n"
+ text+=f"\nTotal Connected Chats: {total_chats}"
+
+ text+=f"\nChannel Names:\n"
+
+ for ch in db_cnames:
+ text+=f" {ch}\n"
+
+ text+=f"\nChannel ID's:\n"
+
+ for ch in db_cnames:
+ text+=f"\n {ch}\n"
+
+ text+=f"\nTotal Files In DB: {f_count}\n"
+
+
+
+ buttons = [
+ [
+ InlineKeyboardButton
+ (
+ "π Connect All π ", callback_data=f"warn({chat_id}|conn|gcmds)"
+ ),
+
+ InlineKeyboardButton
+ (
+ "π¨ Disconnect All π¨", callback_data=f"warn({chat_id}|disconn|gcmds)"
+ )
+ ]
+ ]
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete All Chats β", callback_data=f"warn({chat_id}|c_delete|gcmds)"
+ )
+ ]
+ )
+
+
+ buttons.append(
+ [
+ InlineKeyboardButton
+ (
+ "Delete All Filters β ", callback_data=f"warn({chat_id}|f_delete|gcmds)"
+ )
+ ]
+ )
+
+ 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"
+ )
+
diff --git a/bot/plugins/Callbacks/Configure Btn/__init__.py b/bot/plugins/Callbacks/Configure Btn/__init__.py
new file mode 100644
index 0000000..ac2f88d
--- /dev/null
+++ b/bot/plugins/Callbacks/Configure Btn/__init__.py
@@ -0,0 +1,14 @@
+from .. import (
+ FIND,
+
+ recacher,
+
+ admin_list,
+ Database,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ time_formatter,
+ gen_invite_links,
+)
diff --git a/bot/plugins/Callbacks/Configure Btn/config_main_cb.py b/bot/plugins/Callbacks/Configure Btn/config_main_cb.py
new file mode 100644
index 0000000..9fd569a
--- /dev/null
+++ b/bot/plugins/Callbacks/Configure Btn/config_main_cb.py
@@ -0,0 +1,142 @@
+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 . import (
+ FIND,
+ admin_list,
+ Database,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ time_formatter,
+ gen_invite_links,
+)
+
+db = Database()
+
+
+@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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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"
+ )
+
+
diff --git a/bot/plugins/Callbacks/Configure Btn/config_sub_cb.py b/bot/plugins/Callbacks/Configure Btn/config_sub_cb.py
new file mode 100644
index 0000000..24d4293
--- /dev/null
+++ b/bot/plugins/Callbacks/Configure Btn/config_sub_cb.py
@@ -0,0 +1,463 @@
+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 . import (
+ FIND,
+ recacher,
+ Database,
+ admin_list,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ gen_invite_links,
+)
+
+db = Database()
+
+
+@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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ chat_id = update.message.chat.id
+ chat_name = update.message.chat.title
+ user_id = update.from_user.id
+ query_data = update.data
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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"
+ )
+
diff --git a/bot/plugins/Callbacks/Status Btn/__init__.py b/bot/plugins/Callbacks/Status Btn/__init__.py
new file mode 100644
index 0000000..ac2f88d
--- /dev/null
+++ b/bot/plugins/Callbacks/Status Btn/__init__.py
@@ -0,0 +1,14 @@
+from .. import (
+ FIND,
+
+ recacher,
+
+ admin_list,
+ Database,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ time_formatter,
+ gen_invite_links,
+)
diff --git a/bot/plugins/Callbacks/Status Btn/status_main_cb.py b/bot/plugins/Callbacks/Status Btn/status_main_cb.py
new file mode 100644
index 0000000..f07eeed
--- /dev/null
+++ b/bot/plugins/Callbacks/Status Btn/status_main_cb.py
@@ -0,0 +1,72 @@
+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 . import (
+ FIND,
+ recacher,
+ Database,
+ admin_list,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ gen_invite_links,
+)
+
+db = Database()
+
+@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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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"
+ )
+
+
diff --git a/bot/plugins/Callbacks/Types Btn/__init__.py b/bot/plugins/Callbacks/Types Btn/__init__.py
new file mode 100644
index 0000000..a4f0a15
--- /dev/null
+++ b/bot/plugins/Callbacks/Types Btn/__init__.py
@@ -0,0 +1,14 @@
+from .. import (
+ FIND,
+
+ recacher,
+
+ admin_list,
+ Database,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ time_formatter,
+ gen_invite_links,
+)
\ No newline at end of file
diff --git a/bot/plugins/Callbacks/Types Btn/typs_main_cb.py b/bot/plugins/Callbacks/Types Btn/typs_main_cb.py
new file mode 100644
index 0000000..53826fd
--- /dev/null
+++ b/bot/plugins/Callbacks/Types Btn/typs_main_cb.py
@@ -0,0 +1,231 @@
+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 . import (
+ FIND,
+ recacher,
+ Database,
+ admin_list,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ gen_invite_links,
+)
+
+db = Database()
+
+
+@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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ chat_name = remove_emoji(update.message.chat.title)
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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 CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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"
+ )
+
diff --git a/bot/plugins/Callbacks/__init__.py b/bot/plugins/Callbacks/__init__.py
new file mode 100644
index 0000000..7bdf284
--- /dev/null
+++ b/bot/plugins/Callbacks/__init__.py
@@ -0,0 +1,13 @@
+
+from .. import (
+ FIND,
+ recacher,
+ admin_list,
+ Database,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ time_formatter,
+ gen_invite_links,
+)
diff --git a/bot/plugins/Callbacks/af_main_cb.py b/bot/plugins/Callbacks/af_main_cb.py
new file mode 100644
index 0000000..2c25be3
--- /dev/null
+++ b/bot/plugins/Callbacks/af_main_cb.py
@@ -0,0 +1,419 @@
+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 . import (
+ FIND,
+ recacher,
+ Database,
+ admin_list,
+ ACTIVE_CHATS,
+ CHAT_DETAILS,
+ INVITE_LINK,
+ remove_emoji,
+ gen_invite_links,
+)
+
+
+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 CHAT_DETAILS
+ 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
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if not ((user_id == ruser_id) or (user_id in chat_admins)): # 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 CHAT_DETAILS
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins: # Check If User Is Admin
+ return
+
+ bot_status = await bot.get_me()
+ bot_fname= bot_status.first_name
+
+ text =f"{bot_fname}'s Auto Filter 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 CHAT_DETAILS
+ 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
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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..."
+ text+=f"\nProTip: Make Use Of Disconnect Button To Disable "
+
+
+ elif action=="f_delete":
+ text=f"Are You Sure That You Want To Clear All Filter From This Chat {channel_name} Results Temporarily....{channel_name}???\n"
+ text+=f"\nThis Will Erase All Files From DB.."
+
+
+ elif action == "gcmds" and channel_name == "conn":
+ text=f"Are You Sure You Want To Enable All Connection Of {chat_name}..???\n"
+ text+=f"\nThis Will Show File In The Results From All Chat Connections Of {chat_name}..."
+
+
+ elif action == "gcmds" and channel_name == "disconn":
+ text=f"Are You Sure You Want To Disable All Connection Of {chat_name}....???\n"
+ text+=f"\nThe DB Files Will Still Be There And You Can Connect Back To All Channel Anytime From Settings Menu Without Adding Files To DB Again...\n"
+ text+=f"\nThis Disabling Will No Longer Show Results To Any Query Unless You Enable Back Them..."
+
+
+ elif action == "gcmds" and channel_name == "c_delete":
+ text=f"Are You Sure You Want To Disconnect ALl COnnected Chats Of {chat_name} ....???\n"
+ text+=f"\nThis Will Delete All Connected Channel And All Its Files From DB Too....!!\n"
+ text+=f"\nYou Need To Add Channel Again If You Need To Shows It's Results Again.....\n"
+ text+=f"\nProTip: Make Use Of Disconnect Button To Disable All Chat Results Temporarily...."
+
+
+ elif action == "gcmds" and channel_name == "f_delete":
+ text=f"Are You Sure That You Want To Clear All Filters Of {chat_name}....???\n"
+ text+=f"\nThis Will Erase All Files Of {chat_name} 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"set\((.+)\)"), group=2)
+async def cb_set(bot, update: CallbackQuery):
+ """
+ A Callback Funtion Support For config()
+ """
+ global CHAT_DETAILS
+ query_data = update.data
+ chat_id = update.message.chat.id
+ user_id = update.from_user.id
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
+ 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"
+ )
+
diff --git a/bot/plugins/__init__.py b/bot/plugins/__init__.py
new file mode 100644
index 0000000..1778cb8
--- /dev/null
+++ b/bot/plugins/__init__.py
@@ -0,0 +1,5 @@
+from .. import CHAT_DETAILS
+from .auto_filter import ACTIVE_CHATS, INVITE_LINK, FIND, recacher, gen_invite_links
+from .settings import remove_emoji
+from .utils import time_formatter, admin_list
+from ..database import Database
diff --git a/bot/plugins/callback.py b/bot/plugins/callback.py
deleted file mode 100644
index 2e7253e..0000000
--- a/bot/plugins/callback.py
+++ /dev/null
@@ -1,1712 +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/AlbertEinsteinTG/Adv-Auto-Filter-Bot')
- ],[
- 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
index 2ea646b..17c3237 100644
--- a/bot/plugins/channel.py
+++ b/bot/plugins/channel.py
@@ -5,10 +5,11 @@
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 bot import CHAT_DETAILS
+from bot.bot import Bot
+from bot.database import Database
+from bot.plugins.auto_filter import recacher
+from bot.plugins.utils import admin_list
db = Database()
@@ -20,17 +21,15 @@ async def connect(bot: Bot, update):
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
+ global CHAT_DETAILS
- 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
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
- if not user_id in VERIFY.get(str(chat_id)):
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
+
+ if user_id not in chat_admins:
return
try:
@@ -197,17 +196,15 @@ async def disconnect(bot: Bot, update):
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
+ global CHAT_DETAILS
- 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
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
- if not user_id in VERIFY.get(str(chat_id)):
+ if user_id not in chat_admins:
return
try:
@@ -261,17 +258,15 @@ async def delall(bot: Bot, update):
"""
chat_id=update.chat.id
user_id = update.from_user.id if update.from_user else None
- global VERIFY
+ global CHAT_DETAILS
- 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
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
+
+ if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
- if not user_id in VERIFY.get(str(chat_id)):
+ if user_id not in chat_admins:
return
await db.delete_all(chat_id)
diff --git a/bot/plugins/settings.py b/bot/plugins/settings.py
index a8fd1c5..f816369 100644
--- a/bot/plugins/settings.py
+++ b/bot/plugins/settings.py
@@ -6,24 +6,25 @@
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-from bot import VERIFY # pylint: disable=import-error
+from bot import CHAT_DETAILS
+from bot.plugins.utils import admin_list
+
+
@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
+ global CHAT_DETAILS
+
+ chat_dict = CHAT_DETAILS.get(str(chat_id))
+ chat_admins = chat_dict.get("admins") if chat_dict != None else None
- 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 ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ chat_admins = await admin_list(chat_id, bot, update)
- if not user_id in VERIFY.get(str(chat_id)): # Checks if user is admin of the chat
+ if user_id not in chat_admins:
return
bot_info = await bot.get_me()
diff --git a/bot/plugins/utils.py b/bot/plugins/utils.py
new file mode 100644
index 0000000..59d615f
--- /dev/null
+++ b/bot/plugins/utils.py
@@ -0,0 +1,30 @@
+import time
+from bot import CHAT_DETAILS
+
+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
+
+
+async def admin_list(chat_id, bot, update):
+ """
+ Creates A List Of Admin User ID's
+ """
+ global CHAT_DETAILS
+ admins_id_list = []
+ async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"):
+ admin_id = x.user.id
+ admins_id_list.append(admin_id)
+
+ admins_id_list.append(None)
+ CHAT_DETAILS[str(chat_id)] = dict(admins = admins_id_list)
+ return admins_id_list
\ No newline at end of file
From fe7d4d79e8ab8997663f5f9e00eef9d47d6c3161 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sat, 8 May 2021 15:01:23 +0530
Subject: [PATCH 17/34] Added File_size
---
bot/database/database.py | 2 +-
.../Callbacks/About Btn/abt_main_cb.py | 1 +
.../Callbacks/Channels Btn/chnl_main_cb.py | 228 ++++++++--------
.../Callbacks/Channels Btn/chnl_sub_cb.py | 256 +++++++++---------
bot/plugins/Callbacks/af_main_cb.py | 7 +-
bot/plugins/auto_filter.py | 7 +-
bot/plugins/channel.py | 11 +-
7 files changed, 264 insertions(+), 248 deletions(-)
diff --git a/bot/database/database.py b/bot/database/database.py
index 9e55858..9d9be2f 100644
--- a/bot/database/database.py
+++ b/bot/database/database.py
@@ -447,7 +447,7 @@ async def get_filters(self, group_id: int, keyword: str):
filters = []
pipeline= {
- '$text':{'$search': keyword}
+ 'group_id': int(group_id), '$text':{'$search': keyword}
}
diff --git a/bot/plugins/Callbacks/About Btn/abt_main_cb.py b/bot/plugins/Callbacks/About Btn/abt_main_cb.py
index 45e4612..799d4c7 100644
--- a/bot/plugins/Callbacks/About Btn/abt_main_cb.py
+++ b/bot/plugins/Callbacks/About Btn/abt_main_cb.py
@@ -18,6 +18,7 @@ async def cb_about(bot, update: CallbackQuery):
"""
global CHAT_DETAILS
chat_id = update.message.chat.id
+ user_id = update.from_user.id
chat_dict = CHAT_DETAILS.get(str(chat_id))
chat_admins = chat_dict.get("admins") if chat_dict != None else None
diff --git a/bot/plugins/Callbacks/Channels Btn/chnl_main_cb.py b/bot/plugins/Callbacks/Channels Btn/chnl_main_cb.py
index b579d30..02d0adb 100644
--- a/bot/plugins/Callbacks/Channels Btn/chnl_main_cb.py
+++ b/bot/plugins/Callbacks/Channels Btn/chnl_main_cb.py
@@ -68,13 +68,13 @@ async def cb_channel_list(bot, update: CallbackQuery):
buttons = []
-
- buttons.append([
- InlineKeyboardButton
- (
- "Global Connections", callback_data=f"global({chat_id})"
- )
- ])
+ # For Future Update (Little Help Neededπͺ)
+ # buttons.append([
+ # InlineKeyboardButton
+ # (
+ # "Global Connections", callback_data=f"global({chat_id})"
+ # )
+ # ])
buttons.append(
@@ -240,120 +240,120 @@ async def cb_info(bot, update: CallbackQuery):
)
+#
+ # @Client.on_callback_query(filters.regex(r"^global\((.+)\)"), group=2)
+ # async def cb_global_chats(bot, update:CallbackQuery):
+ # """
+ # A Callback Funtion For Displaying Details Of All The Connected Chat And Provide
+ # Ability To Connect, Disconnect, Delete, Delete Filters of, All Connected Chat In
+ # 1 Go
+ # """
+ # global CHAT_DETAILS
+
+ # chat_id = update.message.chat.id
+ # chat_name = update.message.chat.title
+ # user_id = update.from_user.id
+
+ # chat_dict = CHAT_DETAILS.get(str(chat_id))
+ # chat_admins = chat_dict.get("admins") if chat_dict != None else None
-@Client.on_callback_query(filters.regex(r"^global\((.+)\)"), group=2)
-async def cb_global_chats(bot, update:CallbackQuery):
- """
- A Callback Funtion For Displaying Details Of All The Connected Chat And Provide
- Ability To Connect, Disconnect, Delete, Delete Filters of, All Connected Chat In
- 1 Go
- """
- global CHAT_DETAILS
-
- chat_id = update.message.chat.id
- chat_name = update.message.chat.title
- user_id = update.from_user.id
-
- chat_dict = CHAT_DETAILS.get(str(chat_id))
- chat_admins = chat_dict.get("admins") if chat_dict != None else None
+ # if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ # chat_admins = await admin_list(chat_id, bot, update)
- if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
- chat_admins = await admin_list(chat_id, bot, update)
+ # if user_id not in chat_admins:
+ # return
+
+ # f_count = await db.tf_count(chat_id)
+ # connected_chats = await db.find_chat(chat_id)
+ # active_chats = await db.find_active(chat_id)
+
+ # db_cids = None
+ # db_cnames = None
+ # total_chats = 0
+
+ # if connected_chats: # Checks for active chats connected to a chat
+ # dicts = connected_chats["chat_ids"]
+ # adicts = active_chats["chats"]
+ # adb_cids = [ int(x["chat_id"]) for x in adicts ]
+ # db_cids = []
+ # db_cnames = []
+ # for x in dicts:
+ # cid = x["chat_id"]
+ # cname = x["chat_name"]
+ # print(cname)
+
+ # db_cids.append(cid)
+ # if cid in adb_cids:
+ # cname + " (A)"
+ # db_cnames.append(cname)
+
+ # print(db_cnames)
+
+ # total_chats = len(db_cids)
- if user_id not in chat_admins:
- return
-
- f_count = await db.tf_count(chat_id)
- connected_chats = await db.find_chat(chat_id)
- active_chats = await db.find_active(chat_id)
-
- db_cids = None
- db_cnames = None
- total_chats = 0
-
- if connected_chats: # Checks for active chats connected to a chat
- dicts = connected_chats["chat_ids"]
- adicts = active_chats["chats"]
- adb_cids = [ int(x["chat_id"]) for x in adicts ]
- db_cids = []
- db_cnames = []
- for x in dicts:
- cid = x["chat_id"]
- cname = x["chat_name"]
- print(cname)
+ # text=f"Info About All Connected Of {chat_name}\n"
+ # text+=f"\nTotal Connected Chats: {total_chats}\n"
+
+ # text+=f"\nChannel Names:\n"
+
+ # for y in db_cnames:
+ # text+=f"\n {y}"
- db_cids.append(cid)
- if cid in adb_cids:
- cname + " (A)"
- db_cnames.append(cname)
-
- print(db_cnames)
-
- total_chats = len(db_cids)
-
- text=f"Info About All Connected Of {chat_name}\n"
- text+=f"\nTotal Connected Chats: {total_chats}\n"
-
- text+=f"\nChannel Names:\n"
-
- for y in db_cnames:
- text+=f"\n {y}"
+ # text+=f"\nChannel ID's:\n"
- text+=f"\nChannel ID's:\n"
-
- for z in db_cids:
- text+=f"\n {z}"
-
- text+=f"\nTotal Files In DB: {f_count}\n"
-
-
-
- buttons = [
- [
- InlineKeyboardButton
- (
- "π Connect All π ", callback_data=f"warn({chat_id}|conn|gcmds)"
- ),
-
- InlineKeyboardButton
- (
- "π¨ Disconnect All π¨", callback_data=f"warn({chat_id}|disconn|gcmds)"
- )
- ]
- ]
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete All Chats β", callback_data=f"warn({chat_id}|c_delete|gcmds)"
- )
- ]
- )
+ # for z in db_cids:
+ # text+=f"\n {z}"
+
+ # text+=f"\nTotal Files In DB: {f_count}\n"
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete All Filters β ", callback_data=f"warn({chat_id}|f_delete|gcmds)"
- )
- ]
- )
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "π Back", callback_data=f"channel_list({chat_id})"
- )
- ]
- )
- reply_markup = InlineKeyboardMarkup(buttons)
+ # buttons = [
+ # [
+ # InlineKeyboardButton
+ # (
+ # "π Connect All π ", callback_data=f"warn({chat_id}|conn|gcmds)"
+ # ),
+
+ # InlineKeyboardButton
+ # (
+ # "π¨ Disconnect All π¨", callback_data=f"warn({chat_id}|disconn|gcmds)"
+ # )
+ # ]
+ # ]
+
+
+ # buttons.append(
+ # [
+ # InlineKeyboardButton
+ # (
+ # "Delete All Chats β", callback_data=f"warn({chat_id}|c_delete|gcmds)"
+ # )
+ # ]
+ # )
+
+
+ # buttons.append(
+ # [
+ # InlineKeyboardButton
+ # (
+ # "Delete All Filters β ", callback_data=f"warn({chat_id}|f_delete|gcmds)"
+ # )
+ # ]
+ # )
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
+ # 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"
+ # )
diff --git a/bot/plugins/Callbacks/Channels Btn/chnl_sub_cb.py b/bot/plugins/Callbacks/Channels Btn/chnl_sub_cb.py
index 9919995..dfb8a7f 100644
--- a/bot/plugins/Callbacks/Channels Btn/chnl_sub_cb.py
+++ b/bot/plugins/Callbacks/Channels Btn/chnl_sub_cb.py
@@ -289,140 +289,140 @@ async def cb_filters_delete(bot, update: CallbackQuery):
)
-
-@Client.on_callback_query(filters.regex(r"^gcmds\((.)\)"), group=2)
-async def cb_gcmds(bot, update: CallbackQuery):
- """
- A Callback Funtion to Connect, Disconnect, Delete, Delete Filters of,
- All Connected Chat in 1 GO
- """
- global CHAT_DETAILS
- query_data = update.data
- chat_id = update.message.chat.id
- chat_name = update.message.chat.title
- user_id = update.from_user.id
-
- print(user_id)
+#
+ # @Client.on_callback_query(filters.regex(r"^gcmds\((.)\)"), group=2)
+ # async def cb_gcmds(bot, update: CallbackQuery):
+ # """
+ # A Callback Funtion to Connect, Disconnect, Delete, Delete Filters of,
+ # All Connected Chat in 1 GO
+ # """
+ # global CHAT_DETAILS
+ # query_data = update.data
+ # chat_id = update.message.chat.id
+ # chat_name = update.message.chat.title
+ # user_id = update.from_user.id
- chat_dict = CHAT_DETAILS.get(str(chat_id))
- chat_admins = chat_dict.get("admins") if chat_dict != None else None
-
- if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
- chat_admins = await admin_list(chat_id, bot, update)
-
- if user_id not in chat_admins:
- print(user_id)
- print(chat_admins)
- return
-
- chat_id, action = re.findall(r"gcmds\((.)\)", query_data)[0].split("|", 1)
-
- if action == "conn":
- await db.add_all_chat_as_active(chat_id)
- await update.answer("Sucessfully Made All Chat Connection Active.....")
-
- elif action == "disconn":
- await db.delall_active(chat_id)
- await update.answer("Sucessfully Disabled All Active Chats.....")
-
- elif action == "c_delete":
- await db.delete_all(chat_id)
- await update.answer("Sucessfully Deleted All Data About This Group From DB")
-
- elif action == "f_delete":
- await db.delall_filters(chat_id)
- await update.answer("Sucessfully Deleted All Files Connected With This Chat...")
-
-
-
- f_count = await db.tf_count(chat_id)
- connected_chats = await db.find_chat(chat_id)
- active_chats = await db.find_active(chat_id)
-
- db_cids = None
- db_cnames = None
- total_chats = 0
-
- if connected_chats: # Checks for active chats connected to a chat
- dicts = connected_chats["chat_ids"]
- adicts = active_chats["chats"]
- adb_cids = [ int(x["chat_id"]) for x in adicts ]
- db_cids = []
- db_cnames = []
- for x in dicts:
- cid = x["chat_id"]
- cname = x["chat_name"]
+ # print(user_id)
- db_cids.append(cid)
- if cid in adb_cids:
- cname + " (A)"
- db_cnames.append(db_cnames)
-
- total_chats = len(db_cids)
-
- text=f"Info About All Connected Of {chat_name}\n"
- text+=f"\nTotal Connected Chats: {total_chats}"
-
- text+=f"\nChannel Names:\n"
-
- for ch in db_cnames:
- text+=f" {ch}\n"
-
- text+=f"\nChannel ID's:\n"
-
- for ch in db_cnames:
- text+=f"\n {ch}\n"
-
- text+=f"\nTotal Files In DB: {f_count}\n"
-
+ # chat_dict = CHAT_DETAILS.get(str(chat_id))
+ # chat_admins = chat_dict.get("admins") if chat_dict != None else None
+ # if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ # chat_admins = await admin_list(chat_id, bot, update)
- buttons = [
- [
- InlineKeyboardButton
- (
- "π Connect All π ", callback_data=f"warn({chat_id}|conn|gcmds)"
- ),
-
- InlineKeyboardButton
- (
- "π¨ Disconnect All π¨", callback_data=f"warn({chat_id}|disconn|gcmds)"
- )
- ]
- ]
-
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete All Chats β", callback_data=f"warn({chat_id}|c_delete|gcmds)"
- )
- ]
- )
+ # if user_id not in chat_admins:
+ # print(user_id)
+ # print(chat_admins)
+ # return
+
+ # chat_id, action = re.findall(r"gcmds\((.)\)", query_data)[0].split("|", 1)
+
+ # if action == "conn":
+ # await db.add_all_chat_as_active(chat_id)
+ # await update.answer("Sucessfully Made All Chat Connection Active.....")
+
+ # elif action == "disconn":
+ # await db.delall_active(chat_id)
+ # await update.answer("Sucessfully Disabled All Active Chats.....")
+ # elif action == "c_delete":
+ # await db.delete_all(chat_id)
+ # await update.answer("Sucessfully Deleted All Data About This Group From DB")
+
+ # elif action == "f_delete":
+ # await db.delall_filters(chat_id)
+ # await update.answer("Sucessfully Deleted All Files Connected With This Chat...")
+
- buttons.append(
- [
- InlineKeyboardButton
- (
- "Delete All Filters β ", callback_data=f"warn({chat_id}|f_delete|gcmds)"
- )
- ]
- )
-
- buttons.append(
- [
- InlineKeyboardButton
- (
- "π Back", callback_data=f"channel_list({chat_id})"
- )
- ]
- )
+
+ # f_count = await db.tf_count(chat_id)
+ # connected_chats = await db.find_chat(chat_id)
+ # active_chats = await db.find_active(chat_id)
+
+ # db_cids = None
+ # db_cnames = None
+ # total_chats = 0
+
+ # if connected_chats: # Checks for active chats connected to a chat
+ # dicts = connected_chats["chat_ids"]
+ # adicts = active_chats["chats"]
+ # adb_cids = [ int(x["chat_id"]) for x in adicts ]
+ # db_cids = []
+ # db_cnames = []
+ # for x in dicts:
+ # cid = x["chat_id"]
+ # cname = x["chat_name"]
+
+ # db_cids.append(cid)
+ # if cid in adb_cids:
+ # cname + " (A)"
+ # db_cnames.append(db_cnames)
+
+ # total_chats = len(db_cids)
- reply_markup = InlineKeyboardMarkup(buttons)
+ # text=f"Info About All Connected Of {chat_name}\n"
+ # text+=f"\nTotal Connected Chats: {total_chats}"
- await update.message.edit_text(
- text, reply_markup=reply_markup, parse_mode="html"
- )
+ # text+=f"\nChannel Names:\n"
+
+ # for ch in db_cnames:
+ # text+=f" {ch}\n"
+
+ # text+=f"\nChannel ID's:\n"
+
+ # for ch in db_cnames:
+ # text+=f"\n {ch}\n"
+
+ # text+=f"\nTotal Files In DB: {f_count}\n"
+
+
+
+ # buttons = [
+ # [
+ # InlineKeyboardButton
+ # (
+ # "π Connect All π ", callback_data=f"warn({chat_id}|conn|gcmds)"
+ # ),
+
+ # InlineKeyboardButton
+ # (
+ # "π¨ Disconnect All π¨", callback_data=f"warn({chat_id}|disconn|gcmds)"
+ # )
+ # ]
+ # ]
+
+
+ # buttons.append(
+ # [
+ # InlineKeyboardButton
+ # (
+ # "Delete All Chats β", callback_data=f"warn({chat_id}|c_delete|gcmds)"
+ # )
+ # ]
+ # )
+
+
+ # buttons.append(
+ # [
+ # InlineKeyboardButton
+ # (
+ # "Delete All Filters β ", callback_data=f"warn({chat_id}|f_delete|gcmds)"
+ # )
+ # ]
+ # )
+
+ # 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"
+ # )
diff --git a/bot/plugins/Callbacks/af_main_cb.py b/bot/plugins/Callbacks/af_main_cb.py
index 2c25be3..1e876d7 100644
--- a/bot/plugins/Callbacks/af_main_cb.py
+++ b/bot/plugins/Callbacks/af_main_cb.py
@@ -43,10 +43,12 @@ async def cb_navg(bot, update: CallbackQuery):
chat_dict = CHAT_DETAILS.get(str(chat_id))
chat_admins = chat_dict.get("admins") if chat_dict != None else None
- if ( chat_dict or chat_admins ) == None: # Make Admin's ID List
+ # Make Admin's ID List
+ if ( chat_dict or chat_admins ) == None:
chat_admins = await admin_list(chat_id, bot, update)
- if not ((user_id == ruser_id) or (user_id in chat_admins)): # Checks if user is same as requested user or is admin
+ # Checks if user is same as requested user or is admin
+ if not ((user_id == ruser_id) or (user_id in chat_admins)):
await update.answer("Nice Try ;)",show_alert=True)
return
@@ -60,7 +62,6 @@ async def cb_navg(bot, update: CallbackQuery):
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")
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index c524842..a86add5 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -64,6 +64,11 @@ async def auto_filter(bot, update):
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", ""))
+ file_size /= 1024*1024 # from B to MiB
+
+ # add emoji here if you want
+ button_text = f"[{file_size}] {file_name}" if file_size else file_name
if file_type == "video":
if allow_video:
@@ -102,7 +107,7 @@ async def auto_filter(bot, update):
results.append(
[
- InlineKeyboardButton(file_name, url=file_link)
+ InlineKeyboardButton(button_text, url=file_link)
]
)
diff --git a/bot/plugins/channel.py b/bot/plugins/channel.py
index 17c3237..8356500 100644
--- a/bot/plugins/channel.py
+++ b/bot/plugins/channel.py
@@ -3,6 +3,7 @@
import asyncio
from pyrogram import Client, filters
+from pyrogram.types import Message
from pyrogram.errors import UserAlreadyParticipant, FloodWait
from bot import CHAT_DETAILS
@@ -14,7 +15,7 @@
db = Database()
@Client.on_message(filters.command(["add"]) & filters.group, group=1)
-async def connect(bot: Bot, update):
+async def connect(bot: Bot, update: Message):
"""
A Funtion To Handle Incoming /add Command TO COnnect A Chat With Group
"""
@@ -111,6 +112,7 @@ async def connect(bot: Bot, update):
continue
file_id = file_id.video.file_id
file_name = msgs.video.file_name[0:-4]
+ file_size = msgs.video.file_size
file_caption = msgs.caption if msgs.caption else ""
file_type = "video"
@@ -125,6 +127,7 @@ async def connect(bot: Bot, update):
continue
file_id = file_id.audio.file_id
file_name = msgs.audio.file_name[0:-4]
+ file_size = msgs.audio.file_size
file_caption = msgs.caption if msgs.caption else ""
file_type = "audio"
@@ -139,6 +142,7 @@ async def connect(bot: Bot, update):
continue
file_id = file_id.document.file_id
file_name = msgs.document.file_name[0:-4]
+ file_size = msgs.document.file_size
file_caption = msgs.caption if msgs.caption else ""
file_type = "document"
@@ -162,6 +166,7 @@ async def connect(bot: Bot, update):
file_id=file_id, # Done
unique_id=unique_id,
file_name=file_name,
+ file_size=file_size,
file_caption=file_caption,
file_type=file_type,
file_link=file_link,
@@ -290,18 +295,21 @@ async def new_files(bot: Bot, update):
file_type = "video"
file_id = update.video.file_id
file_name = update.video.file_name[0:-4]
+ file_size = update.video.file_size
file_caption = update.caption if update.caption else ""
elif update.audio:
file_type = "audio"
file_id = update.audio.file_id
file_name = update.audio.file_name[0:-4]
+ file_size = update.audio.file_size
file_caption = update.caption if update.caption else ""
elif update.document:
file_type = "document"
file_id = update.document.file_id
file_name = update.document.file_name[0:-4]
+ file_size = update.document.file_size
file_caption = update.caption if update.caption else ""
for i in ["_", "|", "-", "."]: # Work Around
@@ -332,6 +340,7 @@ async def new_files(bot: Bot, update):
file_id=file_id, # File Id For Future Updates Maybe...
unique_id=unique_id,
file_name=file_name,
+ file_size=file_size,
file_caption=file_caption,
file_type=file_type,
file_link=file_link,
From 51b1a72e8f37bf0c61de43667cb85eda809eec4f Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sat, 8 May 2021 17:25:54 +0530
Subject: [PATCH 18/34] ..............
---
bot/plugins/auto_filter.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index a86add5..0f387b5 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -65,9 +65,9 @@ async def auto_filter(bot, update):
file_type = filter.get("file_type")
file_link = filter.get("file_link")
file_size = int(filter.get("file_size", ""))
- file_size /= 1024*1024 # from B to MiB
+ file_size = round(file_size/1024*1024) # from B to MiB
- # add emoji here if you want
+ # add emoji down below inside " " if you want..
button_text = f"[{file_size}] {file_name}" if file_size else file_name
if file_type == "video":
From 393b3410dc8f0e0958d7b1842055010621b92c05 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sat, 8 May 2021 17:28:52 +0530
Subject: [PATCH 19/34] ....
---
bot/plugins/auto_filter.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index 0f387b5..854d4e6 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -68,7 +68,7 @@ async def auto_filter(bot, update):
file_size = round(file_size/1024*1024) # from B to MiB
# add emoji down below inside " " if you want..
- button_text = f"[{file_size}] {file_name}" if file_size else file_name
+ button_text = f"[{file_size} MiB] {file_name}" if file_size else file_name
if file_type == "video":
if allow_video:
From 3d2e8db28eedcefbf2c5f363083eedd4af628b68 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sat, 8 May 2021 22:53:36 +0530
Subject: [PATCH 20/34] Fixx
---
bot/plugins/Callbacks/af_main_cb.py | 63 +++++++++++++++++++++++++++++
bot/plugins/auto_filter.py | 4 +-
bot/plugins/channel.py | 2 +-
3 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/bot/plugins/Callbacks/af_main_cb.py b/bot/plugins/Callbacks/af_main_cb.py
index 1e876d7..9f30e0f 100644
--- a/bot/plugins/Callbacks/af_main_cb.py
+++ b/bot/plugins/Callbacks/af_main_cb.py
@@ -418,3 +418,66 @@ async def cb_set(bot, update: CallbackQuery):
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/AlbertEinsteinTG/Adv-Auto-Filter-Bot')
+ ],[
+ 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()
+
\ No newline at end of file
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index 854d4e6..130743c 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -66,9 +66,9 @@ async def auto_filter(bot, update):
file_link = filter.get("file_link")
file_size = int(filter.get("file_size", ""))
file_size = round(file_size/1024*1024) # from B to MiB
-
+ file_size = str(file_size) + " MiB" if file_size < 1024 else str(round(file_size/1024)) + " GiB"
# add emoji down below inside " " if you want..
- button_text = f"[{file_size} MiB] {file_name}" if file_size else file_name
+ button_text = f"[{file_size}] {file_name}" if file_size else file_name
if file_type == "video":
if allow_video:
diff --git a/bot/plugins/channel.py b/bot/plugins/channel.py
index 8356500..5b93441 100644
--- a/bot/plugins/channel.py
+++ b/bot/plugins/channel.py
@@ -87,7 +87,7 @@ async def connect(bot: Bot, update: Message):
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....")
+ wait_msg = await update.reply_text("Please Wait Till I Add All Your Files From Channel To Db\n\nThis May Take 2 or 3 Hrs 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"]
From 25537a2f164b4b3bb9489bc917403a7021916fe1 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 9 May 2021 09:49:57 +0530
Subject: [PATCH 21/34] Update auto_filter.py
---
bot/plugins/auto_filter.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index 130743c..4721914 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -65,7 +65,7 @@ async def auto_filter(bot, update):
file_type = filter.get("file_type")
file_link = filter.get("file_link")
file_size = int(filter.get("file_size", ""))
- file_size = round(file_size/1024*1024) # from B to MiB
+ file_size = round(file_size/(1024*1024)) # from B to MiB
file_size = str(file_size) + " MiB" if file_size < 1024 else str(round(file_size/1024)) + " GiB"
# add emoji down below inside " " if you want..
button_text = f"[{file_size}] {file_name}" if file_size else file_name
From af7bf1419db86fd2fef5498793b999e28e35352c Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 9 May 2021 14:38:52 +0530
Subject: [PATCH 22/34] Update auto_filter.py
---
bot/plugins/auto_filter.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index 4721914..dbb77e8 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -55,7 +55,7 @@ async def auto_filter(bot, update):
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
+ # 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)
From 7876b57de71a51b5743f8f9f9407063c733abc74 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 9 May 2021 14:40:28 +0530
Subject: [PATCH 23/34] Update af_main_cb.py
---
bot/plugins/Callbacks/af_main_cb.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bot/plugins/Callbacks/af_main_cb.py b/bot/plugins/Callbacks/af_main_cb.py
index 9f30e0f..3aa6be0 100644
--- a/bot/plugins/Callbacks/af_main_cb.py
+++ b/bot/plugins/Callbacks/af_main_cb.py
@@ -63,6 +63,8 @@ async def cb_navg(bot, update: CallbackQuery):
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) # turn show_invite to False if pm_file_chat is True
+
results = FIND.get(query).get("results")
leng = FIND.get(query).get("total_len")
max_pages = FIND.get(query).get("max_pages")
@@ -480,4 +482,4 @@ async def callback_data(bot, update: CallbackQuery):
elif query_data == "close":
await update.message.delete()
-
\ No newline at end of file
+
From bbdfe061522a1e9704bc8d18fa14e8828c21a068 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 9 May 2021 15:29:59 +0530
Subject: [PATCH 24/34] ......
---
bot/plugins/auto_filter.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index dbb77e8..3fcfbc1 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -64,11 +64,16 @@ async def auto_filter(bot, update):
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", ""))
- file_size = round(file_size/(1024*1024)) # from B to MiB
- file_size = str(file_size) + " MiB" if file_size < 1024 else str(round(file_size/1024)) + " GiB"
+ file_size = int(filter.get("file_size", "0"))
+
+ # from B to MiB
+ file_size = round(file_size/(1024*1024))
+
+ file_size = f"[{str(file_size)}] MiB " if file_size < 1024 else f"[{str(round(file_size/1024))}] GiB "
+ file_size = "" if file_size == ("[0] MiB" or "[0] GiB") else file_size
+
# add emoji down below inside " " if you want..
- button_text = f"[{file_size}] {file_name}" if file_size else file_name
+ button_text = f"{file_size}{file_name}" if file_size else file_name
if file_type == "video":
if allow_video:
From 8be93a60ccbdb84c298f9d95224542a39dfda0ea Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 9 May 2021 15:45:38 +0530
Subject: [PATCH 25/34] Fix
---
bot/plugins/auto_filter.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index 3fcfbc1..affefe4 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -70,7 +70,7 @@ async def auto_filter(bot, update):
file_size = round(file_size/(1024*1024))
file_size = f"[{str(file_size)}] MiB " if file_size < 1024 else f"[{str(round(file_size/1024))}] GiB "
- file_size = "" if file_size == ("[0] MiB" or "[0] GiB") else file_size
+ file_size = "" if file_size == ("[0] MiB " or "[0] GiB ") else file_size
# add emoji down below inside " " if you want..
button_text = f"{file_size}{file_name}" if file_size else file_name
From 86da00b2aeb685faca54eaad940184b3c05a43f7 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 9 May 2021 15:48:25 +0530
Subject: [PATCH 26/34] Fix
---
bot/plugins/auto_filter.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index affefe4..44c05c5 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -69,8 +69,8 @@ async def auto_filter(bot, update):
# from B to MiB
file_size = round(file_size/(1024*1024))
- file_size = f"[{str(file_size)}] MiB " if file_size < 1024 else f"[{str(round(file_size/1024))}] GiB "
- file_size = "" if file_size == ("[0] MiB " or "[0] GiB ") else file_size
+ file_size = f"[{str(file_size)} MiB] " if file_size < 1024 else f"[{str(round(file_size/1024))} GiB] "
+ file_size = "" if file_size == ("[0 MiB] " or "[0 GiB] ") else file_size
# add emoji down below inside " " if you want..
button_text = f"{file_size}{file_name}" if file_size else file_name
From 2a032029bd7adec4ebf8c099adf6cc79c944f4f2 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Sun, 9 May 2021 20:19:58 +0530
Subject: [PATCH 27/34] Better
---
bot/plugins/auto_filter.py | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/bot/plugins/auto_filter.py b/bot/plugins/auto_filter.py
index 44c05c5..4f1d25c 100644
--- a/bot/plugins/auto_filter.py
+++ b/bot/plugins/auto_filter.py
@@ -67,13 +67,22 @@ async def auto_filter(bot, update):
file_size = int(filter.get("file_size", "0"))
# from B to MiB
- file_size = round(file_size/(1024*1024))
- file_size = f"[{str(file_size)} MiB] " if file_size < 1024 else f"[{str(round(file_size/1024))} GiB] "
- file_size = "" if file_size == ("[0 MiB] " or "[0 GiB] ") else file_size
+ 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}"
- # add emoji down below inside " " if you want..
- button_text = f"{file_size}{file_name}" if file_size else file_name
if file_type == "video":
if allow_video:
@@ -184,8 +193,9 @@ async def auto_filter(bot, update):
for x in ibuttons:
result[0].insert(0, x) #Insert invite link buttons at first of page
-
- ibuttons = None # Free Up Memory...
+
+ # Free Up Memory...
+ ibuttons = None
achatId = None
From a2b920ba12b14128442f1ce033ed919b9f7bcaac Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 28 Jul 2021 22:17:28 +0530
Subject: [PATCH 28/34] Merging Upstream
---
bot/plugins/channel.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/plugins/channel.py b/bot/plugins/channel.py
index 5b93441..eeb246a 100644
--- a/bot/plugins/channel.py
+++ b/bot/plugins/channel.py
@@ -280,7 +280,7 @@ 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), group=0)
+@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..
From 83cdefd95d805f6988d3455a321c4e02245fd40c Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 28 Jul 2021 22:20:59 +0530
Subject: [PATCH 29/34] Merging Upstream
---
bot/plugins/commands.py | 60 +++++++----------------------------------
1 file changed, 9 insertions(+), 51 deletions(-)
diff --git a/bot/plugins/commands.py b/bot/plugins/commands.py
index 7af5d5d..5fadbc9 100644
--- a/bot/plugins/commands.py
+++ b/bot/plugins/commands.py
@@ -4,7 +4,7 @@
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()
@@ -24,32 +24,10 @@ async def start(bot, update):
return
caption = file_caption if file_caption != ("" or None) else ("" + 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,34 +41,14 @@ 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 = [[
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 426e1891d865381630cf55a32982ce16abc452e8 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 28 Jul 2021 22:22:54 +0530
Subject: [PATCH 30/34] Merging Upstream
---
bot/plugins/Callbacks/About Btn/abt_main_cb.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/plugins/Callbacks/About Btn/abt_main_cb.py b/bot/plugins/Callbacks/About Btn/abt_main_cb.py
index 799d4c7..55f6f6f 100644
--- a/bot/plugins/Callbacks/About Btn/abt_main_cb.py
+++ b/bot/plugins/Callbacks/About Btn/abt_main_cb.py
@@ -33,7 +33,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 = [
[
@@ -59,4 +59,4 @@ async def cb_about(bot, update: CallbackQuery):
await update.message.edit_text(
text, reply_markup=reply_markup, parse_mode="html"
- )
\ No newline at end of file
+ )
From b09234613f8d96fc09beaa32fe427d5bd01e0c5c Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 28 Jul 2021 22:25:21 +0530
Subject: [PATCH 31/34] Merging Upstream
---
bot/database/database.py | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/bot/database/database.py b/bot/database/database.py
index 9d9be2f..356997d 100644
--- a/bot/database/database.py
+++ b/bot/database/database.py
@@ -1,21 +1,14 @@
+import os
import motor.motor_asyncio # pylint: disable=import-error
from bot import DB_URI
-class Singleton(type):
- __instances__ = {}
+DB_NAME = os.environ.get("DB_NAME", "Adv_Auto_Filter")
- def __call__(cls, *args, **kwargs):
- if cls not in cls.__instances__:
- cls.__instances__[cls] = super(Singleton, cls).__call__(*args, **kwargs)
-
- return cls.__instances__[cls]
-
-
-class Database(metaclass=Singleton):
+class Database:
def __init__(self):
self._client = motor.motor_asyncio.AsyncIOMotorClient(DB_URI)
- self.db = self._client["Adv_Auto_Filter"]
+ self.db = self._client[DB_NAME]
self.col = self.db["Main"]
self.acol = self.db["Active_Chats"]
self.fcol = self.db["Filter_Collection"]
@@ -430,7 +423,6 @@ 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)
@@ -485,7 +477,7 @@ async def get_file(self, unique_id: str):
file_id = file.get("file_id")
file_name = file.get("file_name")
file_type = file.get("file_type")
- file_caption = file.get("caption")
+ file_caption = file.get("file_caption")
return file_id, file_name, file_caption, file_type
@@ -503,4 +495,3 @@ async def tf_count(self, group_id: int):
"""
return await self.fcol.count_documents({"group_id": group_id})
-
From fd2f38ff87760b345612a74d509758a3f0f8b72a Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 28 Jul 2021 22:29:10 +0530
Subject: [PATCH 32/34] Merging Upstream
---
bot/plugins/Callbacks/af_main_cb.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/plugins/Callbacks/af_main_cb.py b/bot/plugins/Callbacks/af_main_cb.py
index 3aa6be0..d2e274c 100644
--- a/bot/plugins/Callbacks/af_main_cb.py
+++ b/bot/plugins/Callbacks/af_main_cb.py
@@ -429,8 +429,8 @@ 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('My Dev π¨βπ¬', 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')
],[
From f30dcbc2a5d6d3c41e8fa018a2368389449b7c29 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 28 Jul 2021 22:30:35 +0530
Subject: [PATCH 33/34] Merging Upstream
---
bot/bot.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/bot.py b/bot/bot.py
index e90f1f0..1af901a 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -20,7 +20,7 @@ def __init__(self):
plugins={
"root": "bot/plugins"
},
- workers=4,
+ workers=400,
bot_token=BOT_TOKEN,
sleep_threshold=10
)
From 1048c61bb3f1f5a7715f0c2edea4073f43a2d738 Mon Sep 17 00:00:00 2001
From: Albert Einstein <73480087+AlbertEinsteinTG@users.noreply.github.com>
Date: Wed, 28 Jul 2021 22:32:19 +0530
Subject: [PATCH 34/34] Merging Upstream
---
Readme.md | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/Readme.md b/Readme.md
index f8392e3..dd41660 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,18 +1,18 @@
# Adv Auto Filter Bot V2
-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/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 @@ -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)