diff --git a/info.py b/info.py deleted file mode 100644 index 0dd4767c6..000000000 --- a/info.py +++ /dev/null @@ -1,92 +0,0 @@ -import re -from os import environ -from Script import script - -id_pattern = re.compile(r'^.\d+$') -def is_enabled(value, default): - if value.lower() in ["true", "yes", "1", "enable", "y"]: - return True - elif value.lower() in ["false", "no", "0", "disable", "n"]: - return False - else: - return default - -# Bot information -SESSION = environ.get('SESSION', 'Media_search') -API_ID = int(environ['API_ID']) -API_HASH = environ['API_HASH'] -BOT_TOKEN = environ['BOT_TOKEN'] - -# Bot settings -CACHE_TIME = int(environ.get('CACHE_TIME', 300)) -USE_CAPTION_FILTER = is_enabled((environ.get('USE_CAPTION_FILTER', 'True')), True) - -PICS = (environ.get('PICS', 'https://telegra.ph/file/6a0726f79acd8300e9a04.jpg https://telegra.ph/file/68289fefb76dbc43b766d.jpg https://telegra.ph/file/0caad29c0cf91c23fb1b6.jpg https://telegra.ph/file/8c34c755dd16581c1c6b5.jpg https://telegra.ph/file/365e35b554e5a3ea83857.jpg https://telegra.ph/file/07f185825c5b7bfd6fbfb.jpg https://telegra.ph/file/85f95494565a762edb3e7.jpg https://telegra.ph/file/708a1d6ce805fcc6a46d0.jpg https://telegra.ph/file/d799c1a964f211028cc97.jpg https://telegra.ph/file/b987425b80bca0cf45c7e.jpg https://telegra.ph/file/2a8b3779760289b76de24.jpg https://telegra.ph/file/47961be968719b3e24cf0.jpg https://telegra.ph/file/2e127b0f6b1810d733c09.jpg https://telegra.ph/file/281b18770a43a29120252.jpg https://telegra.ph/file/2086dd2aa8382e758a599.jpg https://telegra.ph/file/fcc849db4bf5c517f0f8d.jpg')).split() -NOR_IMG = environ.get("NOR_IMG", "https://telegra.ph/file/46443096bc6895c74a716.jpg") -MELCOW_VID = environ.get("MELCOW_VID", "https://telegra.ph/file/451f038b4e7c2ddd10dc0.mp4") -SPELL_IMG = environ.get("SPELL_IMG", "https://telegra.ph/file/5e2d4418525832bc9a1b9.jpg") - -# Admins, Channels & Users -ADMINS = [int(admin) if id_pattern.search(admin) else admin for admin in environ.get('ADMINS', '').split()] -CHANNELS = [int(ch) if id_pattern.search(ch) else ch for ch in environ.get('CHANNELS', '0').split()] -auth_users = [int(user) if id_pattern.search(user) else user for user in environ.get('AUTH_USERS', '').split()] -AUTH_USERS = (auth_users + ADMINS) if auth_users else [] -auth_channel = environ.get('AUTH_CHANNEL') -auth_grp = environ.get('AUTH_GROUP') -AUTH_CHANNEL = [int(auth_channel) for auth_channel in environ.get('AUTH_CHANNEL', '').split() if id_pattern.search(auth_channel)] -AUTH_GROUPS = [int(ch) for ch in auth_grp.split()] if auth_grp else None -support_chat_id = environ.get('SUPPORT_CHAT_ID') -reqst_channel = environ.get('REQST_CHANNEL_ID') -REQST_CHANNEL = int(reqst_channel) if reqst_channel and id_pattern.search(reqst_channel) else None -SUPPORT_CHAT_ID = int(support_chat_id) if support_chat_id and id_pattern.search(support_chat_id) else None -NO_RESULTS_MSG = is_enabled((environ.get("NO_RESULTS_MSG", 'False')), False) - -# MongoDB information -SECONDDB_URI = environ.get('SECONDDB_URI', None) -DATABASE_URI = environ.get('DATABASE_URI', "") -DATABASE_NAME = environ.get('DATABASE_NAME', "Rajappan") -COLLECTION_NAME = environ.get('COLLECTION_NAME', 'Telegram_files') - -# Others -IS_VERIFY = is_enabled((environ.get('IS_VERIFY', 'False')), False) -HOW_TO_VERIFY = environ.get('HOW_TO_VERIFY', "https://t.me/c/1845700490/3") -VERIFY2_URL = environ.get('VERIFY2_URL', "mdisklink.link") -VERIFY2_API = environ.get('VERIFY2_API', "4fa150d44b4bf6579c24b33bbbb786dbfb4fc673") -SHORTLINK_URL = environ.get('SHORTLINK_URL', 'clicksfly.com') -SHORTLINK_API = environ.get('SHORTLINK_API', 'c2150e28189cefefd05f8a9c5c5770cc462033e3') -IS_SHORTLINK = is_enabled((environ.get('IS_SHORTLINK', 'False')), False) -DELETE_CHANNELS = [int(dch) if id_pattern.search(dch) else dch for dch in environ.get('DELETE_CHANNELS', '0').split()] -MAX_B_TN = environ.get("MAX_B_TN", "5") -MAX_BTN = is_enabled((environ.get('MAX_BTN', "True")), True) -PORT = environ.get("PORT", "8080") -GRP_LNK = environ.get('GRP_LNK', 'https://t.me/+GOFte-Rz2tcxODg1') -CHNL_LNK = environ.get('CHNL_LNK', 'https://t.me/+mCMdCb_ymAowZmNl') -MSG_ALRT = environ.get('MSG_ALRT', 'Wʜᴀᴛ Aʀᴇ Yᴏᴜ Lᴏᴏᴋɪɴɢ Aᴛ ?') -LOG_CHANNEL = int(environ.get('LOG_CHANNEL', 0)) -SUPPORT_CHAT = environ.get('SUPPORT_CHAT', 'DQ_The_File_Donor_Support') -P_TTI_SHOW_OFF = is_enabled((environ.get('P_TTI_SHOW_OFF', "False")), False) -IMDB = is_enabled((environ.get('IMDB', "True")), True) -AUTO_FFILTER = is_enabled((environ.get('AUTO_FFILTER', "True")), True) -AUTO_DELETE = is_enabled((environ.get('AUTO_DELETE', "True")), True) -SINGLE_BUTTON = is_enabled((environ.get('SINGLE_BUTTON', "True")), True) -CUSTOM_FILE_CAPTION = environ.get("CUSTOM_FILE_CAPTION", f"{script.CAPTION}") -BATCH_FILE_CAPTION = environ.get("BATCH_FILE_CAPTION", CUSTOM_FILE_CAPTION) -IMDB_TEMPLATE = environ.get("IMDB_TEMPLATE", f"{script.IMDB_TEMPLATE_TXT}") -LONG_IMDB_DESCRIPTION = is_enabled(environ.get("LONG_IMDB_DESCRIPTION", "False"), False) -SPELL_CHECK_REPLY = is_enabled(environ.get("SPELL_CHECK_REPLY", "True"), True) -MAX_LIST_ELM = environ.get("MAX_LIST_ELM", None) -INDEX_REQ_CHANNEL = int(environ.get('INDEX_REQ_CHANNEL', LOG_CHANNEL)) -FILE_STORE_CHANNEL = [int(ch) for ch in (environ.get('FILE_STORE_CHANNEL', '')).split()] -MELCOW_NEW_USERS = is_enabled((environ.get('MELCOW_NEW_USERS', "True")), True) -PROTECT_CONTENT = is_enabled((environ.get('PROTECT_CONTENT', "False")), False) -PUBLIC_FILE_STORE = is_enabled((environ.get('PUBLIC_FILE_STORE', "True")), True) - -LOG_STR = "Current Cusomized Configurations are:-\n" -LOG_STR += ("IMDB Results are enabled, Bot will be showing imdb details for you queries.\n" if IMDB else "IMBD Results are disabled.\n") -LOG_STR += ("P_TTI_SHOW_OFF found , Users will be redirected to send /start to Bot PM instead of sending file file directly\n" if P_TTI_SHOW_OFF else "P_TTI_SHOW_OFF is disabled files will be send in PM, instead of sending start.\n") -LOG_STR += ("SINGLE_BUTTON is Found, filename and files size will be shown in a single button instead of two separate buttons\n" if SINGLE_BUTTON else "SINGLE_BUTTON is disabled , filename and file_sixe will be shown as different buttons\n") -LOG_STR += (f"CUSTOM_FILE_CAPTION enabled with value {CUSTOM_FILE_CAPTION}, your files will be send along with this customized caption.\n" if CUSTOM_FILE_CAPTION else "No CUSTOM_FILE_CAPTION Found, Default captions of file will be used.\n") -LOG_STR += ("Long IMDB storyline enabled." if LONG_IMDB_DESCRIPTION else "LONG_IMDB_DESCRIPTION is disabled , Plot will be shorter.\n") -LOG_STR += ("Spell Check Mode Is Enabled, bot will be suggesting related movies if movie not found\n" if SPELL_CHECK_REPLY else "SPELL_CHECK_REPLY Mode disabled\n") -LOG_STR += (f"MAX_LIST_ELM Found, long list will be shortened to first {MAX_LIST_ELM} elements\n" if MAX_LIST_ELM else "Full List of casts and crew will be shown in imdb template, restrict them by adding a value to MAX_LIST_ELM\n") -LOG_STR += f"Your current IMDB template is {IMDB_TEMPLATE}" diff --git a/plugins/banned.py b/plugins/banned.py deleted file mode 100644 index ec9c049a9..000000000 --- a/plugins/banned.py +++ /dev/null @@ -1,40 +0,0 @@ -from pyrogram import Client, filters -from utils import temp -from pyrogram.types import Message -from database.users_chats_db import db -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup -from info import SUPPORT_CHAT - -async def banned_users(_, client, message: Message): - return ( - message.from_user is not None or not message.sender_chat - ) and message.from_user.id in temp.BANNED_USERS - -banned_user = filters.create(banned_users) - -async def disabled_chat(_, client, message: Message): - return message.chat.id in temp.BANNED_CHATS - -disabled_group=filters.create(disabled_chat) - - -@Client.on_message(filters.private & banned_user & filters.incoming) -async def ban_reply(bot, message): - ban = await db.get_ban_status(message.from_user.id) - await message.reply(f'Sorry Dude, You are Banned to use Me. \nBan Reason: {ban["ban_reason"]}') - -@Client.on_message(filters.group & disabled_group & filters.incoming) -async def grp_bd(bot, message): - buttons = [[ - InlineKeyboardButton('Support', url=f'https://t.me/{SUPPORT_CHAT}') - ]] - reply_markup=InlineKeyboardMarkup(buttons) - vazha = await db.get_chat(message.chat.id) - k = await message.reply( - text=f"CHAT NOT ALLOWED 🐞\n\nMy admins has restricted me from working here ! If you want to know more about it contact support..\nReason : {vazha['reason']}.", - reply_markup=reply_markup) - try: - await k.pin() - except: - pass - await bot.leave_chat(message.chat.id) diff --git a/plugins/broadcast.py b/plugins/broadcast.py deleted file mode 100644 index 415344b2b..000000000 --- a/plugins/broadcast.py +++ /dev/null @@ -1,73 +0,0 @@ - -from pyrogram import Client, filters -import datetime -import time -from database.users_chats_db import db -from info import ADMINS -from utils import broadcast_messages -import asyncio - -@Client.on_message(filters.command("broadcast") & filters.user(ADMINS) & filters.reply) -# https://t.me/GetTGLink/4178 -async def verupikkals(bot, message): - users = await db.get_all_users() - b_msg = message.reply_to_message - sts = await message.reply_text( - text='Broadcasting your messages...' - ) - start_time = time.time() - total_users = await db.total_users_count() - done = 0 - blocked = 0 - deleted = 0 - failed =0 - - success = 0 - for user in users: - pti, sh = await broadcast_messages(int(user['id']), b_msg) - if pti: - success += 1 - elif pti == False: - if sh == "Blocked": - blocked+=1 - elif sh == "Deleted": - deleted += 1 - elif sh == "Error": - failed += 1 - done += 1 - await asyncio.sleep(2) - if not done % 20: - await sts.edit(f"Broadcast in progress:\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") - time_taken = datetime.timedelta(seconds=int(time.time()-start_time)) - await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") - -@Client.on_message(filters.command("grp_broadcast") & filters.user(ADMINS) & filters.reply) -async def grp_brodcst(bot, message): - chats = await db.get_all_chats() - b_msg = message.reply_to_message - sts = await message.reply_text( - text='Broadcasting your messages...' - ) - start_time = time.time() - total_chats = await db.total_chat_count() - done = 0 - failed =0 - - success = 0 - for chat in chats: - pti, sh = await broadcast_messages(int(chat['id']), b_msg) - if pti: - success += 1 - elif pti == False: - if sh == "Blocked": - blocked+=1 - elif sh == "Deleted": - deleted += 1 - elif sh == "Error": - failed += 1 - done += 1 - await asyncio.sleep(2) - if not done % 20: - await sts.edit(f"Broadcast in progress:\n\nTotal Chats {total_chats}\nCompleted: {done} / {total_chats}\nSuccess: {success}\nFailed: {failed}") - time_taken = datetime.timedelta(seconds=int(time.time()-start_time)) - await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nTotal Chats {total_chats}\nCompleted: {done} / {total_chats}\nSuccess: {success}\nFailed: {failed}") diff --git a/plugins/channel.py b/plugins/channel.py deleted file mode 100644 index 595463180..000000000 --- a/plugins/channel.py +++ /dev/null @@ -1,20 +0,0 @@ -from pyrogram import Client, filters -from info import CHANNELS -from database.ia_filterdb import save_file - -media_filter = filters.document | filters.video | filters.audio - - -@Client.on_message(filters.chat(CHANNELS) & media_filter) -async def media(bot, message): - """Media Handler""" - for file_type in ("document", "video", "audio"): - media = getattr(message, file_type, None) - if media is not None: - break - else: - return - - media.file_type = file_type - media.caption = message.caption - await save_file(media) \ No newline at end of file diff --git a/plugins/commands.py b/plugins/commands.py deleted file mode 100644 index 32a413e8e..000000000 --- a/plugins/commands.py +++ /dev/null @@ -1,879 +0,0 @@ -import os -import logging -import random -import asyncio -from Script import script -from pyrogram import Client, filters, enums -from pyrogram.errors import ChatAdminRequired, FloodWait -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup -from database.ia_filterdb import Media, Media2, get_file_details, unpack_new_file_id -from database.users_chats_db import db -from info import CHANNELS, ADMINS, AUTH_CHANNEL, LOG_CHANNEL, PICS, BATCH_FILE_CAPTION, CUSTOM_FILE_CAPTION, PROTECT_CONTENT, CHNL_LNK, GRP_LNK, REQST_CHANNEL, SUPPORT_CHAT_ID, MAX_B_TN, IS_VERIFY, HOW_TO_VERIFY -from utils import get_settings, get_size, is_subscribed, save_group_settings, temp, verify_user, check_token, check_verification, get_token, send_all -from database.connections_mdb import active_connection -import re -import json -import base64 -logger = logging.getLogger(__name__) - -BATCH_FILES = {} - -@Client.on_message(filters.command("start") & filters.incoming) -async def start(client, message): - if message.chat.type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - buttons = [[ - InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true') - ],[ - InlineKeyboardButton('♚ Bᴏᴛ Oᴡɴᴇʀ', callback_data="owner_info"), - InlineKeyboardButton('⌬ Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK) - ],[ - InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'), - InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about'), - InlineKeyboardButton('Iɴʟɪɴᴇ Sᴇᴀʀᴄʜ ☌', switch_inline_query_current_chat='') - ],[ - InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK) - ]] - reply_markup = InlineKeyboardMarkup(buttons) - await message.reply_photo( - photo=random.choice(PICS), - caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - await asyncio.sleep(2) # 😢 https://github.com/EvamariaTG/EvaMaria/blob/master/plugins/p_ttishow.py#L17 😬 wait a bit, before checking. - if not await db.get_chat(message.chat.id): - total=await client.get_chat_members_count(message.chat.id) - await client.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, "Unknown")) - await db.add_chat(message.chat.id, message.chat.title) - return - if not await db.is_user_exist(message.from_user.id): - await db.add_user(message.from_user.id, message.from_user.first_name) - await client.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(message.from_user.id, message.from_user.mention)) - if len(message.command) != 2: - buttons = [[ - InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true') - ],[ - InlineKeyboardButton('♚ Bᴏᴛ Oᴡɴᴇʀ', callback_data="owner_info"), - InlineKeyboardButton('⌬ Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK) - ],[ - InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'), - InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about'), - InlineKeyboardButton('Iɴʟɪɴᴇ Sᴇᴀʀᴄʜ ☌', switch_inline_query_current_chat='') - ],[ - InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK) - ]] - reply_markup = InlineKeyboardMarkup(buttons) - await message.reply_photo( - photo=random.choice(PICS), - caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - return - - invite_links = await is_subscribed(client, query=message) - if AUTH_CHANNEL and len(invite_links) >= 1: - #this is written by tg: @programcrasher - btn = [] - for chnl_num, link in enumerate(invite_links, start=1): - if chnl_num == 1: - channel_num = "1sᴛ" - elif chnl_num == 2: - channel_num = "2ɴᴅ" - elif chnl_num == 3: - channel_num = "3ʀᴅ" - else: - channel_num = str(chnl_num)+"ᴛʜ" - btn.append([ - InlineKeyboardButton(f"❆ Jᴏɪɴ {channel_num} Cʜᴀɴɴᴇʟ ❆", url=link) - ]) - - if message.command[1] != "subscribe": - try: - kk, file_id = message.command[1].split("_", 1) - pre = 'checksubp' if kk == 'filep' else 'checksub' - btn.append([InlineKeyboardButton("↻ Tʀʏ Aɢᴀɪɴ", callback_data=f"{pre}#{file_id}")]) - except (IndexError, ValueError): - btn.append([InlineKeyboardButton("↻ Tʀʏ Aɢᴀɪɴ", url=f"https://t.me/{temp.U_NAME}?start={message.command[1]}")]) - await client.send_message( - chat_id=message.from_user.id, - text="**Yᴏᴜ ᴀʀᴇ ɴᴏᴛ ɪɴ ᴏᴜʀ Bᴀᴄᴋ-ᴜᴘ ᴄʜᴀɴɴᴇʟs ɢɪᴠᴇɴ ʙᴇʟᴏᴡ sᴏ ʏᴏᴜ ᴅᴏɴ'ᴛ ɢᴇᴛ ᴛʜᴇ ᴍᴏᴠɪᴇ ғɪʟᴇ...\n\nIғ ʏᴏᴜ ᴡᴀɴᴛ ᴛʜᴇ ᴍᴏᴠɪᴇ ғɪʟᴇ, ᴄʟɪᴄᴋ ᴏɴ ᴛʜᴇ ɢɪᴠᴇɴ ʙᴜᴛᴛᴏɴs ʙᴇʟᴏᴡ ᴀɴᴅ ᴊᴏɪɴ ᴏᴜʀ ʙᴀᴄᴋ-ᴜᴘ ᴄʜᴀɴɴᴇʟs, ᴛʜᴇɴ ᴄʟɪᴄᴋ ᴏɴ ᴛʜᴇ '↻ Tʀʏ Aɢᴀɪɴ' ʙᴜᴛᴛᴏɴ ʙᴇʟᴏᴡ...\n\nTʜᴇɴ ʏᴏᴜ ᴡɪʟʟ ɢᴇᴛ ᴛʜᴇ ᴍᴏᴠɪᴇ ғɪʟᴇs...**", - reply_markup=InlineKeyboardMarkup(btn), - parse_mode=enums.ParseMode.MARKDOWN - ) - return - if len(message.command) == 2 and message.command[1] in ["subscribe", "error", "okay", "help"]: - buttons = [[ - InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true') - ],[ - InlineKeyboardButton('♚ Bᴏᴛ Oᴡɴᴇʀ', callback_data="owner_info"), - InlineKeyboardButton('⌬ Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK) - ],[ - InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'), - InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about'), - InlineKeyboardButton('Iɴʟɪɴᴇ Sᴇᴀʀᴄʜ ☌', switch_inline_query_current_chat='') - ],[ - InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK) - ]] - reply_markup = InlineKeyboardMarkup(buttons) - await message.reply_photo( - photo=random.choice(PICS), - caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - return - data = message.command[1] - try: - pre, file_id = data.split('_', 1) - except: - file_id = data - pre = "" - if data.split("-", 1)[0] == "BATCH": - sts = await message.reply("Pʟᴇᴀsᴇ ᴡᴀɪᴛ...") - file_id = data.split("-", 1)[1] - msgs = BATCH_FILES.get(file_id) - if not msgs: - file = await client.download_media(file_id) - try: - with open(file) as file_data: - msgs=json.loads(file_data.read()) - except: - await sts.edit("Fᴀɪʟᴇᴅ") - return await client.send_message(LOG_CHANNEL, "Uɴᴀʙʟᴇ Tᴏ Oᴘᴇɴ Fɪʟᴇ.") - os.remove(file) - BATCH_FILES[file_id] = msgs - for msg in msgs: - title = msg.get("title") - size=get_size(int(msg.get("size", 0))) - f_caption=msg.get("caption", "") - if BATCH_FILE_CAPTION: - try: - f_caption=BATCH_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption) - except Exception as e: - logger.exception(e) - f_caption=f_caption - if f_caption is None: - f_caption = f"{title}" - try: - await client.send_cached_media( - chat_id=message.from_user.id, - file_id=msg.get("file_id"), - caption=f_caption, - protect_content=msg.get('protect', False), - reply_markup=InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) - ],[ - InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/creatorbeatz") - ] - ] - ) - ) - except FloodWait as e: - await asyncio.sleep(e.x) - logger.warning(f"Floodwait of {e.x} sec.") - await client.send_cached_media( - chat_id=message.from_user.id, - file_id=msg.get("file_id"), - caption=f_caption, - protect_content=msg.get('protect', False), - reply_markup=InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) - ],[ - InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/creatorbeatz") - ] - ] - ) - ) - except Exception as e: - logger.warning(e, exc_info=True) - continue - await asyncio.sleep(1) - await sts.delete() - return - elif data.split("-", 1)[0] == "DSTORE": - sts = await message.reply("Pʟᴇᴀsᴇ ᴡᴀɪᴛ...") - b_string = data.split("-", 1)[1] - decoded = (base64.urlsafe_b64decode(b_string + "=" * (-len(b_string) % 4))).decode("ascii") - try: - f_msg_id, l_msg_id, f_chat_id, protect = decoded.split("_", 3) - except: - f_msg_id, l_msg_id, f_chat_id = decoded.split("_", 2) - protect = "/pbatch" if PROTECT_CONTENT else "batch" - diff = int(l_msg_id) - int(f_msg_id) - async for msg in client.iter_messages(int(f_chat_id), int(l_msg_id), int(f_msg_id)): - if msg.media: - media = getattr(msg, msg.media.value) - if BATCH_FILE_CAPTION: - try: - f_caption=BATCH_FILE_CAPTION.format(file_name=getattr(media, 'file_name', ''), file_size=getattr(media, 'file_size', ''), file_caption=getattr(msg, 'caption', '')) - except Exception as e: - logger.exception(e) - f_caption = getattr(msg, 'caption', '') - else: - media = getattr(msg, msg.media.value) - file_name = getattr(media, 'file_name', '') - f_caption = getattr(msg, 'caption', file_name) - try: - await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False) - except FloodWait as e: - await asyncio.sleep(e.x) - await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False) - except Exception as e: - logger.exception(e) - continue - elif msg.empty: - continue - else: - try: - await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False) - except FloodWait as e: - await asyncio.sleep(e.x) - await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False) - except Exception as e: - logger.exception(e) - continue - await asyncio.sleep(1) - return await sts.delete() - - elif data.split("-", 1)[0] == "verify": - userid = data.split("-", 2)[1] - token = data.split("-", 3)[2] - fileid = data.split("-", 3)[3] - if str(message.from_user.id) != str(userid): - return await message.reply_text( - text="Iɴᴠᴀʟɪᴅ ʟɪɴᴋ ᴏʀ Exᴘɪʀᴇᴅ ʟɪɴᴋ !", - protect_content=True if PROTECT_CONTENT else False - ) - is_valid = await check_token(client, userid, token) - if is_valid == True: - if fileid == "send_all": - btn = [[ - InlineKeyboardButton("Gᴇᴛ Fɪʟᴇ", callback_data=f"checksub#send_all") - ]] - await verify_user(client, userid, token) - await message.reply_text( - text=f"Hᴇʏ {message.from_user.mention}, Yᴏᴜ ᴀʀᴇ sᴜᴄᴄᴇssғᴜʟʟʏ ᴠᴇʀɪғɪᴇᴅ !\nNᴏᴡ ʏᴏᴜ ʜᴀᴠᴇ ᴜɴʟɪᴍɪᴛᴇᴅ ᴀᴄᴄᴇss ғᴏʀ ᴀʟʟ ᴍᴏᴠɪᴇs ᴛɪʟʟ ᴛʜᴇ ɴᴇxᴛ ᴠᴇʀɪғɪᴄᴀᴛɪᴏɴ ᴡʜɪᴄʜ ɪs ᴀғᴛᴇʀ 12 ʜᴏᴜʀs ғʀᴏᴍ ɴᴏᴡ.", - protect_content=True if PROTECT_CONTENT else False, - reply_markup=InlineKeyboardMarkup(btn) - ) - return - btn = [[ - InlineKeyboardButton("Get File", url=f"https://telegram.me/{temp.U_NAME}?start=files_{fileid}") - ]] - await message.reply_text( - text=f"Hᴇʏ {message.from_user.mention}, Yᴏᴜ ᴀʀᴇ sᴜᴄᴄᴇssғᴜʟʟʏ ᴠᴇʀɪғɪᴇᴅ !\nNᴏᴡ ʏᴏᴜ ʜᴀᴠᴇ ᴜɴʟɪᴍɪᴛᴇᴅ ᴀᴄᴄᴇss ғᴏʀ ᴀʟʟ ᴍᴏᴠɪᴇs ᴛɪʟʟ ᴛʜᴇ ɴᴇxᴛ ᴠᴇʀɪғɪᴄᴀᴛɪᴏɴ ᴡʜɪᴄʜ ɪs ᴀғᴛᴇʀ 12 ʜᴏᴜʀs ғʀᴏᴍ ɴᴏᴡ.", - protect_content=True if PROTECT_CONTENT else False, - reply_markup=InlineKeyboardMarkup(btn) - ) - await verify_user(client, userid, token) - return - else: - return await message.reply_text( - text="Iɴᴠᴀʟɪᴅ ʟɪɴᴋ ᴏʀ Exᴘɪʀᴇᴅ ʟɪɴᴋ !", - protect_content=True if PROTECT_CONTENT else False - ) - - files_ = await get_file_details(file_id) - if not files_: - pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1) - try: - if IS_VERIFY and not await check_verification(client, message.from_user.id): - btn = [[ - InlineKeyboardButton("Vᴇʀɪғʏ", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start=", file_id)), - InlineKeyboardButton("Hᴏᴡ Tᴏ Vᴇʀɪғʏ", url=HOW_TO_VERIFY) - ]] - await message.reply_text( - text="Yᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴠᴇʀɪғɪᴇᴅ!\nKɪɴᴅʟʏ ᴠᴇʀɪғʏ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ Sᴏ ᴛʜᴀᴛ ʏᴏᴜ ᴄᴀɴ ɢᴇᴛ ᴀᴄᴄᴇss ᴛᴏ ᴜɴʟɪᴍɪᴛᴇᴅ ᴍᴏᴠɪᴇs ᴜɴᴛɪʟ 12 ʜᴏᴜʀs ғʀᴏᴍ ɴᴏᴡ !", - protect_content=True if PROTECT_CONTENT else False, - reply_markup=InlineKeyboardMarkup(btn) - ) - return - msg = await client.send_cached_media( - chat_id=message.from_user.id, - file_id=file_id, - protect_content=True if pre == 'filep' else False, - reply_markup=InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) - ],[ - InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/creatorbeatz") - ] - ] - ) - ) - filetype = msg.media - file = getattr(msg, filetype.value) - title = file.file_name - size=get_size(file.file_size) - f_caption = f"{title}" - if CUSTOM_FILE_CAPTION: - try: - f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='') - except: - return - await msg.edit_caption(f_caption) - return - except: - pass - return await message.reply('Nᴏ sᴜᴄʜ ғɪʟᴇ ᴇxɪsᴛ.') - files = files_[0] - title = files.file_name - size=get_size(files.file_size) - f_caption=files.caption - if CUSTOM_FILE_CAPTION: - try: - f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption) - except Exception as e: - logger.exception(e) - f_caption=f_caption - if f_caption is None: - f_caption = f"{files.file_name}" - if IS_VERIFY and not await check_verification(client, message.from_user.id): - btn = [[ - InlineKeyboardButton("Vᴇʀɪғʏ", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start=", file_id)), - InlineKeyboardButton("Hᴏᴡ Tᴏ Vᴇʀɪғʏ", url=HOW_TO_VERIFY) - ]] - await message.reply_text( - text="Yᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴠᴇʀɪғɪᴇᴅ!\nKɪɴᴅʟʏ ᴠᴇʀɪғʏ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ Sᴏ ᴛʜᴀᴛ ʏᴏᴜ ᴄᴀɴ ɢᴇᴛ ᴀᴄᴄᴇss ᴛᴏ ᴜɴʟɪᴍɪᴛᴇᴅ ᴍᴏᴠɪᴇs ᴜɴᴛɪʟ 12 ʜᴏᴜʀs ғʀᴏᴍ ɴᴏᴡ !", - protect_content=True if PROTECT_CONTENT else False, - reply_markup=InlineKeyboardMarkup(btn) - ) - return - await client.send_cached_media( - chat_id=message.from_user.id, - file_id=file_id, - caption=f_caption, - protect_content=True if pre == 'filep' else False, - reply_markup=InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) - ],[ - InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/creatorbeatz") - ] - ] - ) - ) - - -@Client.on_message(filters.command('channel') & filters.user(ADMINS)) -async def channel_info(bot, message): - - """Send basic information of channel""" - if isinstance(CHANNELS, (int, str)): - channels = [CHANNELS] - elif isinstance(CHANNELS, list): - channels = CHANNELS - else: - raise ValueError("Uɴᴇxᴘᴇᴄᴛᴇᴅ ᴛʏᴘᴇ ᴏғ CHANNELS") - - text = '📑 **Iɴᴅᴇxᴇᴅ ᴄʜᴀɴɴᴇʟs/ɢʀᴏᴜᴘs**\n' - for channel in channels: - chat = await bot.get_chat(channel) - if chat.username: - text += '\n@' + chat.username - else: - text += '\n' + chat.title or chat.first_name - - text += f'\n\n**Total:** {len(CHANNELS)}' - - if len(text) < 4096: - await message.reply(text) - else: - file = 'Indexed channels.txt' - with open(file, 'w') as f: - f.write(text) - await message.reply_document(file) - os.remove(file) - - -@Client.on_message(filters.command('logs') & filters.user(ADMINS)) -async def log_file(bot, message): - """Send log file""" - try: - await message.reply_document('Logs.txt') - except Exception as e: - await message.reply(str(e)) - -@Client.on_message(filters.command('delete') & filters.user(ADMINS)) -async def delete(bot, message): - """Delete file from database""" - reply = message.reply_to_message - if reply and reply.media: - msg = await message.reply("Pʀᴏᴄᴇssɪɴɢ...⏳", quote=True) - else: - await message.reply('Rᴇᴘʟʏ ᴛᴏ ғɪʟᴇ ᴡɪᴛʜ /delete ᴡʜɪᴄʜ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴅᴇʟᴇᴛᴇ', quote=True) - return - - for file_type in ("document", "video", "audio"): - media = getattr(reply, file_type, None) - if media is not None: - break - else: - await msg.edit('Tʜɪs ɪs ɴᴏᴛ sᴜᴘᴘᴏʀᴛᴇᴅ ғɪʟᴇ ғᴏʀᴍᴀᴛ') - return - - file_id, file_ref = unpack_new_file_id(media.file_id) - if await Media.count_documents({'file_id': file_id}): - result = await Media.collection.delete_one({ - '_id': file_id, - }) - else: - result = await Media2.collection.delete_one({ - '_id': file_id, - }) - if result.deleted_count: - await msg.edit('Fɪʟᴇ ɪs sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ғʀᴏᴍ ᴅᴀᴛᴀʙᴀsᴇ') - else: - file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name)) - result = await Media.collection.delete_many({ - 'file_name': file_name, - 'file_size': media.file_size, - 'mime_type': media.mime_type - }) - if result.deleted_count: - await msg.edit('Fɪʟᴇ ɪs sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ғʀᴏᴍ ᴅᴀᴛᴀʙᴀsᴇ') - else: - result = await Media2.collection.delete_many({ - 'file_name': file_name, - 'file_size': media.file_size, - 'mime_type': media.mime_type - }) - if result.deleted_count: - await msg.edit('Fɪʟᴇ ɪs sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ғʀᴏᴍ ᴅᴀᴛᴀʙᴀsᴇ') - else: - # files indexed before https://github.com/EvamariaTG/EvaMaria/commit/f3d2a1bcb155faf44178e5d7a685a1b533e714bf#diff-86b613edf1748372103e94cacff3b578b36b698ef9c16817bb98fe9ef22fb669R39 - # have original file name. - result = await Media.collection.delete_many({ - 'file_name': media.file_name, - 'file_size': media.file_size, - 'mime_type': media.mime_type - }) - if result.deleted_count: - await msg.edit('Fɪʟᴇ ɪs sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ғʀᴏᴍ ᴅᴀᴛᴀʙᴀsᴇ') - else: - result = await Media2.collection.delete_many({ - 'file_name': media.file_name, - 'file_size': media.file_size, - 'mime_type': media.mime_type - }) - if result.deleted_count: - await msg.edit('Fɪʟᴇ ɪs sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ғʀᴏᴍ ᴅᴀᴛᴀʙᴀsᴇ') - else: - await msg.edit('Fɪʟᴇ ɴᴏᴛ ғᴏᴜɴᴅ ɪɴ ᴅᴀᴛᴀʙᴀsᴇ') - -@Client.on_message(filters.command('deleteall') & filters.user(ADMINS)) -async def delete_all_index(bot, message): - await message.reply_text( - 'Tʜɪs ᴡɪʟʟ ᴅᴇʟᴇᴛᴇ ᴀʟʟ ɪɴᴅᴇxᴇᴅ ғɪʟᴇs.\nDᴏ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ ?', - reply_markup=InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton( - text="Yᴇs", callback_data="autofilter_delete" - ) - ], - [ - InlineKeyboardButton( - text="Cᴀɴᴄᴇʟ", callback_data="close_data" - ) - ], - ] - ), - quote=True, - ) - - -@Client.on_callback_query(filters.regex(r'^autofilter_delete')) -async def delete_all_index_confirm(bot, message): - await Media.collection.drop() - await Media2.collection.drop() - await message.answer("Eᴠᴇʀʏᴛʜɪɴɢ's Gᴏɴᴇ") - await message.message.edit('Sᴜᴄᴄᴇsғᴜʟʟʏ Dᴇʟᴇᴛᴇᴅ Aʟʟ Tʜᴇ Iɴᴅᴇxᴇᴅ Fɪʟᴇs.') - - -@Client.on_message(filters.command('settings')) -async def settings(client, message): - userid = message.from_user.id if message.from_user else None - if not userid: - return await message.reply(f"Yᴏᴜ ᴀʀᴇ ᴀɴᴏɴʏᴍᴏᴜs ᴀᴅᴍɪɴ. Usᴇ /connect {message.chat.id} ɪɴ PM") - chat_type = message.chat.type - - if chat_type == enums.ChatType.PRIVATE: - grpid = await active_connection(str(userid)) - if grpid is not None: - grp_id = grpid - try: - chat = await client.get_chat(grpid) - title = chat.title - except: - await message.reply_text("Mᴀᴋᴇ sᴜʀᴇ I'ᴍ ᴘʀᴇsᴇɴᴛ ɪɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ !", quote=True) - return - else: - await message.reply_text("I'ᴍ ɴᴏᴛ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ ᴀɴʏ ɢʀᴏᴜᴘs !", quote=True) - return - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grp_id = message.chat.id - title = message.chat.title - - else: - return - - st = await client.get_chat_member(grp_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and str(userid) not in ADMINS - ): - return - - settings = await get_settings(grp_id) - - try: - if settings['max_btn']: - settings = await get_settings(grp_id) - except KeyError: - await save_group_settings(grp_id, 'max_btn', False) - settings = await get_settings(grp_id) - if 'is_shortlink' not in settings.keys(): - await save_group_settings(grp_id, 'is_shortlink', False) - else: - pass - - if settings is not None: - buttons = [ - [ - InlineKeyboardButton( - 'Fɪʟᴛᴇʀ Bᴜᴛᴛᴏɴ', - callback_data=f'setgs#button#{settings["button"]}#{grp_id}', - ), - InlineKeyboardButton( - 'Sɪɴɢʟᴇ' if settings["button"] else 'Dᴏᴜʙʟᴇ', - callback_data=f'setgs#button#{settings["button"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'Fɪʟᴇ Sᴇɴᴅ Mᴏᴅᴇ', - callback_data=f'setgs#botpm#{settings["botpm"]}#{grp_id}', - ), - InlineKeyboardButton( - 'Mᴀɴᴜᴀʟ Sᴛᴀʀᴛ' if settings["botpm"] else 'Aᴜᴛᴏ Sᴇɴᴅ', - callback_data=f'setgs#botpm#{settings["botpm"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'Pʀᴏᴛᴇᴄᴛ Cᴏɴᴛᴇɴᴛ', - callback_data=f'setgs#file_secure#{settings["file_secure"]}#{grp_id}', - ), - InlineKeyboardButton( - '✔ Oɴ' if settings["file_secure"] else '✘ Oғғ', - callback_data=f'setgs#file_secure#{settings["file_secure"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'Iᴍᴅʙ', - callback_data=f'setgs#imdb#{settings["imdb"]}#{grp_id}', - ), - InlineKeyboardButton( - '✔ Oɴ' if settings["imdb"] else '✘ Oғғ', - callback_data=f'setgs#imdb#{settings["imdb"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'Sᴘᴇʟʟ Cʜᴇᴄᴋ', - callback_data=f'setgs#spell_check#{settings["spell_check"]}#{grp_id}', - ), - InlineKeyboardButton( - '✔ Oɴ' if settings["spell_check"] else '✘ Oғғ', - callback_data=f'setgs#spell_check#{settings["spell_check"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'Wᴇʟᴄᴏᴍᴇ Msɢ', - callback_data=f'setgs#welcome#{settings["welcome"]}#{grp_id}', - ), - InlineKeyboardButton( - '✔ Oɴ' if settings["welcome"] else '✘ Oғғ', - callback_data=f'setgs#welcome#{settings["welcome"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'Aᴜᴛᴏ-Dᴇʟᴇᴛᴇ', - callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{grp_id}', - ), - InlineKeyboardButton( - '10 Mɪɴs' if settings["auto_delete"] else '✘ Oғғ', - callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'Aᴜᴛᴏ-Fɪʟᴛᴇʀ', - callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{grp_id}', - ), - InlineKeyboardButton( - '✔ Oɴ' if settings["auto_ffilter"] else '✘ Oғғ', - callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'Mᴀx Bᴜᴛᴛᴏɴs', - callback_data=f'setgs#max_btn#{settings["max_btn"]}#{grp_id}', - ), - InlineKeyboardButton( - '10' if settings["max_btn"] else f'{MAX_B_TN}', - callback_data=f'setgs#max_btn#{settings["max_btn"]}#{grp_id}', - ), - ], - [ - InlineKeyboardButton( - 'SʜᴏʀᴛLɪɴᴋ', - callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{grp_id}', - ), - InlineKeyboardButton( - '✔ Oɴ' if settings["is_shortlink"] else '✘ Oғғ', - callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{grp_id}', - ), - ], - ] - - btn = [[ - InlineKeyboardButton("Oᴘᴇɴ Hᴇʀᴇ ↓", callback_data=f"opnsetgrp#{grp_id}"), - InlineKeyboardButton("Oᴘᴇɴ Iɴ PM ⇲", callback_data=f"opnsetpm#{grp_id}") - ]] - - reply_markup = InlineKeyboardMarkup(buttons) - if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - await message.reply_text( - text="Dᴏ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴏᴘᴇɴ sᴇᴛᴛɪɴɢs ʜᴇʀᴇ ?", - reply_markup=InlineKeyboardMarkup(btn), - disable_web_page_preview=True, - parse_mode=enums.ParseMode.HTML, - reply_to_message_id=message.id - ) - else: - await message.reply_text( - text=f"Cʜᴀɴɢᴇ Yᴏᴜʀ Sᴇᴛᴛɪɴɢs Fᴏʀ {title} As Yᴏᴜʀ Wɪsʜ ⚙", - reply_markup=reply_markup, - disable_web_page_preview=True, - parse_mode=enums.ParseMode.HTML, - reply_to_message_id=message.id - ) - - - -@Client.on_message(filters.command('set_template')) -async def save_template(client, message): - sts = await message.reply("Cʜᴇᴄᴋɪɴɢ ᴛᴇᴍᴘʟᴀᴛᴇ...") - userid = message.from_user.id if message.from_user else None - if not userid: - return await message.reply(f"Yᴏᴜ ᴀʀᴇ ᴀɴᴏɴʏᴍᴏᴜs ᴀᴅᴍɪɴ. Usᴇ /connect {message.chat.id} ɪɴ PM") - chat_type = message.chat.type - - if chat_type == enums.ChatType.PRIVATE: - grpid = await active_connection(str(userid)) - if grpid is not None: - grp_id = grpid - try: - chat = await client.get_chat(grpid) - title = chat.title - except: - await message.reply_text("Mᴀᴋᴇ sᴜʀᴇ I'ᴍ ᴘʀᴇsᴇɴᴛ ɪɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ!!", quote=True) - return - else: - await message.reply_text("I'ᴍ ɴᴏᴛ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ ᴀɴʏ ɢʀᴏᴜᴘs!", quote=True) - return - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grp_id = message.chat.id - title = message.chat.title - - else: - return - - st = await client.get_chat_member(grp_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and str(userid) not in ADMINS - ): - return - - if len(message.command) < 2: - return await sts.edit("Nᴏ Iɴᴘᴜᴛ!!") - template = message.text.split(" ", 1)[1] - await save_group_settings(grp_id, 'template', template) - await sts.edit(f"Sᴜᴄᴄᴇssғᴜʟʟʏ ᴄʜᴀɴɢᴇᴅ ᴛᴇᴍᴘʟᴀᴛᴇ ғᴏʀ {title} ᴛᴏ:\n\n{template}") - - -@Client.on_message((filters.command(["request", "Request"]) | filters.regex("#request") | filters.regex("#Request")) & filters.group) -async def requests(bot, message): - if REQST_CHANNEL is None or SUPPORT_CHAT_ID is None: return # Must add REQST_CHANNEL and SUPPORT_CHAT_ID to use this feature - if message.reply_to_message and SUPPORT_CHAT_ID == message.chat.id: - chat_id = message.chat.id - reporter = str(message.from_user.id) - mention = message.from_user.mention - success = True - content = message.reply_to_message.text - try: - if REQST_CHANNEL is not None: - btn = [[ - InlineKeyboardButton('Vɪᴇᴡ Rᴇᴏ̨ᴜᴇsᴛ', url=f"{message.reply_to_message.link}"), - InlineKeyboardButton('Sʜᴏᴡ Oᴘᴛɪᴏɴs', callback_data=f'show_option#{reporter}') - ]] - reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}", reply_markup=InlineKeyboardMarkup(btn)) - success = True - elif len(content) >= 3: - for admin in ADMINS: - btn = [[ - InlineKeyboardButton('Vɪᴇᴡ Rᴇᴏ̨ᴜᴇsᴛ', url=f"{message.reply_to_message.link}"), - InlineKeyboardButton('Sʜᴏᴡ Oᴘᴛɪᴏɴs', callback_data=f'show_option#{reporter}') - ]] - reported_post = await bot.send_message(chat_id=admin, text=f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}", reply_markup=InlineKeyboardMarkup(btn)) - success = True - else: - if len(content) < 3: - await message.reply_text("Yᴏᴜ ᴍᴜsᴛ ᴛʏᴘᴇ ᴀʙᴏᴜᴛ ʏᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ [Mɪɴɪᴍᴜᴍ 3 Cʜᴀʀᴀᴄᴛᴇʀs]. Rᴇᴏ̨ᴜᴇsᴛs ᴄᴀɴ'ᴛ ʙᴇ ᴇᴍᴘᴛʏ.") - if len(content) < 3: - success = False - except Exception as e: - await message.reply_text(f"Error: {e}") - pass - - elif SUPPORT_CHAT_ID == message.chat.id: - chat_id = message.chat.id - reporter = str(message.from_user.id) - mention = message.from_user.mention - success = True - content = message.text - keywords = ["#request", "/request", "#Request", "/Request"] - for keyword in keywords: - if keyword in content: - content = content.replace(keyword, "") - try: - if REQST_CHANNEL is not None and len(content) >= 3: - btn = [[ - InlineKeyboardButton('Vɪᴇᴡ Rᴇᴏ̨ᴜᴇsᴛ', url=f"{message.link}"), - InlineKeyboardButton('Sʜᴏᴡ Oᴘᴛɪᴏɴs', callback_data=f'show_option#{reporter}') - ]] - reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}", reply_markup=InlineKeyboardMarkup(btn)) - success = True - elif len(content) >= 3: - for admin in ADMINS: - btn = [[ - InlineKeyboardButton('Vɪᴇᴡ Rᴇᴏ̨ᴜᴇsᴛ', url=f"{message.link}"), - InlineKeyboardButton('Sʜᴏᴡ Oᴘᴛɪᴏɴs', callback_data=f'show_option#{reporter}') - ]] - reported_post = await bot.send_message(chat_id=admin, text=f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}", reply_markup=InlineKeyboardMarkup(btn)) - success = True - else: - if len(content) < 3: - await message.reply_text("Yᴏᴜ ᴍᴜsᴛ ᴛʏᴘᴇ ᴀʙᴏᴜᴛ ʏᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ [Mɪɴɪᴍᴜᴍ 3 Cʜᴀʀᴀᴄᴛᴇʀs]. Rᴇᴏ̨ᴜᴇsᴛs ᴄᴀɴ'ᴛ ʙᴇ ᴇᴍᴘᴛʏ.") - if len(content) < 3: - success = False - except Exception as e: - await message.reply_text(f"Eʀʀᴏʀ: {e}") - pass - - else: - success = False - - if success: - btn = [[ - InlineKeyboardButton('Vɪᴇᴡ Rᴇᴏ̨ᴜᴇsᴛ', url=f"{reported_post.link}") - ]] - await message.reply_text("Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ʜᴀs ʙᴇᴇɴ ᴀᴅᴅᴇᴅ! Pʟᴇᴀsᴇ ᴡᴀɪᴛ ғᴏʀ sᴏᴍᴇ ᴛɪᴍᴇ.", reply_markup=InlineKeyboardMarkup(btn)) - - -@Client.on_message(filters.command("send") & filters.user(ADMINS)) -async def send_msg(bot, message): - if message.reply_to_message: - target_id = message.text.split(" ", 1)[1] - out = "Usᴇʀs Sᴀᴠᴇᴅ Iɴ DB Aʀᴇ:\n\n" - success = False - try: - user = await bot.get_users(target_id) - users = await db.get_all_users() - async for usr in users: - out += f"{usr['id']}" - out += '\n' - if str(user.id) in str(out): - await message.reply_to_message.copy(int(user.id)) - success = True - else: - success = False - if success: - await message.reply_text(f"Yᴏᴜʀ ᴍᴇssᴀɢᴇ ʜᴀs ʙᴇᴇɴ sᴜᴄᴄᴇssғᴜʟʟʏ sᴇɴᴅ ᴛᴏ {user.mention}.") - else: - await message.reply_text("Tʜɪs ᴜsᴇʀ ᴅɪᴅɴ'ᴛ sᴛᴀʀᴛᴇᴅ ᴛʜɪs ʙᴏᴛ ʏᴇᴛ!") - except Exception as e: - await message.reply_text(f"Eʀʀᴏʀ: {e}") - else: - await message.reply_text("Usᴇ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ ᴀs ᴀ ʀᴇᴘʟʏ ᴛᴏ ᴀɴʏ ᴍᴇssᴀɢᴇ ᴜsɪɴɢ ᴛʜᴇ ᴛᴀʀɢᴇᴛ ᴄʜᴀᴛ ɪᴅ. Fᴏʀ ᴇɢ: /send ᴜsᴇʀɪᴅ") - -@Client.on_message(filters.command("deletefiles") & filters.user(ADMINS)) -async def deletemultiplefiles(bot, message): - chat_type = message.chat.type - if chat_type != enums.ChatType.PRIVATE: - return await message.reply_text(f"Hᴇʏ {message.from_user.mention}, Tʜɪs ᴄᴏᴍᴍᴀɴᴅ ᴡᴏɴ'ᴛ ᴡᴏʀᴋ ɪɴ ɢʀᴏᴜᴘs. Iᴛ ᴏɴʟʏ ᴡᴏʀᴋs ᴏɴ ᴍʏ PM!") - else: - pass - try: - keyword = message.text.split(" ", 1)[1] - except: - return await message.reply_text(f"Hᴇʏ {message.from_user.mention}, Gɪᴠᴇ ᴍᴇ ᴀ ᴋᴇʏᴡᴏʀᴅ ᴀʟᴏɴɢ ᴡɪᴛʜ ᴛʜᴇ ᴄᴏᴍᴍᴀɴᴅ ᴛᴏ ᴅᴇʟᴇᴛᴇ ғɪʟᴇs.") - btn = [[ - InlineKeyboardButton("Yᴇs, Cᴏɴᴛɪɴᴜᴇ !", callback_data=f"killfilesdq#{keyword}") - ],[ - InlineKeyboardButton("Nᴏ, Aʙᴏʀᴛ ᴏᴘᴇʀᴀᴛɪᴏɴ !", callback_data="close_data") - ]] - await message.reply_text( - text="Aʀᴇ ʏᴏᴜ sᴜʀᴇ? Dᴏ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ?\n\nNᴏᴛᴇ:- Tʜɪs ᴄᴏᴜʟᴅ ʙᴇ ᴀ ᴅᴇsᴛʀᴜᴄᴛɪᴠᴇ ᴀᴄᴛɪᴏɴ!", - reply_markup=InlineKeyboardMarkup(btn), - parse_mode=enums.ParseMode.HTML - ) - -@Client.on_message(filters.command("shortlink") & filters.user(ADMINS)) -async def shortlink(bot, message): - chat_type = message.chat.type - if chat_type == enums.ChatType.PRIVATE: - return await message.reply_text(f"Hᴇʏ {message.from_user.mention}, Tʜɪs ᴄᴏᴍᴍᴀɴᴅ ᴏɴʟʏ ᴡᴏʀᴋs ᴏɴ ɢʀᴏᴜᴘs !") - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grpid = message.chat.id - title = message.chat.title - else: - return - data = message.text - userid = message.from_user.id - user = await bot.get_chat_member(grpid, userid) - if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS: - return await message.reply_text("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ ᴀᴄᴄᴇss ᴛᴏ ᴜsᴇ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ !") - else: - pass - try: - command, shortlink_url, api = data.split(" ") - except: - return await message.reply_text("Cᴏᴍᴍᴀɴᴅ Iɴᴄᴏᴍᴘʟᴇᴛᴇ :(\n\nGɪᴠᴇ ᴍᴇ ᴀ sʜᴏʀᴛʟɪɴᴋ ᴀɴᴅ ᴀᴘɪ ᴀʟᴏɴɢ ᴡɪᴛʜ ᴛʜᴇ ᴄᴏᴍᴍᴀɴᴅ !\n\nFᴏʀᴍᴀᴛ: /shortlink shorturllink.in 95a8195c40d31e0c3b6baa68813fcecb1239f2e9") - reply = await message.reply_text("Pʟᴇᴀsᴇ Wᴀɪᴛ...") - await save_group_settings(grpid, 'shortlink', shortlink_url) - await save_group_settings(grpid, 'shortlink_api', api) - await save_group_settings(grpid, 'is_shortlink', True) - await reply.edit_text(f"Sᴜᴄᴄᴇssғᴜʟʟʏ ᴀᴅᴅᴇᴅ sʜᴏʀᴛʟɪɴᴋ API ғᴏʀ {title}.\n\nCᴜʀʀᴇɴᴛ Sʜᴏʀᴛʟɪɴᴋ Wᴇʙsɪᴛᴇ: {shortlink_url}\nCᴜʀʀᴇɴᴛ API: {api}") diff --git a/plugins/connection.py b/plugins/connection.py deleted file mode 100644 index 6011dd139..000000000 --- a/plugins/connection.py +++ /dev/null @@ -1,147 +0,0 @@ -from pyrogram import filters, Client, enums -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup -from database.connections_mdb import add_connection, all_connections, if_active, delete_connection -from info import ADMINS -import logging - -logger = logging.getLogger(__name__) -logger.setLevel(logging.ERROR) - - -@Client.on_message((filters.private | filters.group) & filters.command('connect')) -async def addconnection(client, message): - userid = message.from_user.id if message.from_user else None - if not userid: - return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") - chat_type = message.chat.type - - if chat_type == enums.ChatType.PRIVATE: - try: - cmd, group_id = message.text.split(" ", 1) - except: - await message.reply_text( - "Enter in correct format!\n\n" - "/connect groupid\n\n" - "Get your Group id by adding this bot to your group and use /id", - quote=True - ) - return - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - group_id = message.chat.id - - try: - st = await client.get_chat_member(group_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and userid not in ADMINS - ): - await message.reply_text("You should be an admin in Given group!", quote=True) - return - except Exception as e: - logger.exception(e) - await message.reply_text( - "Invalid Group ID!\n\nIf correct, Make sure I'm present in your group!!", - quote=True, - ) - - return - try: - st = await client.get_chat_member(group_id, "me") - if st.status == enums.ChatMemberStatus.ADMINISTRATOR: - ttl = await client.get_chat(group_id) - title = ttl.title - - addcon = await add_connection(str(group_id), str(userid)) - if addcon: - await message.reply_text( - f"Successfully connected to **{title}**\nNow manage your group from my pm !", - quote=True, - parse_mode=enums.ParseMode.MARKDOWN - ) - if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - await client.send_message( - userid, - f"Connected to **{title}** !", - parse_mode=enums.ParseMode.MARKDOWN - ) - else: - await message.reply_text( - "You're already connected to this chat!", - quote=True - ) - else: - await message.reply_text("Add me as an admin in group", quote=True) - except Exception as e: - logger.exception(e) - await message.reply_text('Some error occurred! Try again later.', quote=True) - return - - -@Client.on_message((filters.private | filters.group) & filters.command('disconnect')) -async def deleteconnection(client, message): - userid = message.from_user.id if message.from_user else None - if not userid: - return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") - chat_type = message.chat.type - - if chat_type == enums.ChatType.PRIVATE: - await message.reply_text("Run /connections to view or disconnect from groups!", quote=True) - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - group_id = message.chat.id - - st = await client.get_chat_member(group_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and str(userid) not in ADMINS - ): - return - - delcon = await delete_connection(str(userid), str(group_id)) - if delcon: - await message.reply_text("Successfully disconnected from this chat", quote=True) - else: - await message.reply_text("This chat isn't connected to me!\nDo /connect to connect.", quote=True) - - -@Client.on_message(filters.private & filters.command(["connections"])) -async def connections(client, message): - userid = message.from_user.id - - groupids = await all_connections(str(userid)) - if groupids is None: - await message.reply_text( - "There are no active connections!! Connect to some groups first.", - quote=True - ) - return - buttons = [] - for groupid in groupids: - try: - ttl = await client.get_chat(int(groupid)) - title = ttl.title - active = await if_active(str(userid), str(groupid)) - act = " - ACTIVE" if active else "" - buttons.append( - [ - InlineKeyboardButton( - text=f"{title}{act}", callback_data=f"groupcb:{groupid}:{act}" - ) - ] - ) - except: - pass - if buttons: - await message.reply_text( - "Your connected group details ;\n\n", - reply_markup=InlineKeyboardMarkup(buttons), - quote=True - ) - else: - await message.reply_text( - "There are no active connections!! Connect to some groups first.", - quote=True - ) diff --git a/plugins/files_delete.py b/plugins/files_delete.py deleted file mode 100644 index 1fdcc7ba7..000000000 --- a/plugins/files_delete.py +++ /dev/null @@ -1,68 +0,0 @@ -import re -import logging -from pyrogram import Client, filters -from info import DELETE_CHANNELS -from database.ia_filterdb import Media, Media2, unpack_new_file_id - -logger = logging.getLogger(__name__) - -media_filter = filters.document | filters.video | filters.audio - - -@Client.on_message(filters.chat(DELETE_CHANNELS) & media_filter) -async def deletemultiplemedia(bot, message): - """Delete Multiple files from database""" - - for file_type in ("document", "video", "audio"): - media = getattr(message, file_type, None) - if media is not None: - break - else: - return - - file_id, file_ref = unpack_new_file_id(media.file_id) - if await Media.count_documents({'file_id': file_id}): - result = await Media.collection.delete_one({ - '_id': file_id, - }) - else: - result = await Media2.collection.delete_one({ - '_id': file_id, - }) - if result.deleted_count: - logger.info('File is successfully deleted from database.') - else: - file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name)) - result = await Media.collection.delete_many({ - 'file_name': file_name, - 'file_size': media.file_size, - 'mime_type': media.mime_type - }) - if result.deleted_count: - logger.info('File is successfully deleted from database.') - else: - result = await Media2.collection.delete_many({ - 'file_name': file_name, - 'file_size': media.file_size, - 'mime_type': media.mime_type - }) - if result.deleted_count: - logger.info('File is successfully deleted from database.') - else: - result = await Media.collection.delete_many({ - 'file_name': media.file_name, - 'file_size': media.file_size, - 'mime_type': media.mime_type - }) - if result.deleted_count: - logger.info('File is successfully deleted from database.') - else: - result = await Media2.collection.delete_many({ - 'file_name': media.file_name, - 'file_size': media.file_size, - 'mime_type': media.mime_type - }) - if result.deleted_count: - logger.info('File is successfully deleted from database.') - else: - logger.info('File not found in database.') \ No newline at end of file diff --git a/plugins/filters.py b/plugins/filters.py deleted file mode 100644 index 5ec914178..000000000 --- a/plugins/filters.py +++ /dev/null @@ -1,272 +0,0 @@ -import io -from pyrogram import filters, Client, enums -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup -from database.filters_mdb import( - add_filter, - get_filters, - delete_filter, - count_filters -) - -from database.connections_mdb import active_connection -from utils import get_file_id, parser, split_quotes -from info import ADMINS - - -@Client.on_message(filters.command(['filter', 'add']) & filters.incoming) -async def addfilter(client, message): - userid = message.from_user.id if message.from_user else None - if not userid: - return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") - chat_type = message.chat.type - args = message.text.html.split(None, 1) - - if chat_type == enums.ChatType.PRIVATE: - grpid = await active_connection(str(userid)) - if grpid is not None: - grp_id = grpid - try: - chat = await client.get_chat(grpid) - title = chat.title - except: - await message.reply_text("Make sure I'm present in your group!!", quote=True) - return - else: - await message.reply_text("I'm not connected to any groups!", quote=True) - return - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grp_id = message.chat.id - title = message.chat.title - - else: - return - - st = await client.get_chat_member(grp_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and str(userid) not in ADMINS - ): - return - - - if len(args) < 2: - await message.reply_text("Command Incomplete :(", quote=True) - return - - extracted = split_quotes(args[1]) - text = extracted[0].lower() - - if not message.reply_to_message and len(extracted) < 2: - await message.reply_text("Add some content to save your filter!", quote=True) - return - - if (len(extracted) >= 2) and not message.reply_to_message: - reply_text, btn, alert = parser(extracted[1], text) - fileid = None - if not reply_text: - await message.reply_text("You cannot have buttons alone, give some text to go with it!", quote=True) - return - - elif message.reply_to_message and message.reply_to_message.reply_markup: - try: - rm = message.reply_to_message.reply_markup - btn = rm.inline_keyboard - msg = get_file_id(message.reply_to_message) - if msg: - fileid = msg.file_id - reply_text = message.reply_to_message.caption.html - else: - reply_text = message.reply_to_message.text.html - fileid = None - alert = None - except: - reply_text = "" - btn = "[]" - fileid = None - alert = None - - elif message.reply_to_message and message.reply_to_message.media: - try: - msg = get_file_id(message.reply_to_message) - fileid = msg.file_id if msg else None - reply_text, btn, alert = parser(extracted[1], text) if message.reply_to_message.sticker else parser(message.reply_to_message.caption.html, text) - except: - reply_text = "" - btn = "[]" - alert = None - elif message.reply_to_message and message.reply_to_message.text: - try: - fileid = None - reply_text, btn, alert = parser(message.reply_to_message.text.html, text) - except: - reply_text = "" - btn = "[]" - alert = None - else: - return - - await add_filter(grp_id, text, reply_text, btn, fileid, alert) - - await message.reply_text( - f"Filter for `{text}` added in **{title}**", - quote=True, - parse_mode=enums.ParseMode.MARKDOWN - ) - - -@Client.on_message(filters.command(['viewfilters', 'filters']) & filters.incoming) -async def get_all(client, message): - - chat_type = message.chat.type - userid = message.from_user.id if message.from_user else None - if not userid: - return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") - if chat_type == enums.ChatType.PRIVATE: - userid = message.from_user.id - grpid = await active_connection(str(userid)) - if grpid is not None: - grp_id = grpid - try: - chat = await client.get_chat(grpid) - title = chat.title - except: - await message.reply_text("Make sure I'm present in your group!!", quote=True) - return - else: - await message.reply_text("I'm not connected to any groups!", quote=True) - return - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grp_id = message.chat.id - title = message.chat.title - - else: - return - - st = await client.get_chat_member(grp_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and str(userid) not in ADMINS - ): - return - - texts = await get_filters(grp_id) - count = await count_filters(grp_id) - if count: - filterlist = f"Total number of filters in **{title}** : {count}\n\n" - - for text in texts: - keywords = " × `{}`\n".format(text) - - filterlist += keywords - - if len(filterlist) > 4096: - with io.BytesIO(str.encode(filterlist.replace("`", ""))) as keyword_file: - keyword_file.name = "keywords.txt" - await message.reply_document( - document=keyword_file, - quote=True - ) - return - else: - filterlist = f"There are no active filters in **{title}**" - - await message.reply_text( - text=filterlist, - quote=True, - parse_mode=enums.ParseMode.MARKDOWN - ) - -@Client.on_message(filters.command('del') & filters.incoming) -async def deletefilter(client, message): - userid = message.from_user.id if message.from_user else None - if not userid: - return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") - chat_type = message.chat.type - - if chat_type == enums.ChatType.PRIVATE: - grpid = await active_connection(str(userid)) - if grpid is not None: - grp_id = grpid - try: - chat = await client.get_chat(grpid) - title = chat.title - except: - await message.reply_text("Make sure I'm present in your group!!", quote=True) - return - else: - await message.reply_text("I'm not connected to any groups!", quote=True) - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grp_id = message.chat.id - title = message.chat.title - - else: - return - - st = await client.get_chat_member(grp_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and str(userid) not in ADMINS - ): - return - - try: - cmd, text = message.text.split(" ", 1) - except: - await message.reply_text( - "Mention the filtername which you wanna delete!\n\n" - "/del filtername\n\n" - "Use /viewfilters to view all available filters", - quote=True - ) - return - - query = text.lower() - - await delete_filter(message, query, grp_id) - - -@Client.on_message(filters.command('delall') & filters.incoming) -async def delallconfirm(client, message): - userid = message.from_user.id if message.from_user else None - if not userid: - return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") - chat_type = message.chat.type - - if chat_type == enums.ChatType.PRIVATE: - grpid = await active_connection(str(userid)) - if grpid is not None: - grp_id = grpid - try: - chat = await client.get_chat(grpid) - title = chat.title - except: - await message.reply_text("Make sure I'm present in your group!!", quote=True) - return - else: - await message.reply_text("I'm not connected to any groups!", quote=True) - return - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grp_id = message.chat.id - title = message.chat.title - - else: - return - - st = await client.get_chat_member(grp_id, userid) - if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS): - await message.reply_text( - f"This will delete all filters from '{title}'.\nDo you want to continue??", - reply_markup=InlineKeyboardMarkup([ - [InlineKeyboardButton(text="YES",callback_data="delallconfirm")], - [InlineKeyboardButton(text="CANCEL",callback_data="delallcancel")] - ]), - quote=True - ) - diff --git a/plugins/genlink.py b/plugins/genlink.py deleted file mode 100644 index 35050ad46..000000000 --- a/plugins/genlink.py +++ /dev/null @@ -1,125 +0,0 @@ -import re -from pyrogram import filters, Client, enums -from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified -from info import ADMINS, LOG_CHANNEL, FILE_STORE_CHANNEL, PUBLIC_FILE_STORE -from database.ia_filterdb import unpack_new_file_id -from utils import temp -import re -import os -import json -import base64 -import logging - -logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) - -async def allowed(_, __, message): - if PUBLIC_FILE_STORE: - return True - if message.from_user and message.from_user.id in ADMINS: - return True - return False - -@Client.on_message(filters.command(['link', 'plink']) & filters.create(allowed)) -async def gen_link_s(bot, message): - replied = message.reply_to_message - if not replied: - return await message.reply('Reply to a message to get a shareable link.') - file_type = replied.media - if file_type not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: - return await message.reply("Reply to a supported media") - if message.has_protected_content and message.chat.id not in ADMINS: - return await message.reply("okDa") - file_id, ref = unpack_new_file_id((getattr(replied, file_type.value)).file_id) - string = 'filep_' if message.text.lower().strip() == "/plink" else 'file_' - string += file_id - outstr = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=") - await message.reply(f"Here is your Link:\nhttps://t.me/{temp.U_NAME}?start={outstr}") - - -@Client.on_message(filters.command(['batch', 'pbatch']) & filters.create(allowed)) -async def gen_link_batch(bot, message): - if " " not in message.text: - return await message.reply("Use correct format.\nExample /batch https://t.me/TeamEvamaria/10 https://t.me/TeamEvamaria/20.") - links = message.text.strip().split(" ") - if len(links) != 3: - return await message.reply("Use correct format.\nExample /batch https://t.me/TeamEvamaria/10 https://t.me/TeamEvamaria/20.") - cmd, first, last = links - regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") - match = regex.match(first) - if not match: - return await message.reply('Invalid link') - f_chat_id = match.group(4) - f_msg_id = int(match.group(5)) - if f_chat_id.isnumeric(): - f_chat_id = int(("-100" + f_chat_id)) - - match = regex.match(last) - if not match: - return await message.reply('Invalid link') - l_chat_id = match.group(4) - l_msg_id = int(match.group(5)) - if l_chat_id.isnumeric(): - l_chat_id = int(("-100" + l_chat_id)) - - if f_chat_id != l_chat_id: - return await message.reply("Chat ids not matched.") - try: - chat_id = (await bot.get_chat(f_chat_id)).id - except ChannelInvalid: - return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') - except (UsernameInvalid, UsernameNotModified): - return await message.reply('Invalid Link specified.') - except Exception as e: - return await message.reply(f'Errors - {e}') - - sts = await message.reply("Generating link for your message.\nThis may take time depending upon number of messages") - if chat_id in FILE_STORE_CHANNEL: - string = f"{f_msg_id}_{l_msg_id}_{chat_id}_{cmd.lower().strip()}" - b_64 = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=") - return await sts.edit(f"Here is your link https://t.me/{temp.U_NAME}?start=DSTORE-{b_64}") - - FRMT = "Generating Link...\nTotal Messages: `{total}`\nDone: `{current}`\nRemaining: `{rem}`\nStatus: `{sts}`" - - outlist = [] - - # file store without db channel - og_msg = 0 - tot = 0 - async for msg in bot.iter_messages(f_chat_id, l_msg_id, f_msg_id): - tot += 1 - if msg.empty or msg.service: - continue - if not msg.media: - # only media messages supported. - continue - try: - file_type = msg.media - file = getattr(msg, file_type.value) - caption = getattr(msg, 'caption', '') - if caption: - caption = caption.html - if file: - file = { - "file_id": file.file_id, - "caption": caption, - "title": getattr(file, "file_name", ""), - "size": file.file_size, - "protect": cmd.lower().strip() == "/pbatch", - } - - og_msg +=1 - outlist.append(file) - except: - pass - if not og_msg % 20: - try: - await sts.edit(FRMT.format(total=l_msg_id-f_msg_id, current=tot, rem=((l_msg_id-f_msg_id) - tot), sts="Saving Messages")) - except: - pass - with open(f"batchmode_{message.from_user.id}.json", "w+") as out: - json.dump(outlist, out) - post = await bot.send_document(LOG_CHANNEL, f"batchmode_{message.from_user.id}.json", file_name="Batch.json", caption="⚠️Generated for filestore.") - os.remove(f"batchmode_{message.from_user.id}.json") - file_id, ref = unpack_new_file_id(post.document.file_id) - await sts.edit(f"Here is your link\nContains `{og_msg}` files.\n https://t.me/{temp.U_NAME}?start=BATCH-{file_id}") diff --git a/plugins/gfilters.py b/plugins/gfilters.py deleted file mode 100644 index f1de56312..000000000 --- a/plugins/gfilters.py +++ /dev/null @@ -1,140 +0,0 @@ -import io -from pyrogram import filters, Client, enums -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup -from database.gfilters_mdb import( - add_gfilter, - get_gfilters, - delete_gfilter, - count_gfilters -) - -from database.connections_mdb import active_connection -from utils import get_file_id, gfilterparser, split_quotes -from info import ADMINS - - -@Client.on_message(filters.command(['gfilter', 'addg']) & filters.incoming & filters.user(ADMINS)) -async def addgfilter(client, message): - args = message.text.html.split(None, 1) - - if len(args) < 2: - await message.reply_text("Command Incomplete :(", quote=True) - return - - extracted = split_quotes(args[1]) - text = extracted[0].lower() - - if not message.reply_to_message and len(extracted) < 2: - await message.reply_text("Add some content to save your filter!", quote=True) - return - - if (len(extracted) >= 2) and not message.reply_to_message: - reply_text, btn, alert = gfilterparser(extracted[1], text) - fileid = None - if not reply_text: - await message.reply_text("You cannot have buttons alone, give some text to go with it!", quote=True) - return - - elif message.reply_to_message and message.reply_to_message.reply_markup: - try: - rm = message.reply_to_message.reply_markup - btn = rm.inline_keyboard - msg = get_file_id(message.reply_to_message) - if msg: - fileid = msg.file_id - reply_text = message.reply_to_message.caption.html - else: - reply_text = message.reply_to_message.text.html - fileid = None - alert = None - except: - reply_text = "" - btn = "[]" - fileid = None - alert = None - - elif message.reply_to_message and message.reply_to_message.media: - try: - msg = get_file_id(message.reply_to_message) - fileid = msg.file_id if msg else None - reply_text, btn, alert = gfilterparser(extracted[1], text) if message.reply_to_message.sticker else gfilterparser(message.reply_to_message.caption.html, text) - except: - reply_text = "" - btn = "[]" - alert = None - elif message.reply_to_message and message.reply_to_message.text: - try: - fileid = None - reply_text, btn, alert = gfilterparser(message.reply_to_message.text.html, text) - except: - reply_text = "" - btn = "[]" - alert = None - else: - return - - await add_gfilter('gfilters', text, reply_text, btn, fileid, alert) - - await message.reply_text( - f"GFilter for `{text}` added", - quote=True, - parse_mode=enums.ParseMode.MARKDOWN - ) - - -@Client.on_message(filters.command(['viewgfilters', 'gfilters']) & filters.incoming & filters.user(ADMINS)) -async def get_all_gfilters(client, message): - texts = await get_gfilters('gfilters') - count = await count_gfilters('gfilters') - if count: - gfilterlist = f"Total number of gfilters : {count}\n\n" - - for text in texts: - keywords = " × `{}`\n".format(text) - - gfilterlist += keywords - - if len(gfilterlist) > 4096: - with io.BytesIO(str.encode(gfilterlist.replace("`", ""))) as keyword_file: - keyword_file.name = "keywords.txt" - await message.reply_document( - document=keyword_file, - quote=True - ) - return - else: - gfilterlist = f"There are no active gfilters." - - await message.reply_text( - text=gfilterlist, - quote=True, - parse_mode=enums.ParseMode.MARKDOWN - ) - -@Client.on_message(filters.command('delg') & filters.incoming & filters.user(ADMINS)) -async def deletegfilter(client, message): - try: - cmd, text = message.text.split(" ", 1) - except: - await message.reply_text( - "Mention the gfiltername which you wanna delete!\n\n" - "/delg gfiltername\n\n" - "Use /viewgfilters to view all available gfilters", - quote=True - ) - return - - query = text.lower() - - await delete_gfilter(message, query, 'gfilters') - -@Client.on_message(filters.command('delallg') & filters.user(ADMINS)) -async def delallgfilters(client, message): - await message.reply_text( - f"Do you want to continue??", - reply_markup=InlineKeyboardMarkup([ - [InlineKeyboardButton(text="YES",callback_data="gfiltersdeleteallconfirm")], - [InlineKeyboardButton(text="CANCEL",callback_data="gfiltersdeleteallcancel")] - ]), - quote=True - ) diff --git a/plugins/index.py b/plugins/index.py deleted file mode 100644 index df5cf1004..000000000 --- a/plugins/index.py +++ /dev/null @@ -1,185 +0,0 @@ -import logging -import asyncio -from pyrogram import Client, filters, enums -from pyrogram.errors import FloodWait -from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, ChatAdminRequired, UsernameInvalid, UsernameNotModified -from info import ADMINS -from info import INDEX_REQ_CHANNEL as LOG_CHANNEL -from database.ia_filterdb import save_file -from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton -from utils import temp -import re -logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) -lock = asyncio.Lock() - - -@Client.on_callback_query(filters.regex(r'^index')) -async def index_files(bot, query): - if query.data.startswith('index_cancel'): - temp.CANCEL = True - return await query.answer("Cancelling Indexing") - _, raju, chat, lst_msg_id, from_user = query.data.split("#") - if raju == 'reject': - await query.message.delete() - await bot.send_message(int(from_user), - f'Your Submission for indexing {chat} has been decliened by our moderators.', - reply_to_message_id=int(lst_msg_id)) - return - - if lock.locked(): - return await query.answer('Wait until previous process complete.', show_alert=True) - msg = query.message - - await query.answer('Processing...⏳', show_alert=True) - if int(from_user) not in ADMINS: - await bot.send_message(int(from_user), - f'Your Submission for indexing {chat} has been accepted by our moderators and will be added soon.', - reply_to_message_id=int(lst_msg_id)) - await msg.edit( - "Starting Indexing", - reply_markup=InlineKeyboardMarkup( - [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]] - ) - ) - try: - chat = int(chat) - except: - chat = chat - await index_files_to_db(int(lst_msg_id), chat, msg, bot) - - -@Client.on_message((filters.forwarded | (filters.regex("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")) & filters.text ) & filters.private & filters.incoming) -async def send_for_index(bot, message): - if message.text: - regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") - match = regex.match(message.text) - if not match: - return await message.reply('Invalid link') - chat_id = match.group(4) - last_msg_id = int(match.group(5)) - if chat_id.isnumeric(): - chat_id = int(("-100" + chat_id)) - elif message.forward_from_chat.type == enums.ChatType.CHANNEL: - last_msg_id = message.forward_from_message_id - chat_id = message.forward_from_chat.username or message.forward_from_chat.id - else: - return - try: - await bot.get_chat(chat_id) - except ChannelInvalid: - return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') - except (UsernameInvalid, UsernameNotModified): - return await message.reply('Invalid Link specified.') - except Exception as e: - logger.exception(e) - return await message.reply(f'Errors - {e}') - try: - k = await bot.get_messages(chat_id, last_msg_id) - except: - return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private') - if k.empty: - return await message.reply('This may be group and iam not a admin of the group.') - - if message.from_user.id in ADMINS: - buttons = [ - [ - InlineKeyboardButton('Yes', - callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}') - ], - [ - InlineKeyboardButton('close', callback_data='close_data'), - ] - ] - reply_markup = InlineKeyboardMarkup(buttons) - return await message.reply( - f'Do you Want To Index This Channel/ Group ?\n\nChat ID/ Username: {chat_id}\nLast Message ID: {last_msg_id}', - reply_markup=reply_markup) - - if type(chat_id) is int: - try: - link = (await bot.create_chat_invite_link(chat_id)).invite_link - except ChatAdminRequired: - return await message.reply('Make sure iam an admin in the chat and have permission to invite users.') - else: - link = f"@{message.forward_from_chat.username}" - buttons = [ - [ - InlineKeyboardButton('Accept Index', - callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}') - ], - [ - InlineKeyboardButton('Reject Index', - callback_data=f'index#reject#{chat_id}#{message.id}#{message.from_user.id}'), - ] - ] - reply_markup = InlineKeyboardMarkup(buttons) - await bot.send_message(LOG_CHANNEL, - f'#IndexRequest\n\nBy : {message.from_user.mention} ({message.from_user.id})\nChat ID/ Username - {chat_id}\nLast Message ID - {last_msg_id}\nInviteLink - {link}', - reply_markup=reply_markup) - await message.reply('ThankYou For the Contribution, Wait For My Moderators to verify the files.') - - -@Client.on_message(filters.command('setskip') & filters.user(ADMINS)) -async def set_skip_number(bot, message): - if ' ' in message.text: - _, skip = message.text.split(" ") - try: - skip = int(skip) - except: - return await message.reply("Skip number should be an integer.") - await message.reply(f"Successfully set SKIP number as {skip}") - temp.CURRENT = int(skip) - else: - await message.reply("Give me a skip number") - - -async def index_files_to_db(lst_msg_id, chat, msg, bot): - total_files = 0 - duplicate = 0 - errors = 0 - deleted = 0 - no_media = 0 - unsupported = 0 - async with lock: - try: - current = temp.CURRENT - temp.CANCEL = False - async for message in bot.iter_messages(chat, lst_msg_id, temp.CURRENT): - if temp.CANCEL: - await msg.edit(f"Successfully Cancelled!!\n\nSaved {total_files} files to dataBase!\nDuplicate Files Skipped: {duplicate}\nDeleted Messages Skipped: {deleted}\nNon-Media messages skipped: {no_media + unsupported}(Unsupported Media - `{unsupported}` )\nErrors Occurred: {errors}") - break - current += 1 - if current % 20 == 0: - can = [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]] - reply = InlineKeyboardMarkup(can) - await msg.edit_text( - text=f"Total messages fetched: {current}\nTotal messages saved: {total_files}\nDuplicate Files Skipped: {duplicate}\nDeleted Messages Skipped: {deleted}\nNon-Media messages skipped: {no_media + unsupported}(Unsupported Media - `{unsupported}` )\nErrors Occurred: {errors}", - reply_markup=reply) - if message.empty: - deleted += 1 - continue - elif not message.media: - no_media += 1 - continue - elif message.media not in [enums.MessageMediaType.VIDEO, enums.MessageMediaType.AUDIO, enums.MessageMediaType.DOCUMENT]: - unsupported += 1 - continue - media = getattr(message, message.media.value, None) - if not media: - unsupported += 1 - continue - media.file_type = message.media.value - media.caption = message.caption - aynav, vnay = await save_file(media) - if aynav: - total_files += 1 - elif vnay == 0: - duplicate += 1 - elif vnay == 2: - errors += 1 - except Exception as e: - logger.exception(e) - await msg.edit(f'Error: {e}') - else: - await msg.edit(f'Succesfully saved {total_files} to dataBase!\nDuplicate Files Skipped: {duplicate}\nDeleted Messages Skipped: {deleted}\nNon-Media messages skipped: {no_media + unsupported}(Unsupported Media - `{unsupported}` )\nErrors Occurred: {errors}') diff --git a/plugins/inline.py b/plugins/inline.py deleted file mode 100644 index 67dd81f31..000000000 --- a/plugins/inline.py +++ /dev/null @@ -1,118 +0,0 @@ -import logging -from pyrogram import Client, emoji, filters -from pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultCachedDocument, InlineQuery -from database.ia_filterdb import get_search_results -from utils import is_subscribed, get_size, temp -from info import CACHE_TIME, AUTH_USERS, AUTH_CHANNEL, CUSTOM_FILE_CAPTION -from database.connections_mdb import active_connection - -logger = logging.getLogger(__name__) -cache_time = 0 if AUTH_USERS or AUTH_CHANNEL else CACHE_TIME - -async def inline_users(query: InlineQuery): - if AUTH_USERS: - if query.from_user and query.from_user.id in AUTH_USERS: - return True - else: - return False - if query.from_user and query.from_user.id not in temp.BANNED_USERS: - return True - return False - -@Client.on_inline_query() -async def answer(bot, query): - """Show search results for given inline query""" - chat_id = await active_connection(str(query.from_user.id)) - - if not await inline_users(query): - await query.answer(results=[], - cache_time=0, - switch_pm_text='okDa', - switch_pm_parameter="hehe") - return - - invite_links = await is_subscribed(bot, query=query) - if AUTH_CHANNEL and len(invite_links) >= 1: - await query.answer(results=[], - cache_time=0, - switch_pm_text='You have to subscribe my channel to use the bot', - switch_pm_parameter="subscribe") - return - - results = [] - if '|' in query.query: - string, file_type = query.query.split('|', maxsplit=1) - string = string.strip() - file_type = file_type.strip().lower() - else: - string = query.query.strip() - file_type = None - - offset = int(query.offset or 0) - reply_markup = get_reply_markup(query=string) - files, next_offset, total = await get_search_results( - chat_id, - string, - file_type=file_type, - max_results=10, - offset=offset) - - for file in files: - title=file.file_name - size=get_size(file.file_size) - f_caption=file.caption - if CUSTOM_FILE_CAPTION: - try: - f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption) - except Exception as e: - logger.exception(e) - f_caption=f_caption - if f_caption is None: - f_caption = f"{file.file_name}" - results.append( - InlineQueryResultCachedDocument( - title=file.file_name, - document_file_id=file.file_id, - caption=f_caption, - description=f'Size: {get_size(file.file_size)}\nType: {file.file_type}', - reply_markup=reply_markup)) - - if results: - switch_pm_text = f"{emoji.FILE_FOLDER} Results - {total}" - if string: - switch_pm_text += f" for {string}" - try: - await query.answer(results=results, - is_personal = True, - cache_time=cache_time, - switch_pm_text=switch_pm_text, - switch_pm_parameter="start", - next_offset=str(next_offset)) - except QueryIdInvalid: - pass - except Exception as e: - logging.exception(str(e)) - else: - switch_pm_text = f'{emoji.CROSS_MARK} No results' - if string: - switch_pm_text += f' for "{string}"' - - await query.answer(results=[], - is_personal = True, - cache_time=cache_time, - switch_pm_text=switch_pm_text, - switch_pm_parameter="okay") - - -def get_reply_markup(query): - buttons = [ - [ - InlineKeyboardButton('Search again', switch_inline_query_current_chat=query) - ] - ] - return InlineKeyboardMarkup(buttons) - - - - diff --git a/plugins/misc.py b/plugins/misc.py deleted file mode 100644 index 40954a873..000000000 --- a/plugins/misc.py +++ /dev/null @@ -1,214 +0,0 @@ -import os -from pyrogram import Client, filters, enums -from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant, MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty -from info import IMDB_TEMPLATE -from utils import extract_user, get_file_id, get_poster, last_online -import time -from datetime import datetime -from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery -import logging -logger = logging.getLogger(__name__) -logger.setLevel(logging.ERROR) - -@Client.on_message(filters.command('id')) -async def showid(client, message): - chat_type = message.chat.type - if chat_type == enums.ChatType.PRIVATE: - user_id = message.chat.id - first = message.from_user.first_name - last = message.from_user.last_name or "" - username = message.from_user.username - dc_id = message.from_user.dc_id or "" - await message.reply_text( - f"➲ First Name: {first}\n➲ Last Name: {last}\n➲ Username: {username}\n➲ Telegram ID: {user_id}\n➲ Data Centre: {dc_id}", - quote=True - ) - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - _id = "" - _id += ( - "➲ Chat ID: " - f"{message.chat.id}\n" - ) - if message.reply_to_message: - _id += ( - "➲ User ID: " - f"{message.from_user.id if message.from_user else 'Anonymous'}\n" - "➲ Replied User ID: " - f"{message.reply_to_message.from_user.id if message.reply_to_message.from_user else 'Anonymous'}\n" - ) - file_info = get_file_id(message.reply_to_message) - else: - _id += ( - "➲ User ID: " - f"{message.from_user.id if message.from_user else 'Anonymous'}\n" - ) - file_info = get_file_id(message) - if file_info: - _id += ( - f"{file_info.message_type}: " - f"{file_info.file_id}\n" - ) - await message.reply_text( - _id, - quote=True - ) - -@Client.on_message(filters.command(["info"])) -async def who_is(client, message): - # https://github.com/SpEcHiDe/PyroGramBot/blob/master/pyrobot/plugins/admemes/whois.py#L19 - status_message = await message.reply_text( - "`Fetching user info...`" - ) - await status_message.edit( - "`Processing user info...`" - ) - from_user = None - from_user_id, _ = extract_user(message) - try: - from_user = await client.get_users(from_user_id) - except Exception as error: - await status_message.edit(str(error)) - return - if from_user is None: - return await status_message.edit("no valid user_id / message specified") - message_out_str = "" - message_out_str += f"➲First Name: {from_user.first_name}\n" - last_name = from_user.last_name or "None" - message_out_str += f"➲Last Name: {last_name}\n" - message_out_str += f"➲Telegram ID: {from_user.id}\n" - username = from_user.username or "None" - dc_id = from_user.dc_id or "[User Doesn't Have A Valid DP]" - message_out_str += f"➲Data Centre: {dc_id}\n" - message_out_str += f"➲User Name: @{username}\n" - message_out_str += f"➲User 𝖫𝗂𝗇𝗄: Click Here\n" - if message.chat.type in ((enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL)): - try: - chat_member_p = await message.chat.get_member(from_user.id) - joined_date = ( - chat_member_p.joined_date or datetime.now() - ).strftime("%Y.%m.%d %H:%M:%S") - message_out_str += ( - "➲Joined this Chat on: " - f"{joined_date}" - "\n" - ) - except UserNotParticipant: - pass - chat_photo = from_user.photo - if chat_photo: - local_user_photo = await client.download_media( - message=chat_photo.big_file_id - ) - buttons = [[ - InlineKeyboardButton('🔐 Close', callback_data='close_data') - ]] - reply_markup = InlineKeyboardMarkup(buttons) - await message.reply_photo( - photo=local_user_photo, - quote=True, - reply_markup=reply_markup, - caption=message_out_str, - parse_mode=enums.ParseMode.HTML, - disable_notification=True - ) - os.remove(local_user_photo) - else: - buttons = [[ - InlineKeyboardButton('🔐 Close', callback_data='close_data') - ]] - reply_markup = InlineKeyboardMarkup(buttons) - await message.reply_text( - text=message_out_str, - reply_markup=reply_markup, - quote=True, - parse_mode=enums.ParseMode.HTML, - disable_notification=True - ) - await status_message.delete() - -@Client.on_message(filters.command(["imdb", 'search'])) -async def imdb_search(client, message): - if ' ' in message.text: - k = await message.reply('Searching ImDB') - r, title = message.text.split(None, 1) - movies = await get_poster(title, bulk=True) - if not movies: - return await message.reply("No results Found") - btn = [ - [ - InlineKeyboardButton( - text=f"{movie.get('title')} - {movie.get('year')}", - callback_data=f"imdb#{movie.movieID}", - ) - ] - for movie in movies - ] - await k.edit('Here is what i found on IMDb', reply_markup=InlineKeyboardMarkup(btn)) - else: - await message.reply('Give me a movie / series Name') - -@Client.on_callback_query(filters.regex('^imdb')) -async def imdb_callback(bot: Client, quer_y: CallbackQuery): - i, movie = quer_y.data.split('#') - imdb = await get_poster(query=movie, id=True) - btn = [ - [ - InlineKeyboardButton( - text=f"{imdb.get('title')}", - url=imdb['url'], - ) - ] - ] - message = quer_y.message.reply_to_message or quer_y.message - if imdb: - caption = IMDB_TEMPLATE.format( - query = imdb['title'], - title = imdb['title'], - votes = imdb['votes'], - aka = imdb["aka"], - seasons = imdb["seasons"], - box_office = imdb['box_office'], - localized_title = imdb['localized_title'], - kind = imdb['kind'], - imdb_id = imdb["imdb_id"], - cast = imdb["cast"], - runtime = imdb["runtime"], - countries = imdb["countries"], - certificates = imdb["certificates"], - languages = imdb["languages"], - director = imdb["director"], - writer = imdb["writer"], - producer = imdb["producer"], - composer = imdb["composer"], - cinematographer = imdb["cinematographer"], - music_team = imdb["music_team"], - distributors = imdb["distributors"], - release_date = imdb['release_date'], - year = imdb['year'], - genres = imdb['genres'], - poster = imdb['poster'], - plot = imdb['plot'], - rating = imdb['rating'], - url = imdb['url'], - **locals() - ) - else: - caption = "No Results" - if imdb.get('poster'): - try: - await quer_y.message.reply_photo(photo=imdb['poster'], caption=caption, reply_markup=InlineKeyboardMarkup(btn)) - except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty): - pic = imdb.get('poster') - poster = pic.replace('.jpg', "._V1_UX360.jpg") - await quer_y.message.reply_photo(photo=poster, caption=caption, reply_markup=InlineKeyboardMarkup(btn)) - except Exception as e: - logger.exception(e) - await quer_y.message.reply(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False) - await quer_y.message.delete() - else: - await quer_y.message.edit(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False) - await quer_y.answer() - - - diff --git a/plugins/p_ttishow.py b/plugins/p_ttishow.py deleted file mode 100644 index 5d7e45d94..000000000 --- a/plugins/p_ttishow.py +++ /dev/null @@ -1,298 +0,0 @@ -from pyrogram import Client, filters, enums -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery -from pyrogram.errors.exceptions.bad_request_400 import MessageTooLong, PeerIdInvalid -from info import ADMINS, LOG_CHANNEL, SUPPORT_CHAT, MELCOW_NEW_USERS, MELCOW_VID, CHNL_LNK, GRP_LNK -from database.users_chats_db import db -from database.ia_filterdb import Media, Media2, db as clientDB, db2 as clientDB2 -from utils import get_size, temp, get_settings -from Script import script -from pyrogram.errors import ChatAdminRequired -import asyncio - -"""-----------------------------------------https://t.me/GetTGLink/4179 --------------------------------------""" - -@Client.on_message(filters.new_chat_members & filters.group) -async def save_group(bot, message): - r_j_check = [u.id for u in message.new_chat_members] - if temp.ME in r_j_check: - if not await db.get_chat(message.chat.id): - total=await bot.get_chat_members_count(message.chat.id) - r_j = message.from_user.mention if message.from_user else "Anonymous" - await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, r_j)) - await db.add_chat(message.chat.id, message.chat.title) - if message.chat.id in temp.BANNED_CHATS: - # Inspired from a boat of a banana tree - buttons = [[ - InlineKeyboardButton('Support', url=f'https://t.me/{SUPPORT_CHAT}') - ]] - reply_markup=InlineKeyboardMarkup(buttons) - k = await message.reply( - text='CHAT NOT ALLOWED 🐞\n\nMy admins has restricted me from working here ! If you want to know more about it contact support..', - reply_markup=reply_markup, - ) - - try: - await k.pin() - except: - pass - await bot.leave_chat(message.chat.id) - return - buttons = [[ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) - ],[ - InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/creatorbeatz") - ]] - reply_markup=InlineKeyboardMarkup(buttons) - await message.reply_text( - text=f"Thankyou For Adding Me In {message.chat.title} ❣️\n\nIf you have any questions & doubts about using me contact support.", - reply_markup=reply_markup) - else: - settings = await get_settings(message.chat.id) - if settings["welcome"]: - for u in message.new_chat_members: - if (temp.MELCOW).get('welcome') is not None: - try: - await (temp.MELCOW['welcome']).delete() - except: - pass - temp.MELCOW['welcome'] = await message.reply_video( - video=(MELCOW_VID), - caption=(script.MELCOW_ENG.format(u.mention, message.chat.title)), - reply_markup=InlineKeyboardMarkup( - [[ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) - ],[ - InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/creatorbeatz") - ]] - ), - parse_mode=enums.ParseMode.HTML - ) - - if settings["auto_delete"]: - await asyncio.sleep(600) - await (temp.MELCOW['welcome']).delete() - - - - - -@Client.on_message(filters.command('leave') & filters.user(ADMINS)) -async def leave_a_chat(bot, message): - if len(message.command) == 1: - return await message.reply('Give me a chat id') - chat = message.command[1] - try: - chat = int(chat) - except: - chat = chat - try: - buttons = [[ - InlineKeyboardButton('Support', url=f'https://t.me/{SUPPORT_CHAT}') - ]] - reply_markup=InlineKeyboardMarkup(buttons) - await bot.send_message( - chat_id=chat, - text='Hello Friends, \nMy admin has told me to leave from group so i go! If you wanna add me again contact my support group.', - reply_markup=reply_markup, - ) - - await bot.leave_chat(chat) - await message.reply(f"left the chat `{chat}`") - except Exception as e: - await message.reply(f'Error - {e}') - -@Client.on_message(filters.command('disable') & filters.user(ADMINS)) -async def disable_chat(bot, message): - if len(message.command) == 1: - return await message.reply('Give me a chat id') - r = message.text.split(None) - if len(r) > 2: - reason = message.text.split(None, 2)[2] - chat = message.text.split(None, 2)[1] - else: - chat = message.command[1] - reason = "No reason Provided" - try: - chat_ = int(chat) - except: - return await message.reply('Give Me A Valid Chat ID') - cha_t = await db.get_chat(int(chat_)) - if not cha_t: - return await message.reply("Chat Not Found In DB") - if cha_t['is_disabled']: - return await message.reply(f"This chat is already disabled:\nReason- {cha_t['reason']} ") - await db.disable_chat(int(chat_), reason) - temp.BANNED_CHATS.append(int(chat_)) - await message.reply('Chat Successfully Disabled') - try: - buttons = [[ - InlineKeyboardButton('Support', url=f'https://t.me/{SUPPORT_CHAT}') - ]] - reply_markup=InlineKeyboardMarkup(buttons) - await bot.send_message( - chat_id=chat_, - text=f'Hello Friends, \nMy admin has told me to leave from group so i go! If you wanna add me again contact my support group. \nReason : {reason}', - reply_markup=reply_markup) - await bot.leave_chat(chat_) - except Exception as e: - await message.reply(f"Error - {e}") - - -@Client.on_message(filters.command('enable') & filters.user(ADMINS)) -async def re_enable_chat(bot, message): - if len(message.command) == 1: - return await message.reply('Give me a chat id') - chat = message.command[1] - try: - chat_ = int(chat) - except: - return await message.reply('Give Me A Valid Chat ID') - sts = await db.get_chat(int(chat)) - if not sts: - return await message.reply("Chat Not Found In DB !") - if not sts.get('is_disabled'): - return await message.reply('This chat is not yet disabled.') - await db.re_enable_chat(int(chat_)) - temp.BANNED_CHATS.remove(int(chat_)) - await message.reply("Chat Successfully re-enabled") - -@Client.on_message(filters.command('stats') & filters.incoming) -async def get_ststs(bot, message): - rju = await message.reply('Fetching stats..') - #users and chats - total_users = await db.total_users_count() - totl_chats = await db.total_chat_count() - #primary db - filesp = await Media.count_documents() - #secondary db - totalsec = await Media2.count_documents() - #primary - stats = await clientDB.command('dbStats') - used_dbSize = (stats['dataSize']/(1024*1024))+(stats['indexSize']/(1024*1024)) - free_dbSize = 512-used_dbSize - #secondary - stats2 = await clientDB2.command('dbStats') - used_dbSize2 = (stats2['dataSize']/(1024*1024))+(stats2['indexSize']/(1024*1024)) - free_dbSize2 = 512-used_dbSize2 - await rju.edit(script.STATUS_TXT.format((int(filesp)+int(totalsec)), total_users, totl_chats, filesp, round(used_dbSize, 2), round(free_dbSize, 2), totalsec, round(used_dbSize2, 2), round(free_dbSize2, 2))) - -@Client.on_message(filters.command('invite') & filters.user(ADMINS)) -async def gen_invite(bot, message): - if len(message.command) == 1: - return await message.reply('Give me a chat id') - chat = message.command[1] - try: - chat = int(chat) - except: - return await message.reply('Give Me A Valid Chat ID') - try: - link = await bot.create_chat_invite_link(chat) - except ChatAdminRequired: - return await message.reply("Invite Link Generation Failed, Iam Not Having Sufficient Rights") - except Exception as e: - return await message.reply(f'Error {e}') - await message.reply(f'Here is your Invite Link {link.invite_link}') - -@Client.on_message(filters.command('ban') & filters.user(ADMINS)) -async def ban_a_user(bot, message): - # https://t.me/GetTGLink/4185 - if len(message.command) == 1: - return await message.reply('Give me a user id / username') - r = message.text.split(None) - if len(r) > 2: - reason = message.text.split(None, 2)[2] - chat = message.text.split(None, 2)[1] - else: - chat = message.command[1] - reason = "No reason Provided" - try: - chat = int(chat) - except: - pass - try: - k = await bot.get_users(chat) - except PeerIdInvalid: - return await message.reply("This is an invalid user, make sure ia have met him before.") - except IndexError: - return await message.reply("This might be a channel, make sure its a user.") - except Exception as e: - return await message.reply(f'Error - {e}') - else: - jar = await db.get_ban_status(k.id) - if jar['is_banned']: - return await message.reply(f"{k.mention} is already banned\nReason: {jar['ban_reason']}") - await db.ban_user(k.id, reason) - temp.BANNED_USERS.append(k.id) - await message.reply(f"Successfully banned {k.mention}") - - - -@Client.on_message(filters.command('unban') & filters.user(ADMINS)) -async def unban_a_user(bot, message): - if len(message.command) == 1: - return await message.reply('Give me a user id / username') - r = message.text.split(None) - if len(r) > 2: - reason = message.text.split(None, 2)[2] - chat = message.text.split(None, 2)[1] - else: - chat = message.command[1] - reason = "No reason Provided" - try: - chat = int(chat) - except: - pass - try: - k = await bot.get_users(chat) - except PeerIdInvalid: - return await message.reply("This is an invalid user, make sure ia have met him before.") - except IndexError: - return await message.reply("Thismight be a channel, make sure its a user.") - except Exception as e: - return await message.reply(f'Error - {e}') - else: - jar = await db.get_ban_status(k.id) - if not jar['is_banned']: - return await message.reply(f"{k.mention} is not yet banned.") - await db.remove_ban(k.id) - temp.BANNED_USERS.remove(k.id) - await message.reply(f"Successfully unbanned {k.mention}") - - - -@Client.on_message(filters.command('users') & filters.user(ADMINS)) -async def list_users(bot, message): - # https://t.me/GetTGLink/4184 - raju = await message.reply('Getting List Of Users') - users = await db.get_all_users() - out = "Users Saved In DB Are:\n\n" - for user in users: - out += f"{user['name']}" - if user['ban_status']['is_banned']: - out += '( Banned User )' - out += '\n' - try: - await raju.edit_text(out) - except MessageTooLong: - with open('users.txt', 'w+') as outfile: - outfile.write(out) - await message.reply_document('users.txt', caption="List Of Users") - -@Client.on_message(filters.command('chats') & filters.user(ADMINS)) -async def list_chats(bot, message): - raju = await message.reply('Getting List Of chats') - chats = await db.get_all_chats() - out = "Chats Saved In DB Are:\n\n" - for chat in chats: - out += f"**Title:** `{chat['title']}`\n**- ID:** `{chat['id']}`" - if chat['chat_status']['is_disabled']: - out += '( Disabled Chat )' - out += '\n' - try: - await raju.edit_text(out) - except MessageTooLong: - with open('chats.txt', 'w+') as outfile: - outfile.write(out) - await message.reply_document('chats.txt', caption="List Of Chats") diff --git a/plugins/pm_filter.py b/plugins/pm_filter.py deleted file mode 100644 index 6e81f931f..000000000 --- a/plugins/pm_filter.py +++ /dev/null @@ -1,1953 +0,0 @@ -# Kanged From @TroJanZheX -import asyncio -import re -import ast -import math -import random -import pyrogram -lock = asyncio.Lock() - -from pyrogram.errors.exceptions.bad_request_400 import MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty -from Script import script -from database.connections_mdb import active_connection, all_connections, delete_connection, if_active, make_active, \ - make_inactive -from info import ADMINS, AUTH_CHANNEL, AUTH_USERS, SUPPORT_CHAT_ID, CUSTOM_FILE_CAPTION, MSG_ALRT, PICS, GRP_LNK, CHNL_LNK, NOR_IMG, LOG_CHANNEL, SPELL_IMG, MAX_B_TN, \ - NO_RESULTS_MSG, IS_VERIFY, HOW_TO_VERIFY -from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InputMediaPhoto -from pyrogram import Client, filters, enums -from pyrogram.errors import UserIsBlocked, MessageNotModified, PeerIdInvalid -from utils import get_size, is_subscribed, get_poster, temp, get_settings, save_group_settings, get_shortlink, send_all, check_verification, get_token -from database.users_chats_db import db -from database.ia_filterdb import Media, Media2, get_file_details, get_search_results, get_bad_files, db as clientDB, db2 as clientDB2 -from database.filters_mdb import ( - del_all, - find_filter, - get_filters, -) -from database.gfilters_mdb import ( - find_gfilter, - get_gfilters, - del_allg -) -import logging - -logger = logging.getLogger(__name__) -logger.setLevel(logging.ERROR) - -BUTTONS = {} -SPELL_CHECK = {} - -@Client.on_message(filters.group & filters.text & filters.incoming) -async def give_filter(client, message): - if message.chat.id != SUPPORT_CHAT_ID: - glob = await global_filters(client, message) - manual = await manual_filters(client, message) - settings = await get_settings(message.chat.id) - if settings.get('auto_ffilter', None): - await auto_filter(client, message) - else: - await asyncio.sleep(600) - if glob: - await glob.delete() - if manual: - await manual.delete() - else: #a better logic to avoid repeated lines of code in auto_filter function - search = message.text - temp_files, temp_offset, total_results = await get_search_results(chat_id=message.chat.id, query=search.lower(), offset=0, filter=True) - if total_results == 0: - return - else: - return await message.reply_text( - text=f"Hᴇʏ {message.from_user.mention}, {str(total_results)} ʀᴇsᴜʟᴛs ᴀʀᴇ ғᴏᴜɴᴅ ɪɴ ᴍʏ ᴅᴀᴛᴀʙᴀsᴇ ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {search}. Kɪɴᴅʟʏ ᴜsᴇ ɪɴʟɪɴᴇ sᴇᴀʀᴄʜ ᴏʀ ᴍᴀᴋᴇ ᴀ ɢʀᴏᴜᴘ ᴀɴᴅ ᴀᴅᴅ ᴍᴇ ᴀs ᴀᴅᴍɪɴ ᴛᴏ ɢᴇᴛ ᴍᴏᴠɪᴇ ғɪʟᴇs. Tʜɪs ɪs ᴀ sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ sᴏ ᴛʜᴀᴛ ʏᴏᴜ ᴄᴀɴ'ᴛ ɢᴇᴛ ғɪʟᴇs ғʀᴏᴍ ʜᴇʀᴇ...\n\nFᴏʀ Mᴏᴠɪᴇs, Jᴏɪɴ @free_movies_all_languages", - parse_mode=enums.ParseMode.HTML - ) - -@Client.on_message(filters.private & filters.text & filters.incoming) -async def pm_text(bot, message): - content = message.text - user = message.from_user.first_name - user_id = message.from_user.id - if content.startswith("/") or content.startswith("#"): return # ignore commands and hashtags - if user_id in ADMINS: return # ignore admins - await message.reply_text("Yᴏᴜʀ ᴍᴇssᴀɢᴇ ʜᴀs ʙᴇᴇɴ sᴇɴᴛ ᴛᴏ ᴍʏ ᴍᴏᴅᴇʀᴀᴛᴏʀs !") - await bot.send_message( - chat_id=LOG_CHANNEL, - text=f"#𝐏𝐌_𝐌𝐒𝐆\n\nNᴀᴍᴇ : {user}\n\nID : {user_id}\n\nMᴇssᴀɢᴇ : {content}" - ) - -@Client.on_callback_query(filters.regex(r"^next")) -async def next_page(bot, query): - ident, req, key, offset = query.data.split("_") - if int(req) not in [query.from_user.id, 0]: - return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True) - try: - offset = int(offset) - except: - offset = 0 - search = BUTTONS.get(key) - if not search: - await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name),show_alert=True) - return - - files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=offset, filter=True) - try: - n_offset = int(n_offset) - except: - n_offset = 0 - - if not files: - return - settings = await get_settings(query.message.chat.id) - temp.SEND_ALL_TEMP[query.from_user.id] = files - if 'is_shortlink' in settings.keys(): - ENABLE_SHORTLINK = settings['is_shortlink'] - else: - await save_group_settings(query.message.chat.id, 'is_shortlink', False) - ENABLE_SHORTLINK = False - if ENABLE_SHORTLINK and settings['button']: - btn = [ - [ - InlineKeyboardButton( - text=f"[{get_size(file.file_size)}] {file.file_name}", url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - ] - for file in files - ] - elif ENABLE_SHORTLINK and not settings['button']: - btn = [ - [ - InlineKeyboardButton( - text=f"{file.file_name}", url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - InlineKeyboardButton( - text=f"{get_size(file.file_size)}", - url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - ] - for file in files - ] - elif settings['button'] and not ENABLE_SHORTLINK: - btn = [ - [ - InlineKeyboardButton( - text=f"[{get_size(file.file_size)}] {file.file_name}", callback_data=f'files#{file.file_id}' - ), - ] - for file in files - ] - else: - btn = [ - [ - InlineKeyboardButton( - text=f"{file.file_name}", callback_data=f'files#{file.file_id}' - ), - InlineKeyboardButton( - text=f"{get_size(file.file_size)}", - callback_data=f'files_#{file.file_id}', - ), - ] - for file in files - ] - try: - if settings['auto_delete']: - btn.insert(0, - [ - InlineKeyboardButton(f'ɪɴꜰᴏ', 'reqinfo'), - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - else: - btn.insert(0, - [ - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - except KeyError: - await save_group_settings(query.message.chat.id, 'auto_delete', True) - btn.insert(0, - [ - InlineKeyboardButton(f'ɪɴꜰᴏ', 'reqinfo'), - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - try: - if settings['max_btn']: - if 0 < offset <= 10: - off_set = 0 - elif offset == 0: - off_set = None - else: - off_set = offset - 10 - if n_offset == 0: - btn.append( - [InlineKeyboardButton("⌫ 𝐁𝐀𝐂𝐊", callback_data=f"next_{req}_{key}_{off_set}"), InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages")] - ) - elif off_set is None: - btn.append([InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages"), InlineKeyboardButton("𝐍𝐄𝐗𝐓 ➪", callback_data=f"next_{req}_{key}_{n_offset}")]) - else: - btn.append( - [ - InlineKeyboardButton("⌫ 𝐁𝐀𝐂𝐊", callback_data=f"next_{req}_{key}_{off_set}"), - InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages"), - InlineKeyboardButton("𝐍𝐄𝐗𝐓 ➪", callback_data=f"next_{req}_{key}_{n_offset}") - ], - ) - else: - if 0 < offset <= int(MAX_B_TN): - off_set = 0 - elif offset == 0: - off_set = None - else: - off_set = offset - int(MAX_B_TN) - if n_offset == 0: - btn.append( - [InlineKeyboardButton("⌫ 𝐁𝐀𝐂𝐊", callback_data=f"next_{req}_{key}_{off_set}"), InlineKeyboardButton(f"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}", callback_data="pages")] - ) - elif off_set is None: - btn.append([InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(f"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}", callback_data="pages"), InlineKeyboardButton("𝐍𝐄𝐗𝐓 ➪", callback_data=f"next_{req}_{key}_{n_offset}")]) - else: - btn.append( - [ - InlineKeyboardButton("⌫ 𝐁𝐀𝐂𝐊", callback_data=f"next_{req}_{key}_{off_set}"), - InlineKeyboardButton(f"{math.ceil(int(offset)/int(MAX_B_TN))+1} / {math.ceil(total/int(MAX_B_TN))}", callback_data="pages"), - InlineKeyboardButton("𝐍𝐄𝐗𝐓 ➪", callback_data=f"next_{req}_{key}_{n_offset}") - ], - ) - except KeyError: - await save_group_settings(query.message.chat.id, 'max_btn', True) - if 0 < offset <= 10: - off_set = 0 - elif offset == 0: - off_set = None - else: - off_set = offset - 10 - if n_offset == 0: - btn.append( - [InlineKeyboardButton("⌫ 𝐁𝐀𝐂𝐊", callback_data=f"next_{req}_{key}_{off_set}"), InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages")] - ) - elif off_set is None: - btn.append([InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages"), InlineKeyboardButton("𝐍𝐄𝐗𝐓 ➪", callback_data=f"next_{req}_{key}_{n_offset}")]) - else: - btn.append( - [ - InlineKeyboardButton("⌫ 𝐁𝐀𝐂𝐊", callback_data=f"next_{req}_{key}_{off_set}"), - InlineKeyboardButton(f"{math.ceil(int(offset)/10)+1} / {math.ceil(total/10)}", callback_data="pages"), - InlineKeyboardButton("𝐍𝐄𝐗𝐓 ➪", callback_data=f"next_{req}_{key}_{n_offset}") - ], - ) - btn.insert(0, [ - InlineKeyboardButton("! Sᴇɴᴅ Aʟʟ Tᴏ PM !", callback_data=f"send_fall#files#{offset}#{req}"), - InlineKeyboardButton("! Lᴀɴɢᴜᴀɢᴇs !", callback_data=f"select_lang#{req}") - ]) - btn.insert(0, [ - InlineKeyboardButton("⚡ Cʜᴇᴄᴋ Bᴏᴛ PM ⚡", url=f"https://t.me/{temp.U_NAME}") - ]) - try: - await query.edit_message_reply_markup( - reply_markup=InlineKeyboardMarkup(btn) - ) - except MessageNotModified: - pass - await query.answer() - -@Client.on_callback_query(filters.regex(r"^lang")) -async def language_check(bot, query): - _, userid, language = query.data.split("#") - if int(userid) not in [query.from_user.id, 0]: - return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True) - if language == "unknown": - return await query.answer("Sᴇʟᴇᴄᴛ ᴀɴʏ ʟᴀɴɢᴜᴀɢᴇ ғʀᴏᴍ ᴛʜᴇ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴs !", show_alert=True) - movie = temp.KEYWORD.get(query.from_user.id) - if not movie: - return await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name), show_alert=True) - if language != "home": - movie = f"{movie} {language}" - files, offset, total_results = await get_search_results(query.message.chat.id, movie, offset=0, filter=True) - if files: - settings = await get_settings(query.message.chat.id) - temp.SEND_ALL_TEMP[query.from_user.id] = files - if 'is_shortlink' in settings.keys(): - ENABLE_SHORTLINK = settings['is_shortlink'] - else: - await save_group_settings(query.message.chat.id, 'is_shortlink', False) - ENABLE_SHORTLINK = False - pre = 'filep' if settings['file_secure'] else 'file' - if ENABLE_SHORTLINK and settings['button']: - btn = [ - [ - InlineKeyboardButton( - text=f"[{get_size(file.file_size)}] {file.file_name}", url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - ] - for file in files - ] - elif ENABLE_SHORTLINK and not settings['button']: - btn = [ - [ - InlineKeyboardButton( - text=f"{file.file_name}", - url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - InlineKeyboardButton( - text=f"{get_size(file.file_size)}", - url=await get_shortlink(query.message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - ] - for file in files - ] - elif settings['button'] and not ENABLE_SHORTLINK: - btn = [ - [ - InlineKeyboardButton( - text=f"[{get_size(file.file_size)}] {file.file_name}", callback_data=f'{pre}#{file.file_id}' - ), - ] - for file in files - ] - else: - btn = [ - [ - InlineKeyboardButton( - text=f"{file.file_name}", - callback_data=f'{pre}#{file.file_id}', - ), - InlineKeyboardButton( - text=f"{get_size(file.file_size)}", - callback_data=f'{pre}#{file.file_id}', - ), - ] - for file in files - ] - - try: - if settings['auto_delete']: - btn.insert(0, - [ - InlineKeyboardButton(f'ɪɴꜰᴏ', 'reqinfo'), - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - - else: - btn.insert(0, - [ - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - - except KeyError: - await save_group_settings(query.message.chat.id, 'auto_delete', True) - btn.insert(0, - [ - InlineKeyboardButton(f'ɪɴꜰᴏ', 'reqinfo'), - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - - btn.insert(0, [ - InlineKeyboardButton("! Sᴇɴᴅ Aʟʟ Tᴏ PM !", callback_data=f"send_fall#{pre}#{0}#{userid}"), - InlineKeyboardButton("! Lᴀɴɢᴜᴀɢᴇs !", callback_data=f"select_lang#{userid}") - ]) - - btn.insert(0, [ - InlineKeyboardButton("⚡ Cʜᴇᴄᴋ Bᴏᴛ PM ⚡", url=f"https://t.me/{temp.U_NAME}") - ]) - - if offset != "": - key = f"{query.message.chat.id}-{query.message.id}" - BUTTONS[key] = movie - req = userid - try: - if settings['max_btn']: - btn.append( - [InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")] - ) - - else: - btn.append( - [InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/int(MAX_B_TN))}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")] - ) - except KeyError: - await save_group_settings(query.message.chat.id, 'max_btn', True) - btn.append( - [InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")] - ) - else: - btn.append( - [InlineKeyboardButton(text="𝐍𝐎 𝐌𝐎𝐑𝐄 𝐏𝐀𝐆𝐄𝐒 𝐀𝐕𝐀𝐈𝐋𝐀𝐁𝐋𝐄",callback_data="pages")] - ) - try: - await query.edit_message_reply_markup( - reply_markup=InlineKeyboardMarkup(btn) - ) - except MessageNotModified: - pass - await query.answer() - else: - return await query.answer(f"Sᴏʀʀʏ, Nᴏ ғɪʟᴇs ғᴏᴜɴᴅ ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {movie}.", show_alert=True) - -@Client.on_callback_query(filters.regex(r"^select_lang")) -async def select_language(bot, query): - _, userid = query.data.split("#") - if int(userid) not in [query.from_user.id, 0]: - return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True) - btn = [[ - InlineKeyboardButton("Sᴇʟᴇᴄᴛ Yᴏᴜʀ Dᴇꜱɪʀᴇᴅ Lᴀɴɢᴜᴀɢᴇ ↓", callback_data=f"lang#{userid}#unknown") - ],[ - InlineKeyboardButton("Eɴɢʟɪꜱʜ", callback_data=f"lang#{userid}#eng"), - InlineKeyboardButton("Tᴀᴍɪʟ", callback_data=f"lang#{userid}#tam"), - InlineKeyboardButton("Hɪɴᴅɪ", callback_data=f"lang#{userid}#hin") - ],[ - InlineKeyboardButton("Kᴀɴɴᴀᴅᴀ", callback_data=f"lang#{userid}#kan"), - InlineKeyboardButton("Tᴇʟᴜɢᴜ", callback_data=f"lang#{userid}#tel") - ],[ - InlineKeyboardButton("Mᴀʟᴀʏᴀʟᴀᴍ", callback_data=f"lang#{userid}#mal") - ],[ - InlineKeyboardButton("Mᴜʟᴛɪ Aᴜᴅɪᴏ", callback_data=f"lang#{userid}#multi"), - InlineKeyboardButton("Dᴜᴀʟ Aᴜᴅɪᴏ", callback_data=f"lang#{userid}#dual") - ],[ - InlineKeyboardButton("Gᴏ Bᴀᴄᴋ", callback_data=f"lang#{userid}#home") - ]] - try: - await query.edit_message_reply_markup( - reply_markup=InlineKeyboardMarkup(btn) - ) - except MessageNotModified: - pass - await query.answer() - -@Client.on_callback_query(filters.regex(r"^spol")) -async def advantage_spoll_choker(bot, query): - _, user, movie_ = query.data.split('#') - movies = SPELL_CHECK.get(query.message.reply_to_message.id) - if not movies: - return await query.answer(script.OLD_ALRT_TXT.format(query.from_user.first_name), show_alert=True) - if int(user) != 0 and query.from_user.id != int(user): - return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True) - if movie_ == "close_spellcheck": - return await query.message.delete() - movie = movies[(int(movie_))] - await query.answer(script.TOP_ALRT_MSG) - gl = await global_filters(bot, query.message, text=movie) - manual = await manual_filters(bot, query.message, text=movie) - files, offset, total_results = await get_search_results(query.message.chat.id, movie, offset=0, filter=True) - if files: - k = (movie, files, offset, total_results) - await auto_filter(bot, query, k) - else: - if NO_RESULTS_MSG: - reqstr1 = query.from_user.id if query.from_user else 0 - reqstr = await bot.get_users(reqstr1) - await bot.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, movie))) - k_msg = await query.message.edit(script.MVE_NT_FND) - await asyncio.sleep(10) - await k_msg.delete() - await asyncio.sleep(590) - if gl: - await gl.delete() - if manual: - await manual.delete() - - -@Client.on_callback_query() -async def cb_handler(client: Client, query: CallbackQuery): - if query.data == "close_data": - await query.message.delete() - elif query.data == "gfiltersdeleteallconfirm": - await del_allg(query.message, 'gfilters') - await query.answer("Dᴏɴᴇ !") - return - elif query.data == "gfiltersdeleteallcancel": - await query.message.reply_to_message.delete() - await query.message.delete() - await query.answer("Pʀᴏᴄᴇss Cᴀɴᴄᴇʟʟᴇᴅ !") - return - elif query.data == "delallconfirm": - userid = query.from_user.id - chat_type = query.message.chat.type - - if chat_type == enums.ChatType.PRIVATE: - grpid = await active_connection(str(userid)) - if grpid is not None: - grp_id = grpid - try: - chat = await client.get_chat(grpid) - title = chat.title - except: - await query.message.edit_text("Mᴀᴋᴇ sᴜʀᴇ I'ᴍ ᴘʀᴇsᴇɴᴛ ɪɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ!!", quote=True) - return await query.answer(MSG_ALRT) - else: - await query.message.edit_text( - "I'ᴍ ɴᴏᴛ ᴄᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ ᴀɴʏ ɢʀᴏᴜᴘs!\nCʜᴇᴄᴋ /connections ᴏʀ ᴄᴏɴɴᴇᴄᴛ ᴛᴏ ᴀɴʏ ɢʀᴏᴜᴘs", - quote=True - ) - return await query.answer(MSG_ALRT) - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grp_id = query.message.chat.id - title = query.message.chat.title - - else: - return await query.answer(MSG_ALRT) - - st = await client.get_chat_member(grp_id, userid) - if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS): - await del_all(query.message, grp_id, title) - else: - await query.answer("Yᴏᴜ ɴᴇᴇᴅ ᴛᴏ ʙᴇ Gʀᴏᴜᴘ Oᴡɴᴇʀ ᴏʀ ᴀɴ Aᴜᴛʜ Usᴇʀ ᴛᴏ ᴅᴏ ᴛʜᴀᴛ!", show_alert=True) - elif query.data == "delallcancel": - userid = query.from_user.id - chat_type = query.message.chat.type - - if chat_type == enums.ChatType.PRIVATE: - await query.message.reply_to_message.delete() - await query.message.delete() - - elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]: - grp_id = query.message.chat.id - st = await client.get_chat_member(grp_id, userid) - if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS): - await query.message.delete() - try: - await query.message.reply_to_message.delete() - except: - pass - else: - await query.answer("Tʜᴀᴛ's ɴᴏᴛ ғᴏʀ ʏᴏᴜ!!", show_alert=True) - elif "groupcb" in query.data: - await query.answer() - - group_id = query.data.split(":")[1] - - act = query.data.split(":")[2] - hr = await client.get_chat(int(group_id)) - title = hr.title - user_id = query.from_user.id - - if act == "": - stat = "CONNECT" - cb = "connectcb" - else: - stat = "DISCONNECT" - cb = "disconnect" - - keyboard = InlineKeyboardMarkup([ - [InlineKeyboardButton(f"{stat}", callback_data=f"{cb}:{group_id}"), - InlineKeyboardButton("DELETE", callback_data=f"deletecb:{group_id}")], - [InlineKeyboardButton("BACK", callback_data="backcb")] - ]) - - await query.message.edit_text( - f"Gʀᴏᴜᴘ Nᴀᴍᴇ : **{title}**\nGʀᴏᴜᴘ ID : `{group_id}`", - reply_markup=keyboard, - parse_mode=enums.ParseMode.MARKDOWN - ) - return await query.answer(MSG_ALRT) - elif "connectcb" in query.data: - await query.answer() - - group_id = query.data.split(":")[1] - - hr = await client.get_chat(int(group_id)) - - title = hr.title - - user_id = query.from_user.id - - mkact = await make_active(str(user_id), str(group_id)) - - if mkact: - await query.message.edit_text( - f"Cᴏɴɴᴇᴄᴛᴇᴅ ᴛᴏ **{title}**", - parse_mode=enums.ParseMode.MARKDOWN - ) - else: - await query.message.edit_text('Sᴏᴍᴇ ᴇʀʀᴏʀ ᴏᴄᴄᴜʀʀᴇᴅ!!', parse_mode=enums.ParseMode.MARKDOWN) - return await query.answer(MSG_ALRT) - elif "disconnect" in query.data: - await query.answer() - - group_id = query.data.split(":")[1] - - hr = await client.get_chat(int(group_id)) - - title = hr.title - user_id = query.from_user.id - - mkinact = await make_inactive(str(user_id)) - - if mkinact: - await query.message.edit_text( - f"Dɪsᴄᴏɴɴᴇᴄᴛᴇᴅ ғʀᴏᴍ **{title}**", - parse_mode=enums.ParseMode.MARKDOWN - ) - else: - await query.message.edit_text( - f"Sᴏᴍᴇ ᴇʀʀᴏʀ ᴏᴄᴄᴜʀʀᴇᴅ!!", - parse_mode=enums.ParseMode.MARKDOWN - ) - return await query.answer(MSG_ALRT) - elif "deletecb" in query.data: - await query.answer() - - user_id = query.from_user.id - group_id = query.data.split(":")[1] - - delcon = await delete_connection(str(user_id), str(group_id)) - - if delcon: - await query.message.edit_text( - "Sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ ᴄᴏɴɴᴇᴄᴛɪᴏɴ !" - ) - else: - await query.message.edit_text( - f"Sᴏᴍᴇ ᴇʀʀᴏʀ ᴏᴄᴄᴜʀʀᴇᴅ!!", - parse_mode=enums.ParseMode.MARKDOWN - ) - return await query.answer(MSG_ALRT) - elif query.data == "backcb": - await query.answer() - - userid = query.from_user.id - - groupids = await all_connections(str(userid)) - if groupids is None: - await query.message.edit_text( - "Tʜᴇʀᴇ ᴀʀᴇ ɴᴏ ᴀᴄᴛɪᴠᴇ ᴄᴏɴɴᴇᴄᴛɪᴏɴs!! Cᴏɴɴᴇᴄᴛ ᴛᴏ sᴏᴍᴇ ɢʀᴏᴜᴘs ғɪʀsᴛ.", - ) - return await query.answer(MSG_ALRT) - buttons = [] - for groupid in groupids: - try: - ttl = await client.get_chat(int(groupid)) - title = ttl.title - active = await if_active(str(userid), str(groupid)) - act = " - ACTIVE" if active else "" - buttons.append( - [ - InlineKeyboardButton( - text=f"{title}{act}", callback_data=f"groupcb:{groupid}:{act}" - ) - ] - ) - except: - pass - if buttons: - await query.message.edit_text( - "Yᴏᴜʀ ᴄᴏɴɴᴇᴄᴛᴇᴅ ɢʀᴏᴜᴘ ᴅᴇᴛᴀɪʟs ;\n\n", - reply_markup=InlineKeyboardMarkup(buttons) - ) - elif "gfilteralert" in query.data: - grp_id = query.message.chat.id - i = query.data.split(":")[1] - keyword = query.data.split(":")[2] - reply_text, btn, alerts, fileid = await find_gfilter('gfilters', keyword) - if alerts is not None: - alerts = ast.literal_eval(alerts) - alert = alerts[int(i)] - alert = alert.replace("\\n", "\n").replace("\\t", "\t") - await query.answer(alert, show_alert=True) - elif "alertmessage" in query.data: - grp_id = query.message.chat.id - i = query.data.split(":")[1] - keyword = query.data.split(":")[2] - reply_text, btn, alerts, fileid = await find_filter(grp_id, keyword) - if alerts is not None: - alerts = ast.literal_eval(alerts) - alert = alerts[int(i)] - alert = alert.replace("\\n", "\n").replace("\\t", "\t") - await query.answer(alert, show_alert=True) - if query.data.startswith("file"): - clicked = query.from_user.id - try: - typed = query.message.reply_to_message.from_user.id - except: - typed = query.from_user.id - ident, file_id = query.data.split("#") - files_ = await get_file_details(file_id) - if not files_: - return await query.answer('Nᴏ sᴜᴄʜ ғɪʟᴇ ᴇxɪsᴛ.') - files = files_[0] - title = files.file_name - size = get_size(files.file_size) - f_caption = files.caption - settings = await get_settings(query.message.chat.id) - if CUSTOM_FILE_CAPTION: - try: - f_caption = CUSTOM_FILE_CAPTION.format(file_name='' if title is None else title, - file_size='' if size is None else size, - file_caption='' if f_caption is None else f_caption) - except Exception as e: - logger.exception(e) - f_caption = f_caption - if f_caption is None: - f_caption = f"{files.file_name}" - - try: - links = await is_subscribed(client, query=query) - if AUTH_CHANNEL and not len(links) == 0: - if clicked == typed: - await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}") - return - else: - await query.answer(f"Hᴇʏ {query.from_user.first_name}, Tʜɪs Is Nᴏᴛ Yᴏᴜʀ Mᴏᴠɪᴇ Rᴇǫᴜᴇsᴛ. Rᴇǫᴜᴇsᴛ Yᴏᴜʀ's !", show_alert=True) - elif settings['botpm']: - if clicked == typed: - await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}") - return - else: - await query.answer(f"Hᴇʏ {query.from_user.first_name}, Tʜɪs Is Nᴏᴛ Yᴏᴜʀ Mᴏᴠɪᴇ Rᴇǫᴜᴇsᴛ. Rᴇǫᴜᴇsᴛ Yᴏᴜʀ's !", show_alert=True) - else: - if clicked == typed: - if IS_VERIFY and not await check_verification(client, query.from_user.id): - btn = [[ - InlineKeyboardButton("Vᴇʀɪғʏ", url=await get_token(client, query.from_user.id, f"https://telegram.me/{temp.U_NAME}?start=", file_id)), - InlineKeyboardButton("Hᴏᴡ Tᴏ Vᴇʀɪғʏ", url=HOW_TO_VERIFY) - ]] - await client.send_message( - chat_id=query.from_user.id, - text="Yᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴠᴇʀɪғɪᴇᴅ!\nKɪɴᴅʟʏ ᴠᴇʀɪғʏ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ Sᴏ ᴛʜᴀᴛ ʏᴏᴜ ᴄᴀɴ ɢᴇᴛ ᴀᴄᴄᴇss ᴛᴏ ᴜɴʟɪᴍɪᴛᴇᴅ ᴍᴏᴠɪᴇs ᴜɴᴛɪʟ 12 ʜᴏᴜʀs ғʀᴏᴍ ɴᴏᴡ !", - protect_content=True if ident == 'checksubp' else False, - disable_web_page_preview=True, - parse_mode=enums.ParseMode.HTML, - reply_markup=InlineKeyboardMarkup(btn) - ) - return await query.answer("Hᴇʏ, Yᴏᴜ ʜᴀᴠᴇ ɴᴏᴛ ᴠᴇʀɪғɪᴇᴅ ᴛᴏᴅᴀʏ. Yᴏᴜ ʜᴀᴠᴇ ᴛᴏ ᴠᴇʀɪғʏ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ. Cʜᴇᴄᴋ ᴍʏ PM ᴛᴏ ᴠᴇʀɪғʏ ᴀɴᴅ ɢᴇᴛ ғɪʟᴇs !", show_alert=True) - else: - await client.send_cached_media( - chat_id=query.from_user.id, - file_id=file_id, - caption=f_caption, - protect_content=True if ident == "filep" else False, - reply_markup=InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) - ],[ - InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/creatorbeatz") - ] - ] - ) - ) - return await query.answer('Cʜᴇᴄᴋ PM, I ʜᴀᴠᴇ sᴇɴᴛ ғɪʟᴇs ɪɴ PM', show_alert=True) - else: - return await query.answer(f"Hᴇʏ {query.from_user.first_name}, Tʜɪs Is Nᴏᴛ Yᴏᴜʀ Mᴏᴠɪᴇ Rᴇǫᴜᴇsᴛ. Rᴇǫᴜᴇsᴛ Yᴏᴜʀ's !", show_alert=True) - except UserIsBlocked: - await query.answer('Uɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ ᴍᴀʜɴ !', show_alert=True) - except PeerIdInvalid: - await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}") - except Exception as e: - await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}") - elif query.data.startswith("checksub"): - links = await is_subscribed(client, query=query) - if AUTH_CHANNEL and len(links) >= 1: - await query.answer("Jᴏɪɴ ᴏᴜʀ Bᴀᴄᴋ-ᴜᴘ ᴄʜᴀɴɴᴇʟs ᴍᴀʜɴ! 😒", show_alert=True) - return - ident, file_id = query.data.split("#") - if file_id == "send_all": - send_files = temp.SEND_ALL_TEMP.get(query.from_user.id) - is_over = await send_all(client, query.from_user.id, send_files, ident) - if is_over == 'done': - return await query.answer(f"Hᴇʏ {query.from_user.first_name}, Aʟʟ ғɪʟᴇs ᴏɴ ᴛʜɪs ᴘᴀɢᴇ ʜᴀs ʙᴇᴇɴ sᴇɴᴛ sᴜᴄᴄᴇssғᴜʟʟʏ ᴛᴏ ʏᴏᴜʀ PM !", show_alert=True) - elif is_over == 'fsub': - return await query.answer("Hᴇʏ, Yᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴊᴏɪɴᴇᴅ ɪɴ ᴍʏ ʙᴀᴄᴋ ᴜᴘ ᴄʜᴀɴɴᴇʟ. Cʜᴇᴄᴋ ᴍʏ PM ᴛᴏ ᴊᴏɪɴ ᴀɴᴅ ɢᴇᴛ ғɪʟᴇs !", show_alert=True) - elif is_over == 'verify': - return await query.answer("Hᴇʏ, Yᴏᴜ ʜᴀᴠᴇ ɴᴏᴛ ᴠᴇʀɪғɪᴇᴅ ᴛᴏᴅᴀʏ. Yᴏᴜ ʜᴀᴠᴇ ᴛᴏ ᴠᴇʀɪғʏ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ. Cʜᴇᴄᴋ ᴍʏ PM ᴛᴏ ᴠᴇʀɪғʏ ᴀɴᴅ ɢᴇᴛ ғɪʟᴇs !", show_alert=True) - else: - return await query.answer(f"Eʀʀᴏʀ: {is_over}", show_alert=True) - files_ = await get_file_details(file_id) - if not files_: - return await query.answer('Nᴏ sᴜᴄʜ ғɪʟᴇ ᴇxɪsᴛ.') - files = files_[0] - title = files.file_name - size = get_size(files.file_size) - f_caption = files.caption - if CUSTOM_FILE_CAPTION: - try: - f_caption = CUSTOM_FILE_CAPTION.format(file_name='' if title is None else title, - file_size='' if size is None else size, - file_caption='' if f_caption is None else f_caption) - except Exception as e: - logger.exception(e) - f_caption = f_caption - if f_caption is None: - f_caption = f"{title}" - await query.answer() - if IS_VERIFY and not await check_verification(client, query.from_user.id): - btn = [[ - InlineKeyboardButton("Vᴇʀɪғʏ", url=await get_token(client, query.from_user.id, f"https://telegram.me/{temp.U_NAME}?start=", file_id)), - InlineKeyboardButton("Hᴏᴡ Tᴏ Vᴇʀɪғʏ", url=HOW_TO_VERIFY) - ]] - await client.send_message( - chat_id=query.from_user.id, - text="Yᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴠᴇʀɪғɪᴇᴅ!\nKɪɴᴅʟʏ ᴠᴇʀɪғʏ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ Sᴏ ᴛʜᴀᴛ ʏᴏᴜ ᴄᴀɴ ɢᴇᴛ ᴀᴄᴄᴇss ᴛᴏ ᴜɴʟɪᴍɪᴛᴇᴅ ᴍᴏᴠɪᴇs ᴜɴᴛɪʟ 12 ʜᴏᴜʀs ғʀᴏᴍ ɴᴏᴡ !", - protect_content=True if ident == 'checksubp' else False, - disable_web_page_preview=True, - parse_mode=enums.ParseMode.HTML, - reply_markup=InlineKeyboardMarkup(btn) - ) - return - await client.send_cached_media( - chat_id=query.from_user.id, - file_id=file_id, - caption=f_caption, - protect_content=True if ident == 'checksubp' else False, - reply_markup=InlineKeyboardMarkup( - [ - [ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK) - ],[ - InlineKeyboardButton("Bᴏᴛ Oᴡɴᴇʀ", url="t.me/creatorbeatz") - ] - ] - ) - ) - elif query.data == "pages": - await query.answer() - - elif query.data.startswith("send_fall"): - temp_var, ident, offset, userid = query.data.split("#") - if int(userid) not in [query.from_user.id, 0]: - return await query.answer(script.ALRT_TXT.format(query.from_user.first_name), show_alert=True) - files = temp.SEND_ALL_TEMP.get(query.from_user.id) - is_over = await send_all(client, query.from_user.id, files, ident) - if is_over == 'done': - return await query.answer(f"Hᴇʏ {query.from_user.first_name}, Aʟʟ ғɪʟᴇs ᴏɴ ᴛʜɪs ᴘᴀɢᴇ ʜᴀs ʙᴇᴇɴ sᴇɴᴛ sᴜᴄᴄᴇssғᴜʟʟʏ ᴛᴏ ʏᴏᴜʀ PM !", show_alert=True) - elif is_over == 'fsub': - return await query.answer("Hᴇʏ, Yᴏᴜ ᴀʀᴇ ɴᴏᴛ ᴊᴏɪɴᴇᴅ ɪɴ ᴍʏ ʙᴀᴄᴋ ᴜᴘ ᴄʜᴀɴɴᴇʟ. Cʜᴇᴄᴋ ᴍʏ PM ᴛᴏ ᴊᴏɪɴ ᴀɴᴅ ɢᴇᴛ ғɪʟᴇs !", show_alert=True) - elif is_over == 'verify': - return await query.answer("Hᴇʏ, Yᴏᴜ ʜᴀᴠᴇ ɴᴏᴛ ᴠᴇʀɪғɪᴇᴅ ᴛᴏᴅᴀʏ. Yᴏᴜ ʜᴀᴠᴇ ᴛᴏ ᴠᴇʀɪғʏ ᴛᴏ ᴄᴏɴᴛɪɴᴜᴇ. Cʜᴇᴄᴋ ᴍʏ PM ᴛᴏ ᴠᴇʀɪғʏ ᴀɴᴅ ɢᴇᴛ ғɪʟᴇs !", show_alert=True) - else: - return await query.answer(f"Eʀʀᴏʀ: {is_over}", show_alert=True) - - elif query.data.startswith("killfilesdq"): - ident, keyword = query.data.split("#") - await query.message.edit_text(f"Fᴇᴛᴄʜɪɴɢ Fɪʟᴇs ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {keyword} ᴏɴ DB... Pʟᴇᴀsᴇ ᴡᴀɪᴛ...") - files, total = await get_bad_files(keyword) - await query.message.edit_text(f"Fᴏᴜɴᴅ {total} Fɪʟᴇs ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {keyword} !\n\nFɪʟᴇ ᴅᴇʟᴇᴛɪᴏɴ ᴘʀᴏᴄᴇss ᴡɪʟʟ sᴛᴀʀᴛ ɪɴ 5 sᴇᴄᴏɴᴅs!") - await asyncio.sleep(5) - deleted = 0 - async with lock: - try: - for file in files: - file_ids = file.file_id - file_name = file.file_name - result = await Media.collection.delete_one({ - '_id': file_ids, - }) - if not result.deleted_count: - result = await Media2.collection.delete_one({ - '_id': file_ids, - }) - if result.deleted_count: - logger.info(f'Fɪʟᴇ Fᴏᴜɴᴅ ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {keyword}! Sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ {file_name} ғʀᴏᴍ ᴅᴀᴛᴀʙᴀsᴇ.') - deleted += 1 - if deleted % 20 == 0: - await query.message.edit_text(f"Pʀᴏᴄᴇss sᴛᴀʀᴛᴇᴅ ғᴏʀ ᴅᴇʟᴇᴛɪɴɢ ғɪʟᴇs ғʀᴏᴍ DB. Sᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ {str(deleted)} ғɪʟᴇs ғʀᴏᴍ DB ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {keyword} !\n\nPʟᴇᴀsᴇ ᴡᴀɪᴛ...") - except Exception as e: - logger.exception(e) - await query.message.edit_text(f'Eʀʀᴏʀ: {e}') - else: - await query.message.edit_text(f"Pʀᴏᴄᴇss Cᴏᴍᴘʟᴇᴛᴇᴅ ғᴏʀ ғɪʟᴇ ᴅᴇʟᴇᴛɪᴏɴ !\n\nSᴜᴄᴄᴇssғᴜʟʟʏ ᴅᴇʟᴇᴛᴇᴅ {str(deleted)} ғɪʟᴇs ғʀᴏᴍ DB ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {keyword}.") - - elif query.data.startswith("opnsetgrp"): - ident, grp_id = query.data.split("#") - userid = query.from_user.id if query.from_user else None - st = await client.get_chat_member(grp_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and str(userid) not in ADMINS - ): - await query.answer("Yᴏᴜ Dᴏɴ'ᴛ Hᴀᴠᴇ Tʜᴇ Rɪɢʜᴛs Tᴏ Dᴏ Tʜɪs !", show_alert=True) - return - title = query.message.chat.title - settings = await get_settings(grp_id) - if settings is not None: - buttons = [ - [ - InlineKeyboardButton('Fɪʟᴛᴇʀ Bᴜᴛᴛᴏɴ', - callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'), - InlineKeyboardButton('Sɪɴɢʟᴇ' if settings["button"] else 'Dᴏᴜʙʟᴇ', - callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Fɪʟᴇ Sᴇɴᴅ Mᴏᴅᴇ', callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}'), - InlineKeyboardButton('Mᴀɴᴜᴀʟ Sᴛᴀʀᴛ' if settings["botpm"] else 'Aᴜᴛᴏ Sᴇɴᴅ', - callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Pʀᴏᴛᴇᴄᴛ Cᴏɴᴛᴇɴᴛ', - callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["file_secure"] else '✘ Oғғ', - callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Iᴍᴅʙ', callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["imdb"] else '✘ Oғғ', - callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Sᴘᴇʟʟ Cʜᴇᴄᴋ', - callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["spell_check"] else '✘ Oғғ', - callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Wᴇʟᴄᴏᴍᴇ Msɢ', callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["welcome"] else '✘ Oғғ', - callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Aᴜᴛᴏ-Dᴇʟᴇᴛᴇ', - callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}'), - InlineKeyboardButton('10 Mɪɴs' if settings["auto_delete"] else '✘ Oғғ', - callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Aᴜᴛᴏ-Fɪʟᴛᴇʀ', - callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["auto_ffilter"] else '✘ Oғғ', - callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Mᴀx Bᴜᴛᴛᴏɴs', - callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}'), - InlineKeyboardButton('10' if settings["max_btn"] else f'{MAX_B_TN}', - callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('SʜᴏʀᴛLɪɴᴋ', - callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["is_shortlink"] else '✘ Oғғ', - callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}') - ] - ] - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=f"Cʜᴀɴɢᴇ Yᴏᴜʀ Sᴇᴛᴛɪɴɢs Fᴏʀ {title} As Yᴏᴜʀ Wɪsʜ ⚙", - disable_web_page_preview=True, - parse_mode=enums.ParseMode.HTML - ) - await query.message.edit_reply_markup(reply_markup) - - elif query.data.startswith("opnsetpm"): - ident, grp_id = query.data.split("#") - userid = query.from_user.id if query.from_user else None - st = await client.get_chat_member(grp_id, userid) - if ( - st.status != enums.ChatMemberStatus.ADMINISTRATOR - and st.status != enums.ChatMemberStatus.OWNER - and str(userid) not in ADMINS - ): - await query.answer("Yᴏᴜ Dᴏɴ'ᴛ Hᴀᴠᴇ Tʜᴇ Rɪɢʜᴛs Tᴏ Dᴏ Tʜɪs !", show_alert=True) - return - title = query.message.chat.title - settings = await get_settings(grp_id) - btn2 = [[ - InlineKeyboardButton("Cʜᴇᴄᴋ PM", url=f"t.me/{temp.U_NAME}") - ]] - reply_markup = InlineKeyboardMarkup(btn2) - await query.message.edit_text(f"Yᴏᴜʀ sᴇᴛᴛɪɴɢs ᴍᴇɴᴜ ғᴏʀ {title} ʜᴀs ʙᴇᴇɴ sᴇɴᴛ ᴛᴏ ʏᴏᴜʀ PM") - await query.message.edit_reply_markup(reply_markup) - if settings is not None: - buttons = [ - [ - InlineKeyboardButton('Fɪʟᴛᴇʀ Bᴜᴛᴛᴏɴ', - callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'), - InlineKeyboardButton('Sɪɴɢʟᴇ' if settings["button"] else 'Dᴏᴜʙʟᴇ', - callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Fɪʟᴇ Sᴇɴᴅ Mᴏᴅᴇ', callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}'), - InlineKeyboardButton('Mᴀɴᴜᴀʟ Sᴛᴀʀᴛ' if settings["botpm"] else 'Aᴜᴛᴏ Sᴇɴᴅ', - callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Pʀᴏᴛᴇᴄᴛ Cᴏɴᴛᴇɴᴛ', - callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["file_secure"] else '✘ Oғғ', - callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Iᴍᴅʙ', callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["imdb"] else '✘ Oғғ', - callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Sᴘᴇʟʟ Cʜᴇᴄᴋ', - callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["spell_check"] else '✘ Oғғ', - callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Wᴇʟᴄᴏᴍᴇ Msɢ', callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["welcome"] else '✘ Oғғ', - callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Aᴜᴛᴏ-Dᴇʟᴇᴛᴇ', - callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}'), - InlineKeyboardButton('10 Mɪɴs' if settings["auto_delete"] else '✘ Oғғ', - callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Aᴜᴛᴏ-Fɪʟᴛᴇʀ', - callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["auto_ffilter"] else '✘ Oғғ', - callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Mᴀx Bᴜᴛᴛᴏɴs', - callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}'), - InlineKeyboardButton('10' if settings["max_btn"] else f'{MAX_B_TN}', - callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('SʜᴏʀᴛLɪɴᴋ', - callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["is_shortlink"] else '✘ Oғғ', - callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}') - ] - ] - reply_markup = InlineKeyboardMarkup(buttons) - await client.send_message( - chat_id=userid, - text=f"Cʜᴀɴɢᴇ Yᴏᴜʀ Sᴇᴛᴛɪɴɢs Fᴏʀ {title} As Yᴏᴜʀ Wɪsʜ ⚙", - reply_markup=reply_markup, - disable_web_page_preview=True, - parse_mode=enums.ParseMode.HTML, - reply_to_message_id=query.message.id - ) - - elif query.data.startswith("show_option"): - ident, from_user = query.data.split("#") - btn = [[ - InlineKeyboardButton("Uɴᴀᴠᴀɪʟᴀʙʟᴇ", callback_data=f"unavailable#{from_user}"), - InlineKeyboardButton("Uᴘʟᴏᴀᴅᴇᴅ", callback_data=f"uploaded#{from_user}") - ],[ - InlineKeyboardButton("Aʟʀᴇᴀᴅʏ Aᴠᴀɪʟᴀʙʟᴇ", callback_data=f"already_available#{from_user}") - ]] - btn2 = [[ - InlineKeyboardButton("Vɪᴇᴡ Sᴛᴀᴛᴜs", url=f"{query.message.link}") - ]] - if query.from_user.id in ADMINS: - user = await client.get_users(from_user) - reply_markup = InlineKeyboardMarkup(btn) - await query.message.edit_reply_markup(reply_markup) - await query.answer("Hᴇʀᴇ ᴀʀᴇ ᴛʜᴇ ᴏᴘᴛɪᴏɴs !") - else: - await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) - - elif query.data.startswith("unavailable"): - ident, from_user = query.data.split("#") - btn = [[ - InlineKeyboardButton("⚠️ Uɴᴀᴠᴀɪʟᴀʙʟᴇ ⚠️", callback_data=f"unalert#{from_user}") - ]] - btn2 = [[ - InlineKeyboardButton("Vɪᴇᴡ Sᴛᴀᴛᴜs", url=f"{query.message.link}") - ]] - if query.from_user.id in ADMINS: - user = await client.get_users(from_user) - reply_markup = InlineKeyboardMarkup(btn) - content = query.message.text - await query.message.edit_text(f"{content}") - await query.message.edit_reply_markup(reply_markup) - await query.answer("Sᴇᴛ ᴛᴏ Uɴᴀᴠᴀɪʟᴀʙʟᴇ !") - try: - await client.send_message(chat_id=int(from_user), text=f"Hᴇʏ {user.mention}, Sᴏʀʀʏ Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴜɴᴀᴠᴀɪʟᴀʙʟᴇ. Sᴏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs ᴄᴀɴ'ᴛ ᴜᴘʟᴏᴀᴅ ɪᴛ.", reply_markup=InlineKeyboardMarkup(btn2)) - except UserIsBlocked: - await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"Hᴇʏ {user.mention}, Sᴏʀʀʏ Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴜɴᴀᴠᴀɪʟᴀʙʟᴇ. Sᴏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs ᴄᴀɴ'ᴛ ᴜᴘʟᴏᴀᴅ ɪᴛ.\n\nNᴏᴛᴇ: Tʜɪs ᴍᴇssᴀɢᴇ ɪs sᴇɴᴛ ᴛᴏ ᴛʜɪs ɢʀᴏᴜᴘ ʙᴇᴄᴀᴜsᴇ ʏᴏᴜ'ᴠᴇ ʙʟᴏᴄᴋᴇᴅ ᴛʜᴇ ʙᴏᴛ. Tᴏ sᴇɴᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ ʏᴏᴜʀ PM, Mᴜsᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.", reply_markup=InlineKeyboardMarkup(btn2)) - else: - await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) - - elif query.data.startswith("uploaded"): - ident, from_user = query.data.split("#") - btn = [[ - InlineKeyboardButton("✅ Uᴘʟᴏᴀᴅᴇᴅ ✅", callback_data=f"upalert#{from_user}") - ]] - btn2 = [[ - InlineKeyboardButton("Vɪᴇᴡ Sᴛᴀᴛᴜs", url=f"{query.message.link}") - ]] - if query.from_user.id in ADMINS: - user = await client.get_users(from_user) - reply_markup = InlineKeyboardMarkup(btn) - content = query.message.text - await query.message.edit_text(f"{content}") - await query.message.edit_reply_markup(reply_markup) - await query.answer("Sᴇᴛ ᴛᴏ Uᴘʟᴏᴀᴅᴇᴅ !") - try: - await client.send_message(chat_id=int(from_user), text=f"Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ʜᴀs ʙᴇᴇɴ ᴜᴘʟᴏᴀᴅᴇᴅ ʙʏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ᴀɢᴀɪɴ.", reply_markup=InlineKeyboardMarkup(btn2)) - except UserIsBlocked: - await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ʜᴀs ʙᴇᴇɴ ᴜᴘʟᴏᴀᴅᴇᴅ ʙʏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ᴀɢᴀɪɴ.\n\nNᴏᴛᴇ: Tʜɪs ᴍᴇssᴀɢᴇ ɪs sᴇɴᴛ ᴛᴏ ᴛʜɪs ɢʀᴏᴜᴘ ʙᴇᴄᴀᴜsᴇ ʏᴏᴜ'ᴠᴇ ʙʟᴏᴄᴋᴇᴅ ᴛʜᴇ ʙᴏᴛ. Tᴏ sᴇɴᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ ʏᴏᴜʀ PM, Mᴜsᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.", reply_markup=InlineKeyboardMarkup(btn2)) - else: - await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) - - elif query.data.startswith("already_available"): - ident, from_user = query.data.split("#") - btn = [[ - InlineKeyboardButton("🟢 Aʟʀᴇᴀᴅʏ Aᴠᴀɪʟᴀʙʟᴇ 🟢", callback_data=f"alalert#{from_user}") - ]] - btn2 = [[ - InlineKeyboardButton("Vɪᴇᴡ Sᴛᴀᴛᴜs", url=f"{query.message.link}") - ]] - if query.from_user.id in ADMINS: - user = await client.get_users(from_user) - reply_markup = InlineKeyboardMarkup(btn) - content = query.message.text - await query.message.edit_text(f"{content}") - await query.message.edit_reply_markup(reply_markup) - await query.answer("Sᴇᴛ ᴛᴏ Aʟʀᴇᴀᴅʏ Aᴠᴀɪʟᴀʙʟᴇ !") - try: - await client.send_message(chat_id=int(from_user), text=f"Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ᴏɴ ᴏᴜʀ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ᴀɢᴀɪɴ.", reply_markup=InlineKeyboardMarkup(btn2)) - except UserIsBlocked: - await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ᴏɴ ᴏᴜʀ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ᴀɢᴀɪɴ.\n\nNᴏᴛᴇ: Tʜɪs ᴍᴇssᴀɢᴇ ɪs sᴇɴᴛ ᴛᴏ ᴛʜɪs ɢʀᴏᴜᴘ ʙᴇᴄᴀᴜsᴇ ʏᴏᴜ'ᴠᴇ ʙʟᴏᴄᴋᴇᴅ ᴛʜᴇ ʙᴏᴛ. Tᴏ sᴇɴᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ ʏᴏᴜʀ PM, Mᴜsᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.", reply_markup=InlineKeyboardMarkup(btn2)) - else: - await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) - - elif query.data.startswith("alalert"): - ident, from_user = query.data.split("#") - if int(query.from_user.id) == int(from_user): - user = await client.get_users(from_user) - await query.answer(f"Hᴇʏ {user.first_name}, Yᴏᴜʀ Rᴇᴏ̨ᴜᴇsᴛ ɪs Aʟʀᴇᴀᴅʏ Aᴠᴀɪʟᴀʙʟᴇ !", show_alert=True) - else: - await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) - - elif query.data.startswith("upalert"): - ident, from_user = query.data.split("#") - if int(query.from_user.id) == int(from_user): - user = await client.get_users(from_user) - await query.answer(f"Hᴇʏ {user.first_name}, Yᴏᴜʀ Rᴇᴏ̨ᴜᴇsᴛ ɪs Uᴘʟᴏᴀᴅᴇᴅ !", show_alert=True) - else: - await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) - - elif query.data.startswith("unalert"): - ident, from_user = query.data.split("#") - if int(query.from_user.id) == int(from_user): - user = await client.get_users(from_user) - await query.answer(f"Hᴇʏ {user.first_name}, Yᴏᴜʀ Rᴇᴏ̨ᴜᴇsᴛ ɪs Uɴᴀᴠᴀɪʟᴀʙʟᴇ !", show_alert=True) - else: - await query.answer("Yᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ sᴜғғɪᴄɪᴀɴᴛ ʀɪɢʜᴛs ᴛᴏ ᴅᴏ ᴛʜɪs !", show_alert=True) - - elif query.data == "reqinfo": - await query.answer(text=script.REQINFO, show_alert=True) - - elif query.data == "minfo": - await query.answer(text=script.MINFO, show_alert=True) - - elif query.data == "sinfo": - await query.answer(text=script.SINFO, show_alert=True) - - elif query.data == "start": - buttons = [[ - InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true') - ],[ - InlineKeyboardButton('♚ Bᴏᴛ Oᴡɴᴇʀ', callback_data="owner_info"), - InlineKeyboardButton('⌬ Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK) - ],[ - InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'), - InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about'), - InlineKeyboardButton('Iɴʟɪɴᴇ Sᴇᴀʀᴄʜ ☌', switch_inline_query_current_chat='') - ],[ - InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK) - ]] - - reply_markup = InlineKeyboardMarkup(buttons) - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - await query.message.edit_text( - text=script.START_TXT.format(query.from_user.mention, temp.U_NAME, temp.B_NAME), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - await query.answer(MSG_ALRT) - - elif query.data == "filters": - buttons = [[ - InlineKeyboardButton('Mᴀɴᴜᴀʟ FIʟᴛᴇʀ', callback_data='manuelfilter'), - InlineKeyboardButton('Aᴜᴛᴏ FIʟᴛᴇʀ', callback_data='autofilter') - ],[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='help'), - InlineKeyboardButton('Gʟᴏʙᴀʟ Fɪʟᴛᴇʀs', callback_data='global_filters') - ]] - - reply_markup = InlineKeyboardMarkup(buttons) - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - await query.message.edit_text( - text=script.ALL_FILTERS.format(query.from_user.mention), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - - elif query.data == "global_filters": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='filters') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=script.GFILTER_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - - elif query.data == "help": - buttons = [[ - InlineKeyboardButton('FIʟᴛᴇʀs', callback_data='filters'), - InlineKeyboardButton('Fɪʟᴇ Sᴛᴏʀᴇ', callback_data='store_file') - ], [ - InlineKeyboardButton('Cᴏɴɴᴇᴄᴛɪᴏɴ', callback_data='coct'), - InlineKeyboardButton('Exᴛʀᴀ Mᴏᴅs', callback_data='extra') - ], [ - InlineKeyboardButton('Hᴏᴍᴇ', callback_data='start'), - InlineKeyboardButton('Sᴛᴀᴛᴜs', callback_data='stats') - ]] - - reply_markup = InlineKeyboardMarkup(buttons) - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - await query.message.edit_text( - text=script.HELP_TXT.format(query.from_user.mention), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "about": - buttons = [[ - InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=GRP_LNK), - InlineKeyboardButton('Sᴏᴜʀᴄᴇ Cᴏᴅᴇ', callback_data='source') - ],[ - InlineKeyboardButton('Hᴏᴍᴇ', callback_data='start'), - InlineKeyboardButton('Cʟᴏsᴇ', callback_data='close_data') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=script.ABOUT_TXT.format(temp.B_NAME), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "source": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='about') - ]] - reply_markup = InlineKeyboardMarkup(buttons) - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - await query.message.edit_text( - text=script.SOURCE_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "manuelfilter": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='filters'), - InlineKeyboardButton('Bᴜᴛᴛᴏɴs', callback_data='button') - ]] - reply_markup = InlineKeyboardMarkup(buttons) - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - await query.message.edit_text( - text=script.MANUELFILTER_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "button": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='manuelfilter') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=script.BUTTON_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "autofilter": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='filters') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=script.AUTOFILTER_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "coct": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='help') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=script.CONNECTION_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "extra": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='help'), - InlineKeyboardButton('Aᴅᴍɪɴ', callback_data='admin') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=script.EXTRAMOD_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - - elif query.data == "store_file": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='help') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=script.FILE_STORE_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - - elif query.data == "admin": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='extra') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_text( - text=script.ADMIN_TXT, - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "stats": - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='help'), - InlineKeyboardButton('⟲ Rᴇғʀᴇsʜ', callback_data='rfrsh') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - #primary db - totalp = await Media.count_documents() - #secondary db - totalsec = await Media2.count_documents() - #users and chats - users = await db.total_users_count() - chats = await db.total_chat_count() - #primary db - stats = await clientDB.command('dbStats') - used_dbSize = (stats['dataSize']/(1024*1024))+(stats['indexSize']/(1024*1024)) - free_dbSize = 512-used_dbSize - #secondary db - stats2 = await clientDB2.command('dbStats') - used_dbSize2 = (stats2['dataSize']/(1024*1024))+(stats2['indexSize']/(1024*1024)) - free_dbSize2 = 512-used_dbSize2 - await query.message.edit_text( - text=script.STATUS_TXT.format((int(totalp)+int(totalsec)), users, chats, totalp, round(used_dbSize, 2), round(free_dbSize, 2), totalsec, round(used_dbSize2, 2), round(free_dbSize2, 2)), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "rfrsh": - await query.answer("Fetching MongoDb DataBase") - buttons = [[ - InlineKeyboardButton('⟸ Bᴀᴄᴋ', callback_data='help'), - InlineKeyboardButton('⟲ Rᴇғʀᴇsʜ', callback_data='rfrsh') - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(buttons) - #primary db - totalp = await Media.count_documents() - #secondary db - totalsec = await Media2.count_documents() - users = await db.total_users_count() - chats = await db.total_chat_count() - #primary db - stats = await clientDB.command('dbStats') - used_dbSize = (stats['dataSize']/(1024*1024))+(stats['indexSize']/(1024*1024)) - free_dbSize = 512-used_dbSize - #secondary db - stats2 = await clientDB2.command('dbStats') - used_dbSize2 = (stats2['dataSize']/(1024*1024))+(stats2['indexSize']/(1024*1024)) - free_dbSize2 = 512-used_dbSize2 - await query.message.edit_text( - text=script.STATUS_TXT.format((int(totalp)+int(totalsec)), users, chats, totalp, round(used_dbSize, 2), round(free_dbSize, 2), totalsec, round(used_dbSize2, 2), round(free_dbSize2, 2)), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - elif query.data == "owner_info": - btn = [[ - InlineKeyboardButton("⟸ Bᴀᴄᴋ", callback_data="start"), - InlineKeyboardButton("Cᴏɴᴛᴀᴄᴛ", url="t.me/creatorbeatz") - ]] - await client.edit_message_media( - query.message.chat.id, - query.message.id, - InputMediaPhoto(random.choice(PICS)) - ) - reply_markup = InlineKeyboardMarkup(btn) - await query.message.edit_text( - text=(script.OWNER_INFO), - reply_markup=reply_markup, - parse_mode=enums.ParseMode.HTML - ) - - elif query.data.startswith("setgs"): - ident, set_type, status, grp_id = query.data.split("#") - grpid = await active_connection(str(query.from_user.id)) - - if set_type == 'is_shortlink' and query.from_user.id not in ADMINS: - return await query.answer(text=f"Hᴇʏ {query.from_user.first_name}, Yᴏᴜ ᴄᴀɴ'ᴛ ᴄʜᴀɴɢᴇ sʜᴏʀᴛʟɪɴᴋ sᴇᴛᴛɪɴɢs ғᴏʀ ʏᴏᴜʀ ɢʀᴏᴜᴘ !\n\nIᴛ's ᴀɴ ᴀᴅᴍɪɴ ᴏɴʟʏ sᴇᴛᴛɪɴɢ !", show_alert=True) - - if str(grp_id) != str(grpid) and query.from_user.id not in ADMINS: - await query.message.edit("Yᴏᴜʀ Aᴄᴛɪᴠᴇ Cᴏɴɴᴇᴄᴛɪᴏɴ Hᴀs Bᴇᴇɴ Cʜᴀɴɢᴇᴅ. Gᴏ Tᴏ /connections ᴀɴᴅ ᴄʜᴀɴɢᴇ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴄᴏɴɴᴇᴄᴛɪᴏɴ.") - return await query.answer(MSG_ALRT) - - if status == "True": - await save_group_settings(grpid, set_type, False) - else: - await save_group_settings(grpid, set_type, True) - - settings = await get_settings(grpid) - - if settings is not None: - buttons = [ - [ - InlineKeyboardButton('Fɪʟᴛᴇʀ Bᴜᴛᴛᴏɴ', - callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'), - InlineKeyboardButton('Sɪɴɢʟᴇ' if settings["button"] else 'Dᴏᴜʙʟᴇ', - callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Fɪʟᴇ Sᴇɴᴅ Mᴏᴅᴇ', callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}'), - InlineKeyboardButton('Mᴀɴᴜᴀʟ Sᴛᴀʀᴛ' if settings["botpm"] else 'Aᴜᴛᴏ Sᴇɴᴅ', - callback_data=f'setgs#botpm#{settings["botpm"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Pʀᴏᴛᴇᴄᴛ Cᴏɴᴛᴇɴᴛ', - callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["file_secure"] else '✘ Oғғ', - callback_data=f'setgs#file_secure#{settings["file_secure"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Iᴍᴅʙ', callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["imdb"] else '✘ Oғғ', - callback_data=f'setgs#imdb#{settings["imdb"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Sᴘᴇʟʟ Cʜᴇᴄᴋ', - callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["spell_check"] else '✘ Oғғ', - callback_data=f'setgs#spell_check#{settings["spell_check"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Wᴇʟᴄᴏᴍᴇ Msɢ', callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["welcome"] else '✘ Oғғ', - callback_data=f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Aᴜᴛᴏ-Dᴇʟᴇᴛᴇ', - callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}'), - InlineKeyboardButton('10 Mɪɴs' if settings["auto_delete"] else '✘ Oғғ', - callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Aᴜᴛᴏ-Fɪʟᴛᴇʀ', - callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["auto_ffilter"] else '✘ Oғғ', - callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('Mᴀx Bᴜᴛᴛᴏɴs', - callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}'), - InlineKeyboardButton('10' if settings["max_btn"] else f'{MAX_B_TN}', - callback_data=f'setgs#max_btn#{settings["max_btn"]}#{str(grp_id)}') - ], - [ - InlineKeyboardButton('SʜᴏʀᴛLɪɴᴋ', - callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}'), - InlineKeyboardButton('✔ Oɴ' if settings["is_shortlink"] else '✘ Oғғ', - callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{str(grp_id)}') - ] - ] - reply_markup = InlineKeyboardMarkup(buttons) - await query.message.edit_reply_markup(reply_markup) - await query.answer(MSG_ALRT) - - -async def auto_filter(client, msg, spoll=False): - reqstr1 = msg.from_user.id if msg.from_user else 0 - reqstr = await client.get_users(reqstr1) - if not spoll: - message = msg - settings = await get_settings(message.chat.id) - if message.text.startswith("/"): return # ignore commands - if re.findall("((^\/|^,|^!|^\.|^[\U0001F600-\U000E007F]).*)", message.text): - return - if len(message.text) < 100: - search = message.text - files, offset, total_results = await get_search_results(message.chat.id ,search.lower(), offset=0, filter=True) - if not files: - if settings["spell_check"]: - return await advantage_spell_chok(client, msg) - else: - if NO_RESULTS_MSG: - await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, search))) - return - else: - return - else: - message = msg.message.reply_to_message # msg will be callback query - search, files, offset, total_results = spoll - settings = await get_settings(message.chat.id) - temp.SEND_ALL_TEMP[message.from_user.id] = files - temp.KEYWORD[message.from_user.id] = search - if 'is_shortlink' in settings.keys(): - ENABLE_SHORTLINK = settings['is_shortlink'] - else: - await save_group_settings(message.chat.id, 'is_shortlink', False) - ENABLE_SHORTLINK = False - pre = 'filep' if settings['file_secure'] else 'file' - if ENABLE_SHORTLINK and settings["button"]: - btn = [ - [ - InlineKeyboardButton( - text=f"[{get_size(file.file_size)}] {file.file_name}", url=await get_shortlink(message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - ] - for file in files - ] - elif ENABLE_SHORTLINK and not settings["button"]: - btn = [ - [ - InlineKeyboardButton( - text=f"{file.file_name}", - url=await get_shortlink(message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - InlineKeyboardButton( - text=f"{get_size(file.file_size)}", - url=await get_shortlink(message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}") - ), - ] - for file in files - ] - elif settings["button"] and not ENABLE_SHORTLINK: - btn = [ - [ - InlineKeyboardButton( - text=f"[{get_size(file.file_size)}] {file.file_name}", callback_data=f'{pre}#{file.file_id}' - ), - ] - for file in files - ] - else: - btn = [ - [ - InlineKeyboardButton( - text=f"{file.file_name}", - callback_data=f'{pre}#{file.file_id}', - ), - InlineKeyboardButton( - text=f"{get_size(file.file_size)}", - callback_data=f'{pre}#{file.file_id}', - ), - ] - for file in files - ] - try: - if settings['auto_delete']: - btn.insert(0, - [ - InlineKeyboardButton(f'ɪɴꜰᴏ', 'reqinfo'), - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - else: - btn.insert(0, - [ - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - except KeyError: - await save_group_settings(message.chat.id, 'auto_delete', True) - btn.insert(0, - [ - InlineKeyboardButton(f'ɪɴꜰᴏ', 'reqinfo'), - InlineKeyboardButton(f'ᴍᴏᴠɪᴇ', 'minfo'), - InlineKeyboardButton(f'ꜱᴇʀɪᴇꜱ', 'sinfo') - ] - ) - - btn.insert(0, [ - InlineKeyboardButton("! Sᴇɴᴅ Aʟʟ Tᴏ PM !", callback_data=f"send_fall#{pre}#{0}#{message.from_user.id}"), - InlineKeyboardButton("! Lᴀɴɢᴜᴀɢᴇs !", callback_data=f"select_lang#{message.from_user.id}") - ]) - - btn.insert(0, [ - InlineKeyboardButton("⚡ Cʜᴇᴄᴋ Bᴏᴛ PM ⚡", url=f"https://t.me/{temp.U_NAME}") - ]) - - if offset != "": - key = f"{message.chat.id}-{message.id}" - BUTTONS[key] = search - req = message.from_user.id if message.from_user else 0 - try: - if settings['max_btn']: - btn.append( - [InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")] - ) - else: - btn.append( - [InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/int(MAX_B_TN))}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")] - ) - except KeyError: - await save_group_settings(message.chat.id, 'max_btn', True) - btn.append( - [InlineKeyboardButton("𝐏𝐀𝐆𝐄", callback_data="pages"), InlineKeyboardButton(text=f"1/{math.ceil(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="𝐍𝐄𝐗𝐓 ➪",callback_data=f"next_{req}_{key}_{offset}")] - ) - else: - btn.append( - [InlineKeyboardButton(text="𝐍𝐎 𝐌𝐎𝐑𝐄 𝐏𝐀𝐆𝐄𝐒 𝐀𝐕𝐀𝐈𝐋𝐀𝐁𝐋𝐄",callback_data="pages")] - ) - imdb = await get_poster(search, file=(files[0]).file_name) if settings["imdb"] else None - TEMPLATE = settings['template'] - if imdb: - cap = TEMPLATE.format( - query=search, - title=imdb['title'], - votes=imdb['votes'], - aka=imdb["aka"], - seasons=imdb["seasons"], - box_office=imdb['box_office'], - localized_title=imdb['localized_title'], - kind=imdb['kind'], - imdb_id=imdb["imdb_id"], - cast=imdb["cast"], - runtime=imdb["runtime"], - countries=imdb["countries"], - certificates=imdb["certificates"], - languages=imdb["languages"], - director=imdb["director"], - writer=imdb["writer"], - producer=imdb["producer"], - composer=imdb["composer"], - cinematographer=imdb["cinematographer"], - music_team=imdb["music_team"], - distributors=imdb["distributors"], - release_date=imdb['release_date'], - year=imdb['year'], - genres=imdb['genres'], - poster=imdb['poster'], - plot=imdb['plot'], - rating=imdb['rating'], - url=imdb['url'], - **locals() - ) - else: - cap = f"Hᴇʏ {message.from_user.mention}, Hᴇʀᴇ ɪs Wʜᴀᴛ I Fᴏᴜɴᴅ Iɴ Mʏ Dᴀᴛᴀʙᴀsᴇ Fᴏʀ Yᴏᴜʀ Qᴜᴇʀʏ {search}." - if imdb and imdb.get('poster'): - try: - hehe = await message.reply_photo(photo=imdb.get('poster'), caption=cap[:1024], reply_markup=InlineKeyboardMarkup(btn)) - try: - if settings['auto_delete']: - await asyncio.sleep(600) - await hehe.delete() - await message.delete() - except KeyError: - await save_group_settings(message.chat.id, 'auto_delete', True) - await asyncio.sleep(600) - await hehe.delete() - await message.delete() - except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty): - pic = imdb.get('poster') - poster = pic.replace('.jpg', "._V1_UX360.jpg") - hmm = await message.reply_photo(photo=poster, caption=cap[:1024], reply_markup=InlineKeyboardMarkup(btn)) - try: - if settings['auto_delete']: - await asyncio.sleep(600) - await hmm.delete() - await message.delete() - except KeyError: - await save_group_settings(message.chat.id, 'auto_delete', True) - await asyncio.sleep(600) - await hmm.delete() - await message.delete() - except Exception as e: - logger.exception(e) - fek = await message.reply_photo(photo=NOR_IMG, caption=cap, reply_markup=InlineKeyboardMarkup(btn)) - try: - if settings['auto_delete']: - await asyncio.sleep(600) - await fek.delete() - await message.delete() - except KeyError: - await save_group_settings(message.chat.id, 'auto_delete', True) - await asyncio.sleep(600) - await fek.delete() - await message.delete() - else: - fuk = await message.reply_photo(photo=NOR_IMG, caption=cap, reply_markup=InlineKeyboardMarkup(btn)) - try: - if settings['auto_delete']: - await asyncio.sleep(600) - await fuk.delete() - await message.delete() - except KeyError: - await save_group_settings(message.chat.id, 'auto_delete', True) - await asyncio.sleep(600) - await fuk.delete() - await message.delete() - if spoll: - await msg.message.delete() - - -async def advantage_spell_chok(client, msg): - mv_id = msg.id - mv_rqst = msg.text - reqstr1 = msg.from_user.id if msg.from_user else 0 - reqstr = await client.get_users(reqstr1) - settings = await get_settings(msg.chat.id) - query = re.sub( - r"\b(pl(i|e)*?(s|z+|ease|se|ese|(e+)s(e)?)|((send|snd|giv(e)?|gib)(\sme)?)|movie(s)?|new|latest|br((o|u)h?)*|^h(e|a)?(l)*(o)*|mal(ayalam)?|t(h)?amil|file|that|find|und(o)*|kit(t(i|y)?)?o(w)?|thar(u)?(o)*w?|kittum(o)*|aya(k)*(um(o)*)?|full\smovie|any(one)|with\ssubtitle(s)?)", - "", msg.text, flags=re.IGNORECASE) # plis contribute some common words - query = query.strip() + " movie" - try: - movies = await get_poster(mv_rqst, bulk=True) - except Exception as e: - logger.exception(e) - reqst_gle = mv_rqst.replace(" ", "+") - button = [[ - InlineKeyboardButton("Gᴏᴏɢʟᴇ", url=f"https://www.google.com/search?q={reqst_gle}") - ]] - if NO_RESULTS_MSG: - await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, mv_rqst))) - k = await msg.reply_photo( - photo=SPELL_IMG, - caption=script.I_CUDNT.format(mv_rqst), - reply_markup=InlineKeyboardMarkup(button) - ) - await asyncio.sleep(30) - await k.delete() - return - movielist = [] - if not movies: - reqst_gle = mv_rqst.replace(" ", "+") - button = [[ - InlineKeyboardButton("Gᴏᴏɢʟᴇ", url=f"https://www.google.com/search?q={reqst_gle}") - ]] - if NO_RESULTS_MSG: - await client.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, mv_rqst))) - k = await msg.reply_photo( - photo=SPELL_IMG, - caption=script.I_CUDNT.format(mv_rqst), - reply_markup=InlineKeyboardMarkup(button) - ) - await asyncio.sleep(30) - await k.delete() - return - movielist += [movie.get('title') for movie in movies] - movielist += [f"{movie.get('title')} {movie.get('year')}" for movie in movies] - SPELL_CHECK[mv_id] = movielist - btn = [ - [ - InlineKeyboardButton( - text=movie_name.strip(), - callback_data=f"spol#{reqstr1}#{k}", - ) - ] - for k, movie_name in enumerate(movielist) - ] - btn.append([InlineKeyboardButton(text="Close", callback_data=f'spol#{reqstr1}#close_spellcheck')]) - spell_check_del = await msg.reply_photo( - photo=(SPELL_IMG), - caption=(script.CUDNT_FND.format(mv_rqst)), - reply_markup=InlineKeyboardMarkup(btn) - ) - try: - if settings['auto_delete']: - await asyncio.sleep(600) - await spell_check_del.delete() - except KeyError: - grpid = await active_connection(str(msg.from_user.id)) - await save_group_settings(grpid, 'auto_delete', True) - settings = await get_settings(msg.chat.id) - if settings['auto_delete']: - await asyncio.sleep(600) - await spell_check_del.delete() - - -async def manual_filters(client, message, text=False): - settings = await get_settings(message.chat.id) - group_id = message.chat.id - name = text or message.text - reply_id = message.reply_to_message.id if message.reply_to_message else message.id - keywords = await get_filters(group_id) - for keyword in reversed(sorted(keywords, key=len)): - pattern = r"( |^|[^\w])" + re.escape(keyword) + r"( |$|[^\w])" - if re.search(pattern, name, flags=re.IGNORECASE): - reply_text, btn, alert, fileid = await find_filter(group_id, keyword) - - if reply_text: - reply_text = reply_text.replace("\\n", "\n").replace("\\t", "\t") - - if btn is not None: - try: - if fileid == "None": - if btn == "[]": - return await client.send_message( - group_id, - reply_text, - disable_web_page_preview=True, - protect_content=True if settings["file_secure"] else False, - reply_to_message_id=reply_id - ) - else: - button = eval(btn) - return await client.send_message( - group_id, - reply_text, - disable_web_page_preview=True, - reply_markup=InlineKeyboardMarkup(button), - protect_content=True if settings["file_secure"] else False, - reply_to_message_id=reply_id - ) - elif btn == "[]": - return await client.send_cached_media( - group_id, - fileid, - caption=reply_text or "", - protect_content=True if settings["file_secure"] else False, - reply_to_message_id=reply_id - ) - else: - button = eval(btn) - return await message.reply_cached_media( - fileid, - caption=reply_text or "", - reply_markup=InlineKeyboardMarkup(button), - reply_to_message_id=reply_id - ) - except Exception as e: - logger.exception(e) - break - else: - return False - -async def global_filters(client, message, text=False): - settings = await get_settings(message.chat.id) - group_id = message.chat.id - name = text or message.text - reply_id = message.reply_to_message.id if message.reply_to_message else message.id - keywords = await get_gfilters('gfilters') - for keyword in reversed(sorted(keywords, key=len)): - pattern = r"( |^|[^\w])" + re.escape(keyword) + r"( |$|[^\w])" - if re.search(pattern, name, flags=re.IGNORECASE): - reply_text, btn, alert, fileid = await find_gfilter('gfilters', keyword) - - if reply_text: - reply_text = reply_text.replace("\\n", "\n").replace("\\t", "\t") - - if btn is not None: - try: - if fileid == "None": - if btn == "[]": - return await client.send_message( - group_id, - reply_text, - disable_web_page_preview=True, - reply_to_message_id=reply_id - ) - else: - button = eval(btn) - return await client.send_message( - group_id, - reply_text, - disable_web_page_preview=True, - reply_markup=InlineKeyboardMarkup(button), - reply_to_message_id=reply_id - ) - elif btn == "[]": - return await client.send_cached_media( - group_id, - fileid, - caption=reply_text or "", - reply_to_message_id=reply_id - ) - else: - button = eval(btn) - return await message.reply_cached_media( - fileid, - caption=reply_text or "", - reply_markup=InlineKeyboardMarkup(button), - reply_to_message_id=reply_id - ) - except Exception as e: - logger.exception(e) - break - else: - return False