Test-bot / plugins /pm_filter.py
kgashok's picture
commit
19e1d1f
# Kanged From @TroJanZheX
import asyncio
import re
import ast
import math
import random
import pytz
from datetime import datetime, timedelta, date, time
lock = asyncio.Lock()
from pyrogram.errors.exceptions.bad_request_400 import MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty
from Script import script
import pyrogram
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, AUTH_GROUPS, P_TTI_SHOW_OFF, GRP_LNK, CHNL_LNK, NOR_IMG, LOG_CHANNEL, SPELL_IMG, MAX_B_TN, IMDB, \
SINGLE_BUTTON, SPELL_CHECK_REPLY, IMDB_TEMPLATE, NO_RESULTS_MSG, TUTORIAL, REQST_CHANNEL, IS_TUTORIAL, LANGUAGES, SEASONS, SUPPORT_CHAT, PREMIUM_USER
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InputMediaPhoto
from pyrogram import Client, filters, enums
from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid
from utils import get_size, is_subscribed, get_poster, search_gagala, temp, get_settings, save_group_settings, get_shortlink, get_tutorial, send_all
from database.users_chats_db import db
from database.ia_filterdb import Media, get_file_details, get_search_results, get_bad_files
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)
BUTTON = {}
BUTTONS = {}
FRESH = {}
BUTTONS0 = {}
BUTTONS1 = {}
BUTTONS2 = {}
SPELL_CHECK = {}
# ENABLE_SHORTLINK = ""
@Client.on_message(filters.group & filters.text & filters.incoming)
async def give_filter(client, message):
if message.chat.id != SUPPORT_CHAT_ID:
manual = await manual_filters(client, message)
if manual == False:
settings = await get_settings(message.chat.id)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
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(f"<b>Hᴇʏ {message.from_user.mention}, {str(total_results)} ʀᴇsᴜʟᴛs ᴀʀᴇ ғᴏᴜɴᴅ ɪɴ ᴍʏ ᴅᴀᴛᴀʙᴀsᴇ ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {search}. \n\nTʜɪs ɪs ᴀ sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ sᴏ ᴛʜᴀᴛ ʏᴏᴜ ᴄᴀɴ'ᴛ ɢᴇᴛ ғɪʟᴇs ғʀᴏᴍ ʜᴇʀᴇ...\n\nJᴏɪɴ ᴀɴᴅ Sᴇᴀʀᴄʜ Hᴇʀᴇ - @TeamHMT_Movies</b>")
@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(
text=f"<b>ʜᴇʏ {user} 😍 ,\n\nʏᴏᴜ ᴄᴀɴ'ᴛ ɢᴇᴛ ᴍᴏᴠɪᴇs ꜰʀᴏᴍ ʜᴇʀᴇ. ʀᴇǫᴜᴇsᴛ ɪᴛ ɪɴ ᴏᴜʀ <a href=https://telegram.me/+ps2An00KwZYwNTRl>ᴍᴏᴠɪᴇ ɢʀᴏᴜᴘ</a> ᴏʀ ᴄʟɪᴄᴋ ʀᴇǫᴜᴇsᴛ ʜᴇʀᴇ ʙᴜᴛᴛᴏɴ ʙᴇʟᴏᴡ 👇</b>",
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("📝 ʀᴇǫᴜᴇsᴛ ʜᴇʀᴇ ", url=f"telegram.me/TeamHMT_Movies")]])
)
await bot.send_message(
chat_id=LOG_CHANNEL,
text=f"<b>#𝐏𝐌_𝐌𝐒𝐆\n\nNᴀᴍᴇ : {user}\n\nID : {user_id}\n\nMᴇssᴀɢᴇ : {content}</b>"
)
@Client.on_callback_query(filters.regex(r"^next"))
async def next_page(bot, query):
ident, req, key, offset = query.data.split("_")
curr_time = datetime.now(pytz.timezone('Asia/Kolkata')).time()
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
if BUTTONS.get(key)!=None:
search = BUTTONS.get(key)
else:
search = FRESH.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
temp.GETALL[key] = files
temp.SHORT[query.from_user.id] = query.message.chat.id
settings = await get_settings(query.message.chat.id)
# 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 settings['button']:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}'
),
]
for file in files
]
# else:
# btn = [
# [
# InlineKeyboardButton(
# text=f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", 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
# ]
btn.insert(0,
[
InlineKeyboardButton(f'Sᴇʟᴇᴄᴛ ➢', 'select'),
InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇs", callback_data=f"languages#{key}"),
InlineKeyboardButton("Sᴇᴀsᴏɴs", callback_data=f"seasons#{key}")
]
)
btn.insert(0, [
InlineKeyboardButton("Sᴛᴀʀᴛ Bᴏᴛ", url=f"https://telegram.me/{temp.U_NAME}"),
InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", callback_data=f"sendfiles#{key}")
])
else:
btn = []
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}")
],
)
# if ENABLE_SHORTLINK == True:
# btn.insert(0, [
# InlineKeyboardButton("Sᴛᴀʀᴛ Bᴏᴛ", url=f"https://telegram.me/{temp.U_NAME}"),
# InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", callback_data=f"sendfiles#{key}")
# ])
# else:
# btn.insert(0, [
# InlineKeyboardButton("Sᴛᴀʀᴛ Bᴏᴛ", url=f"https://telegram.me/{temp.U_NAME}"),
# InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", callback_data=f"send_fall#{pre}#{key}#{offset}")
# ])
# btn.insert(0, [
# InlineKeyboardButton("Hᴏᴡ ᴛᴏ Dᴏᴡɴʟᴏᴀᴅ⚡", url=await get_tutorial(query.message.chat.id))
# ])
cur_time = datetime.now(pytz.timezone('Asia/Kolkata')).time()
time_difference = timedelta(hours=cur_time.hour, minutes=cur_time.minute, seconds=(cur_time.second+(cur_time.microsecond/1000000))) - timedelta(hours=curr_time.hour, minutes=curr_time.minute, seconds=(curr_time.second+(curr_time.microsecond/1000000)))
remaining_seconds = "{:.2f}".format(time_difference.total_seconds())
if settings["button"]:
cap = f"<b>Tʜᴇ Rᴇꜱᴜʟᴛꜱ Fᴏʀ ☞ {search}\n\nRᴇǫᴜᴇsᴛᴇᴅ Bʏ ☞ {query.from_user.mention}\n\nʀᴇsᴜʟᴛ sʜᴏᴡ ɪɴ ☞ {remaining_seconds} sᴇᴄᴏɴᴅs\n\nᴘᴏᴡᴇʀᴇᴅ ʙʏ ☞ : {query.message.chat.title} \n\n⚠️ ᴀꜰᴛᴇʀ 5 ᴍɪɴᴜᴛᴇꜱ ᴛʜɪꜱ ᴍᴇꜱꜱᴀɢᴇ ᴡɪʟʟ ʙᴇ ᴀᴜᴛᴏᴍᴀᴛɪᴄᴀʟʟʏ ᴅᴇʟᴇᴛᴇᴅ 🗑️\n\n</b>"
else:
# cap = f"<b>Hᴇʏ {query.from_user.mention}, Hᴇʀᴇ ɪs ᴛʜᴇ ʀᴇsᴜʟᴛ ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {search} \n\n</b>"
cap = f"<b>Hᴇʏ {query.from_user.mention}, Fᴏᴜɴᴅ {total} Rᴇsᴜʟᴛs ғᴏʀ Yᴏᴜʀ Qᴜᴇʀʏ {search}\n\n</b>"
for file in files:
cap += f"<b>📁 <a href='https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}'>[{get_size(file.file_size)}] {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}\n\n</a></b>"
try:
await query.message.edit_text(text=cap, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=True)
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_))]
movie = re.sub(r"[:\-]", " ", movie)
movie = re.sub(r"\s+", " ", movie).strip()
await query.answer(script.TOP_ALRT_MSG)
gl = await global_filters(bot, query.message, text=movie)
if gl == False:
k = await manual_filters(bot, query.message, text=movie)
if k == False:
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:
reqstr1 = query.from_user.id if query.from_user else 0
reqstr = await bot.get_users(reqstr1)
if NO_RESULTS_MSG:
await bot.send_message(chat_id=LOG_CHANNEL, text=(script.NORSLTS.format(reqstr.id, reqstr.mention, movie)))
k = await query.message.edit(script.MVE_NT_FND)
await asyncio.sleep(10)
await k.delete()
#languages
@Client.on_callback_query(filters.regex(r"^languages#"))
async def languages_cb_handler(client: Client, query: CallbackQuery):
try:
if int(query.from_user.id) not in [query.message.reply_to_message.from_user.id, 0]:
return await query.answer(
f"⚠️ ʜᴇʟʟᴏ{query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇQᴜᴇꜱᴛ,\nʀᴇQᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...",
show_alert=True,
)
except:
pass
_, key = query.data.split("#")
# if BUTTONS.get(key+"1")!=None:
# search = BUTTONS.get(key+"1")
# else:
# search = BUTTONS.get(key)
# BUTTONS[key+"1"] = search
search = FRESH.get(key)
search = search.replace(' ', '_')
btn = []
for i in range(0, len(LANGUAGES)-1, 2):
btn.append([
InlineKeyboardButton(
text=LANGUAGES[i].title(),
callback_data=f"fl#{LANGUAGES[i].lower()}#{key}"
),
InlineKeyboardButton(
text=LANGUAGES[i+1].title(),
callback_data=f"fl#{LANGUAGES[i+1].lower()}#{key}"
),
])
btn.insert(
0,
[
InlineKeyboardButton(
text="👇 𝖲𝖾𝗅𝖾𝖼𝗍 𝖸𝗈𝗎𝗋 𝖫𝖺𝗇𝗀𝗎𝖺𝗀𝖾𝗌 👇", callback_data="ident"
)
],
)
req = query.from_user.id
offset = 0
btn.append([InlineKeyboardButton(text="↭ ʙᴀᴄᴋ ᴛᴏ ꜰɪʟᴇs ​↭", callback_data=f"fl#homepage#{key}")])
await query.edit_message_reply_markup(InlineKeyboardMarkup(btn))
@Client.on_callback_query(filters.regex(r"^fl#"))
async def filter_languages_cb_handler(client: Client, query: CallbackQuery):
_, lang, key = query.data.split("#")
search = FRESH.get(key)
search = search.replace("_", " ")
baal = lang in search
if baal:
search = search.replace(lang, "")
else:
search = search
req = query.from_user.id
chat_id = query.message.chat.id
message = query.message
try:
if int(req) not in [query.message.reply_to_message.from_user.id, 0]:
return await query.answer(
f"⚠️ ʜᴇʟʟᴏ{query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇQᴜᴇꜱᴛ,\nʀᴇQᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...",
show_alert=True,
)
except:
pass
searchagain = search
if lang != "homepage":
search = f"{search} {lang}"
BUTTONS[key] = search
files, offset, total_results = await get_search_results(chat_id, search, offset=0, filter=True)
# files = [file for file in files if re.search(lang, file.file_name, re.IGNORECASE)]
if not files:
await query.answer("🚫 𝗡𝗼 𝗙𝗶𝗹𝗲 𝗪𝗲𝗿𝗲 𝗙𝗼𝘂𝗻𝗱 🚫", show_alert=1)
return
temp.GETALL[key] = files
settings = await get_settings(message.chat.id)
# 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 settings["button"]:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}'
),
]
for file in files
]
else:
btn = [
[
InlineKeyboardButton(
text=f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}",
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'Sᴇʟᴇᴄᴛ ➢', 'select'),
InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇs", callback_data=f"languages#{key}"),
InlineKeyboardButton("Sᴇᴀsᴏɴs", callback_data=f"seasons#{key}")
]
)
else:
btn.insert(0,
[
InlineKeyboardButton(f'Sᴇʟᴇᴄᴛ ➢', 'select'),
InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇs", callback_data=f"languages#{key}"),
InlineKeyboardButton("Sᴇᴀsᴏɴs", callback_data=f"seasons#{key}")
]
)
except KeyError:
await save_group_settings(query.message.chat.id, 'auto_delete', True)
btn.insert(0,
[
InlineKeyboardButton(f'Sᴇʟᴇᴄᴛ ➢', 'select'),
InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇs", callback_data=f"languages#{key}"),
InlineKeyboardButton("Sᴇᴀsᴏɴs", callback_data=f"seasons#{key}")
]
)
# btn.insert(0, [
# InlineKeyboardButton("Hᴏᴡ ᴛᴏ Dᴏᴡɴʟᴏᴀᴅ⚡", url=await get_tutorial(query.message.chat.id))
# ])
if offset != "":
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")]
)
# if ENABLE_SHORTLINK == True:
btn.insert(0, [
InlineKeyboardButton("Sᴛᴀʀᴛ Bᴏᴛ", url=f"https://telegram.me/{temp.U_NAME}"),
InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", callback_data=f"sendfiles#{key}")
])
# else:
# btn.insert(0, [
# InlineKeyboardButton("Sᴛᴀʀᴛ Bᴏᴛ", url=f"https://telegram.me/{temp.U_NAME}"),
# InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", callback_data=f"send_fall#{pre}#{key}#{offset}")
# ])
try:
await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(btn)
)
except MessageNotModified:
pass
await query.answer()
# if lang != "homepage":
# offset = 0
# btn.append( [
# InlineKeyboardButton(
# text="↭ ʙᴀᴄᴋ ᴛᴏ ꜰɪʟᴇs ​↭",
# callback_data=f"fl#homepage#search#{key}"
# ),
# ])
# await query.edit_message_reply_markup(reply_markup=InlineKeyboardMarkup(btn))
@Client.on_callback_query(filters.regex(r"^seasons#"))
async def seasons_cb_handler(client: Client, query: CallbackQuery):
try:
if int(query.from_user.id) not in [query.message.reply_to_message.from_user.id, 0]:
return await query.answer(
f"⚠️ ʜᴇʟʟᴏ{query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇQᴜᴇꜱᴛ,\nʀᴇQᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...",
show_alert=True,
)
except:
pass
_, key = query.data.split("#")
# if BUTTONS.get(key+"2")!=None:
# search = BUTTONS.get(key+"2")
# else:
# search = BUTTONS.get(key)
# BUTTONS[key+"2"] = search
search = FRESH.get(key)
BUTTONS[key] = None
search = search.replace(' ', '_')
btn = []
for i in range(0, len(SEASONS)-1, 2):
btn.append([
InlineKeyboardButton(
text=SEASONS[i].title(),
callback_data=f"fs#{SEASONS[i].lower()}#{key}"
),
InlineKeyboardButton(
text=SEASONS[i+1].title(),
callback_data=f"fs#{SEASONS[i+1].lower()}#{key}"
),
])
btn.insert(
0,
[
InlineKeyboardButton(
text="👇 𝖲𝖾𝗅𝖾𝖼𝗍 Season 👇", callback_data="ident"
)
],
)
req = query.from_user.id
offset = 0
btn.append([InlineKeyboardButton(text="↭ ʙᴀᴄᴋ ᴛᴏ ꜰɪʟᴇs ​↭", callback_data=f"next_{req}_{key}_{offset}")])
await query.edit_message_reply_markup(InlineKeyboardMarkup(btn))
@Client.on_callback_query(filters.regex(r"^fs#"))
async def filter_seasons_cb_handler(client: Client, query: CallbackQuery):
_, seas, key = query.data.split("#")
search = FRESH.get(key)
search = search.replace("_", " ")
sea = ""
season_search = ["s01","s02", "s03", "s04", "s05", "s06", "s07", "s08", "s09", "s10", "season 01","season 02","season 03","season 04","season 05","season 06","season 07","season 08","season 09","season 10", "season 1","season 2","season 3","season 4","season 5","season 6","season 7","season 8","season 9"]
for x in range (len(season_search)):
if season_search[x] in search:
sea = season_search[x]
break
if sea:
search = search.replace(sea, "")
else:
search = search
# await query.answer(f"search = {search}", show_alert=True)
req = query.from_user.id
chat_id = query.message.chat.id
message = query.message
try:
if int(req) not in [query.message.reply_to_message.from_user.id, 0]:
return await query.answer(
f"⚠️ ʜᴇʟʟᴏ{query.from_user.first_name},\nᴛʜɪꜱ ɪꜱ ɴᴏᴛ ʏᴏᴜʀ ᴍᴏᴠɪᴇ ʀᴇQᴜᴇꜱᴛ,\nʀᴇQᴜᴇꜱᴛ ʏᴏᴜʀ'ꜱ...",
show_alert=True,
)
except:
pass
searchagn = search
search1 = search
search2 = search
search = f"{search} {seas}"
BUTTONS0[key] = search
files, _, _ = await get_search_results(chat_id, search, max_results=10)
files = [file for file in files if re.search(seas, file.file_name, re.IGNORECASE)]
seas1 = "s01" if seas == "season 1" else "s02" if seas == "season 2" else "s03" if seas == "season 3" else "s04" if seas == "season 4" else "s05" if seas == "season 5" else "s06" if seas == "season 6" else "s07" if seas == "season 7" else "s08" if seas == "season 8" else "s09" if seas == "season 9" else "s10" if seas == "season 10" else ""
search1 = f"{search1} {seas1}"
BUTTONS1[key] = search1
files1, _, _ = await get_search_results(chat_id, search1, max_results=10)
files1 = [file for file in files1 if re.search(seas1, file.file_name, re.IGNORECASE)]
if files1:
files.extend(files1)
seas2 = "season 01" if seas == "season 1" else "season 02" if seas == "season 2" else "season 03" if seas == "season 3" else "season 04" if seas == "season 4" else "season 05" if seas == "season 5" else "season 06" if seas == "season 6" else "season 07" if seas == "season 7" else "season 08" if seas == "season 8" else "season 09" if seas == "season 9" else "s010"
search2 = f"{search2} {seas2}"
BUTTONS2[key] = search2
files2, _, _ = await get_search_results(chat_id, search2, max_results=10)
files2 = [file for file in files2 if re.search(seas2, file.file_name, re.IGNORECASE)]
if files2:
files.extend(files2)
if not files:
await query.answer("🚫 𝗡𝗼 𝗙𝗶𝗹𝗲 𝗪𝗲𝗿𝗲 𝗙𝗼𝘂𝗻𝗱 🚫", show_alert=1)
return
temp.GETALL[key] = files
settings = await get_settings(message.chat.id)
# 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 settings["button"]:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}'
),
]
for file in files
]
else:
btn = [
[
InlineKeyboardButton(
text=f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}",
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
]
btn.insert(0, [
InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", callback_data=f"sendfiles#{key}"),
InlineKeyboardButton("Sᴇʟᴇᴄᴛ ᴀɢᴀɪɴ", callback_data=f"seasons#{key}")
])
# btn.insert(0, [
# InlineKeyboardButton("Hᴏᴡ ᴛᴏ Dᴏᴡɴʟᴏᴀᴅ⚡", url=await get_tutorial(query.message.chat.id))
# ])
offset = 0
btn.append([
InlineKeyboardButton(
text="↭ ʙᴀᴄᴋ ᴛᴏ ꜰɪʟᴇs ​↭",
callback_data=f"next_{req}_{key}_{offset}"
),
])
await query.edit_message_reply_markup(reply_markup=InlineKeyboardMarkup(btn))
@Client.on_callback_query()
async def cb_handler(client: Client, query: CallbackQuery):
# link = await client.create_chat_invite_link(int(REQST_CHANNEL))
if query.data == "close_data":
await query.message.delete()
elif query.data == "gfiltersdeleteallconfirm":
await del_allg(query.message, 'gfilters')
await query.answer("Done !")
return
elif query.data == "gfiltersdeleteallcancel":
await query.message.reply_to_message.delete()
await query.message.delete()
await query.answer("Process Cancelled !")
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:
if AUTH_CHANNEL and not await is_subscribed(client, query):
if clicked == typed:
await query.answer(url=f"https://telegram.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'] and settings['is_shortlink'] and clicked not in PREMIUM_USER:
if clicked == typed:
temp.SHORT[clicked] = query.message.chat.id
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=short_{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['is_shortlink'] and not settings['botpm'] and clicked not in PREMIUM_USER:
if clicked == typed:
temp.SHORT[clicked] = query.message.chat.id
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=short_{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'] or clicked in PREMIUM_USER:
if clicked == typed:
await query.answer(url=f"https://telegram.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:
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=SUPPORT_CHAT),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="telegram.me/TeamHMT_Movies")
]
]
)
)
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)
await query.answer('Cʜᴇᴄᴋ PM, I ʜᴀᴠᴇ sᴇɴᴛ ғɪʟᴇs ɪɴ PM', show_alert=True)
except UserIsBlocked:
await query.answer('Uɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ ᴍᴀʜɴ !', show_alert=True)
except PeerIdInvalid:
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start={ident}_{file_id}")
except Exception as e:
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start={ident}_{file_id}")
elif query.data.startswith("sendfiles"):
clicked = query.from_user.id
ident, key = query.data.split("#")
settings = await get_settings(query.message.chat.id)
try:
if settings['botpm'] and settings['is_shortlink'] and clicked not in PREMIUM_USER:
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=sendfiles1_{key}")
return
elif settings['is_shortlink'] and not settings['botpm'] and clicked not in PREMIUM_USER:
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=sendfiles2_{key}")
return
else:
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=allfiles_{key}")
return
except UserIsBlocked:
await query.answer('Uɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ ᴍᴀʜɴ !', show_alert=True)
except PeerIdInvalid:
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=sendfiles3_{key}")
except Exception as e:
logger.exception(e)
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=sendfiles4_{key}")
elif query.data.startswith("del"):
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}"
await query.answer(url=f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}")
elif query.data.startswith("checksub"):
if AUTH_CHANNEL and not await is_subscribed(client, query):
await query.answer("Jᴏɪɴ ᴏᴜʀ Bᴀᴄᴋ-ᴜᴘ ᴄʜᴀɴɴᴇʟ ᴍᴀʜɴ! 😒", show_alert=True)
return
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
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()
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=SUPPORT_CHAT),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="telegram.me/TeamHMT_Movies")
]
]
)
)
elif query.data == "pages":
await query.answer()
elif query.data.startswith("send_fsall"):
temp_var, ident, key, offset = query.data.split("#")
search = BUTTON0.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=int(offset), filter=True)
await send_all(client, query.from_user.id, files, ident, query.message.chat.id, query.from_user.first_name, query)
search = BUTTONS1.get(key)
files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=int(offset), filter=True)
await send_all(client, query.from_user.id, files, ident, query.message.chat.id, query.from_user.first_name, query)
search = BUTTONS2.get(key)
files, n_offset, total = await get_search_results(query.message.chat.id, search, offset=int(offset), filter=True)
await send_all(client, query.from_user.id, files, ident, query.message.chat.id, query.from_user.first_name, query)
await query.answer(f"Hey {query.from_user.first_name}, All files on this page has been sent successfully to your PM !", show_alert=True)
elif query.data.startswith("send_fall"):
temp_var, ident, key, offset = query.data.split("#")
if BUTTONS.get(key)!=None:
search = BUTTONS.get(key)
else:
search = FRESH.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=int(offset), filter=True)
await send_all(client, query.from_user.id, files, ident, query.message.chat.id, query.from_user.first_name, query)
await query.answer(f"Hey {query.from_user.first_name}, All files on this page has been sent successfully to your PM !", show_alert=True)
elif query.data.startswith("killfilesdq"):
ident, keyword = query.data.split("#")
#await query.message.edit_text(f"<b>Fetching Files for your query {keyword} on DB... Please wait...</b>")
files, total = await get_bad_files(keyword)
await query.message.edit_text("<b>File deletion process will start in 5 seconds !</b>")
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 result.deleted_count:
logger.info(f'File Found for your query {keyword}! Successfully deleted {file_name} from database.')
deleted += 1
if deleted % 20 == 0:
await query.message.edit_text(f"<b>Process started for deleting files from DB. Successfully deleted {str(deleted)} files from DB for your query {keyword} !\n\nPlease wait...</b>")
except Exception as e:
logger.exception(e)
await query.message.edit_text(f'Error: {e}')
else:
await query.message.edit_text(f"<b>Process Completed for file deletion !\n\nSuccessfully deleted {str(deleted)} files from database for your query {keyword}.</b>")
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('Rᴇsᴜʟᴛ Pᴀɢᴇ',
callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'),
InlineKeyboardButton('Bᴜᴛᴛᴏɴ' if settings["button"] else 'Tᴇxᴛ',
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('5 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"<b>Cʜᴀɴɢᴇ Yᴏᴜʀ Sᴇᴛᴛɪɴɢs Fᴏʀ {title} As Yᴏᴜʀ Wɪsʜ ⚙</b>",
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"telegram.me/{temp.U_NAME}")
]]
reply_markup = InlineKeyboardMarkup(btn2)
await query.message.edit_text(f"<b>Yᴏᴜʀ sᴇᴛᴛɪɴɢs ᴍᴇɴᴜ ғᴏʀ {title} ʜᴀs ʙᴇᴇɴ sᴇɴᴛ ᴛᴏ ʏᴏᴜʀ PM</b>")
await query.message.edit_reply_markup(reply_markup)
if settings is not None:
buttons = [
[
InlineKeyboardButton('Rᴇsᴜʟᴛ Pᴀɢᴇ',
callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'),
InlineKeyboardButton('Bᴜᴛᴛᴏɴ' if settings["button"] else 'Tᴇxᴛ',
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('5 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"<b>Cʜᴀɴɢᴇ Yᴏᴜʀ Sᴇᴛᴛɪɴɢs Fᴏʀ {title} As Yᴏᴜʀ Wɪsʜ ⚙</b>",
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('Jᴏɪɴ Cʜᴀɴɴᴇʟ', url=link.invite_link),
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"<b><strike>{content}</strike></b>")
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"<b>Hᴇʏ {user.mention}, Sᴏʀʀʏ Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴜɴᴀᴠᴀɪʟᴀʙʟᴇ. Sᴏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs ᴄᴀɴ'ᴛ ᴜᴘʟᴏᴀᴅ ɪᴛ.</b>", reply_markup=InlineKeyboardMarkup(btn2))
except UserIsBlocked:
await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"<b>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ᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.</b>", 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('Jᴏɪɴ Cʜᴀɴɴᴇʟ', url=link.invite_link),
InlineKeyboardButton("Vɪᴇᴡ Sᴛᴀᴛᴜs", url=f"{query.message.link}")
],[
InlineKeyboardButton("Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ Lɪɴᴋ", url="https://telegram.me/TeamHMT_Movies")
]]
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"<b><strike>{content}</strike></b>")
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"<b>Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ʜᴀs ʙᴇᴇɴ ᴜᴘʟᴏᴀᴅᴇᴅ ʙʏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ɪɴ ᴏᴜʀ Gʀᴏᴜᴘ.</b>", reply_markup=InlineKeyboardMarkup(btn2))
except UserIsBlocked:
await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"<b>Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ʜᴀs ʙᴇᴇɴ ᴜᴘʟᴏᴀᴅᴇᴅ ʙʏ ᴏᴜʀ ᴍᴏᴅᴇʀᴀᴛᴏʀs. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ɪɴ ᴏᴜʀ Gʀᴏᴜᴘ.\n\nNᴏᴛᴇ: Tʜɪs ᴍᴇssᴀɢᴇ ɪs sᴇɴᴛ ᴛᴏ ᴛʜɪs ɢʀᴏᴜᴘ ʙᴇᴄᴀᴜsᴇ ʏᴏᴜ'ᴠᴇ ʙʟᴏᴄᴋᴇᴅ ᴛʜᴇ ʙᴏᴛ. Tᴏ sᴇɴᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ ʏᴏᴜʀ PM, Mᴜsᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.</b>", 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('Jᴏɪɴ Cʜᴀɴɴᴇʟ', url=link.invite_link),
InlineKeyboardButton("Vɪᴇᴡ Sᴛᴀᴛᴜs", url=f"{query.message.link}")
],[
InlineKeyboardButton("Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ Lɪɴᴋ", url="https://telegram.me/TeamHMT_Movies")
]]
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"<b><strike>{content}</strike></b>")
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"<b>Hᴇʏ {user.mention}, Yᴏᴜʀ <a ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ᴏɴ ᴏᴜʀ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ɪɴ ᴏᴜʀ Gʀᴏᴜᴘ.</b>", reply_markup=InlineKeyboardMarkup(btn2))
except UserIsBlocked:
await client.send_message(chat_id=int(SUPPORT_CHAT_ID), text=f"<b>Hᴇʏ {user.mention}, Yᴏᴜʀ ʀᴇᴏ̨ᴜᴇsᴛ ɪs ᴀʟʀᴇᴀᴅʏ ᴀᴠᴀɪʟᴀʙʟᴇ ᴏɴ ᴏᴜʀ ʙᴏᴛ's ᴅᴀᴛᴀʙᴀsᴇ. Kɪɴᴅʟʏ sᴇᴀʀᴄʜ ɪɴ ᴏᴜʀ Gʀᴏᴜᴘ.\n\nNᴏᴛᴇ: Tʜɪs ᴍᴇssᴀɢᴇ ɪs sᴇɴᴛ ᴛᴏ ᴛʜɪs ɢʀᴏᴜᴘ ʙᴇᴄᴀᴜsᴇ ʏᴏᴜ'ᴠᴇ ʙʟᴏᴄᴋᴇᴅ ᴛʜᴇ ʙᴏᴛ. Tᴏ sᴇɴᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ ʏᴏᴜʀ PM, Mᴜsᴛ ᴜɴʙʟᴏᴄᴋ ᴛʜᴇ ʙᴏᴛ.</b>", 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 == "select":
await query.answer(text=script.SELECT, 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://telegram.me/{temp.U_NAME}?startgroup=true')
],[
InlineKeyboardButton('Eᴀʀɴ Mᴏɴᴇʏ 💸', callback_data="shortlink_info"),
InlineKeyboardButton('⌬ Mᴏᴠɪᴇ Gʀᴏᴜᴘ', url=GRP_LNK)
],[
InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'),
InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about')
],[
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)
total = await Media.count_documents()
users = await db.total_users_count()
chats = await db.total_chat_count()
monsize = await db.get_db_size()
free = 536870912 - monsize
monsize = get_size(monsize)
free = get_size(free)
await query.message.edit_text(
text=script.STATUS_TXT.format(total, users, chats, monsize, free),
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)
total = await Media.count_documents()
users = await db.total_users_count()
chats = await db.total_chat_count()
monsize = await db.get_db_size()
free = 536870912 - monsize
monsize = get_size(monsize)
free = get_size(free)
await query.message.edit_text(
text=script.STATUS_TXT.format(total, users, chats, monsize, free),
reply_markup=reply_markup,
parse_mode=enums.ParseMode.HTML
)
elif query.data == "shortlink_info":
btn = [[
InlineKeyboardButton("⟸ Bᴀᴄᴋ", callback_data="start"),
InlineKeyboardButton("Cᴏɴᴛᴀᴄᴛ", url="telegram.me/TeamHMT_Bot")
]]
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.SHORTLINK_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 str(grp_id) != str(grpid):
await query.message.edit("Yᴏᴜʀ Aᴄᴛɪᴠᴇ Cᴏɴɴᴇᴄᴛɪᴏɴ Hᴀs Bᴇᴇɴ Cʜᴀɴɢᴇᴅ. Gᴏ Tᴏ /connections ᴀɴᴅ ᴄʜᴀɴɢᴇ ʏᴏᴜʀ ᴀᴄᴛɪᴠᴇ ᴄᴏɴɴᴇᴄᴛɪᴏɴ.")
return await query.answer(MSG_ALRT)
if set_type == 'is_shortlink' and query.from_user.id not in ADMINS:
return await query.answer(text=f"Hey {query.from_user.first_name}, You can't change shortlink settings for your group !\n\nIt's an admin only setting !", show_alert=True)
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('Rᴇsᴜʟᴛ Pᴀɢᴇ',
callback_data=f'setgs#button#{settings["button"]}#{str(grp_id)}'),
InlineKeyboardButton('Bᴜᴛᴛᴏɴ' if settings["button"] else 'Tᴇxᴛ',
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('5 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):
curr_time = datetime.now(pytz.timezone('Asia/Kolkata')).time()
# reqstr1 = msg.from_user.id if msg.from_user else 0
# reqstr = await client.get_users(reqstr1)
if not spoll:
message = msg
if message.text.startswith("/"): return # ignore commands
if re.findall("((^\/|^,|^!|^\.|^[\U0001F600-\U000E007F]).*)", message.text):
return
if len(message.text) < 100:
search = message.text
m=await message.reply_text(f"<b><i> 𝖲𝖾𝖺𝗋𝖼𝗁𝗂𝗇𝗀 𝖿𝗈𝗋 '{search}' 🔎</i></b>")
search = search.lower()
find = search.split(" ")
search = ""
removes = ["in","upload", "series", "full", "horror", "thriller", "mystery", "print", "file"]
for x in find:
# if x == "in" or x == "upload" or x == "series" or x == "full" or x == "horror" or x == "thriller" or x == "mystery" or x == "print" or x == "subtitle" or x == "subtitles":
# continue
if x in removes:
continue
else:
search = search + x + " "
search = 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|bro|bruh|broh|helo|that|find|dubbed|link|venum|iruka|pannunga|pannungga|anuppunga|anupunga|anuppungga|anupungga|film|undo|kitti|kitty|tharu|kittumo|kittum|movie|any(one)|with\ssubtitle(s)?)", "", search, flags=re.IGNORECASE)
search = re.sub(r"\s+", " ", search).strip()
search = search.replace("-", " ")
search = search.replace(":","")
files, offset, total_results = await get_search_results(message.chat.id ,search, offset=0, filter=True)
settings = await get_settings(message.chat.id)
if not files:
await m.delete()
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
m=await message.reply_text(f"<b><i> 𝖲𝖾𝖺𝗋𝖼𝗁𝗂𝗇𝗀 𝖿𝗈𝗋 '{search}' 🔎</i></b>")
settings = await get_settings(message.chat.id)
await msg.message.delete()
# 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
# if 'is_tutorial' in settings.keys():
# ENABLE_TUTORIAL = settings['is_tutorial']
# else:
# await save_group_settings(message.chat.id, 'is_tutorial', False)
# ENABLE_TUTORIAL = False
pre = 'filep' if settings['file_secure'] else 'file'
key = f"{message.chat.id}-{message.id}"
FRESH[key] = search
temp.GETALL[key] = files
temp.SHORT[message.from_user.id] = message.chat.id
if settings["button"]:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}", callback_data=f'{pre}#{file.file_id}'
),
]
for file in files
]
# else:
# btn = [
# [
# InlineKeyboardButton(
# text=f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}",
# 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
# ]
btn.insert(0,
[
InlineKeyboardButton(f'Sᴇʟᴇᴄᴛ ➢', 'select'),
InlineKeyboardButton("ʟᴀɴɢᴜᴀɢᴇs", callback_data=f"languages#{key}"),
InlineKeyboardButton("Sᴇᴀsᴏɴs", callback_data=f"seasons#{key}")
]
)
# if ENABLE_SHORTLINK == True:
# btn.insert(0, [
# InlineKeyboardButton("Sᴛᴀʀᴛ Bᴏᴛ", url=f"https://telegram.me/{temp.U_NAME}"),
# InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", url=await get_shortlink(message.chat.id, f"https://telegram.me/{temp.U_NAME}?start=allfiles_{key}")
# )
# ])
# else:
# btn.insert(0, [
# InlineKeyboardButton("Sᴛᴀʀᴛ Bᴏᴛ", url=f"https://telegram.me/{temp.U_NAME}"),
# InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", callback_data=f"send_fall#{pre}#{message.chat.id}-{message.id}#{0}")
# ])
btn.insert(0, [
InlineKeyboardButton("Sᴛᴀʀᴛ Bᴏᴛ", url=f"https://telegram.me/{temp.U_NAME}"),
InlineKeyboardButton("𝐒𝐞𝐧𝐝 𝐀𝐥𝐥", callback_data=f"sendfiles#{key}")
])
# if ENABLE_TUTORIAL == True:
# btn.insert(0, [
# InlineKeyboardButton("Hᴏᴡ ᴛᴏ Dᴏᴡɴʟᴏᴀᴅ⚡", url=await get_tutorial(message.chat.id))
# ])
# else:
# btn.insert(0, [
# InlineKeyboardButton("Hᴏᴡ ᴛᴏ Dᴏᴡɴʟᴏᴀᴅ⚡", url=TUTORIAL)
# ])
else:
btn = []
if offset != "":
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
cur_time = datetime.now(pytz.timezone('Asia/Kolkata')).time()
time_difference = timedelta(hours=cur_time.hour, minutes=cur_time.minute, seconds=(cur_time.second+(cur_time.microsecond/1000000))) - timedelta(hours=curr_time.hour, minutes=curr_time.minute, seconds=(curr_time.second+(curr_time.microsecond/1000000)))
remaining_seconds = "{:.2f}".format(time_difference.total_seconds())
# 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:
if settings["button"]:
cap = f"<b>Tʜᴇ Rᴇꜱᴜʟᴛꜱ Fᴏʀ ☞ {search}\n\nRᴇǫᴜᴇsᴛᴇᴅ Bʏ ☞ {message.from_user.mention}\n\nʀᴇsᴜʟᴛ sʜᴏᴡ ɪɴ ☞ {remaining_seconds} sᴇᴄᴏɴᴅs\n\nᴘᴏᴡᴇʀᴇᴅ ʙʏ ☞ : {message.chat.title} \n\n⚠️ ᴀꜰᴛᴇʀ 5 ᴍɪɴᴜᴛᴇꜱ ᴛʜɪꜱ ᴍᴇꜱꜱᴀɢᴇ ᴡɪʟʟ ʙᴇ ᴀᴜᴛᴏᴍᴀᴛɪᴄᴀʟʟʏ ᴅᴇʟᴇᴛᴇᴅ 🗑️\n\n</b>"
else:
# cap = f"<b>Hᴇʏ {message.from_user.mention}, Hᴇʀᴇ ɪs ᴛʜᴇ ʀᴇsᴜʟᴛ ғᴏʀ ʏᴏᴜʀ ᴏ̨ᴜᴇʀʏ {search} \n\n</b>"
cap = f"<b>Hᴇʏ {message.from_user.mention}, Fᴏᴜɴᴅ {total_results} Rᴇsᴜʟᴛs ғᴏʀ Yᴏᴜʀ Qᴜᴇʀʏ {search}\n\n</b>"
for file in files:
cap += f"<b>📁 <a href='https://telegram.me/{temp.U_NAME}?start=files_{file.file_id}'>[{get_size(file.file_size)}] {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@') and not x.startswith('www.'), file.file_name.split()))}\n\n</a></b>"
# if imdb and imdb.get('poster'):
# try:
# hehe = await message.reply_photo(photo=imdb.get('poster'), caption=cap[:1024], reply_markup=InlineKeyboardMarkup(btn))
# await m.delete()
# try:
# if settings['auto_delete']:
# await asyncio.sleep(300)
# await hehe.delete()
# await message.delete()
# except KeyError:
# await save_group_settings(message.chat.id, 'auto_delete', True)
# await asyncio.sleep(300)
# await hehe.delete()
# await message.delete()
# except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty):
# pic = imdb.get('poster')
# poster = pic.replace('.jpg', "._V1_UX360.jpg")
# #m=await message.reply_text("🔎")
# hmm = await message.reply_photo(photo=poster, caption=cap[:1024], reply_markup=InlineKeyboardMarkup(btn))
# await m.delete()
# try:
# if settings['auto_delete']:
# await asyncio.sleep(300)
# await hmm.delete()
# await message.delete()
# except KeyError:
# await save_group_settings(message.chat.id, 'auto_delete', True)
# await asyncio.sleep(300)
# await hmm.delete()
# await message.delete()
# except Exception as e:
# logger.exception(e)
# #m=await message.reply_text("🔎")
# fek = await message.reply_text(text=cap, reply_markup=InlineKeyboardMarkup(btn))
# await m.delete()
# try:
# if settings['auto_delete']:
# await asyncio.sleep(300)
# await fek.delete()
# await message.delete()
# except KeyError:
# await save_group_settings(message.chat.id, 'auto_delete', True)
# await asyncio.sleep(300)
# await fek.delete()
# await message.delete()
# else:
fuk = await message.reply_text(text=cap, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=True)
await m.delete()
try:
if settings['auto_delete']:
await asyncio.sleep(300)
await fuk.delete()
await message.delete()
except KeyError:
await save_group_settings(message.chat.id, 'auto_delete', True)
await asyncio.sleep(300)
await fuk.delete()
await message.delete()
# if spoll:
# await msg.message.delete()
async def advantage_spell_chok(client, msg):
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)
find = mv_rqst.split(" ")
query = ""
removes = ["in","upload", "series", "full", "horror", "thriller", "mystery", "print", "file"]
for x in find:
if x in removes:
continue
else:
query = query + x + " "
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|bro|bruh|broh|helo|that|find|dubbed|link|venum|iruka|pannunga|pannungga|anuppunga|anupunga|anuppungga|anupungga|film|undo|kitti|kitty|tharu|kittumo|kittum|movie|any(one)|with\ssubtitle(s)?)", "", query, flags=re.IGNORECASE)
query = re.sub(r"\s+", " ", query).strip() + "movie"
g_s = await search_gagala(query)
g_s += await search_gagala(msg.text)
gs_parsed = []
if not g_s:
reqst_gle = query.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
regex = re.compile(r".*(imdb|wikipedia).*", re.IGNORECASE) # look for imdb / wiki results
gs = list(filter(regex.match, g_s))
gs_parsed = [re.sub(
r'\b(\-([a-zA-Z-\s])\-\simdb|(\-\s)?imdb|(\-\s)?wikipedia|\(|\)|\-|reviews|full|all|episode(s)?|film|movie|series)',
'', i, flags=re.IGNORECASE) for i in gs]
if not gs_parsed:
reg = re.compile(r"watch(\s[a-zA-Z0-9_\s\-\(\)]*)*\|.*",
re.IGNORECASE) # match something like Watch Niram | Amazon Prime
for mv in g_s:
match = reg.match(mv)
if match:
gs_parsed.append(match.group(1))
movielist = []
gs_parsed = list(dict.fromkeys(gs_parsed)) # removing duplicates https://stackoverflow.com/a/7961425
if len(gs_parsed) > 3:
gs_parsed = gs_parsed[:3]
if gs_parsed:
for mov in gs_parsed:
imdb_s = await get_poster(mov.strip(), bulk=True) # searching each keyword in imdb
if imdb_s:
movielist += [movie.get('title') for movie in imdb_s]
movielist += [(re.sub(r'(\-|\(|\)|_)', '', i, flags=re.IGNORECASE)).strip() for i in gs_parsed]
movielist = list(dict.fromkeys(movielist)) # removing duplicates
if not movielist:
reqst_gle = query.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
SPELL_CHECK[msg.id] = movielist
btn = [[
InlineKeyboardButton(
text=movie.strip(),
callback_data=f"spolling#{reqstr1}#{k}",
)
] for k, movie 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(60)
await spell_check_del.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(60)
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 == "[]":
joelkb = 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
)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
try:
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
else:
button = eval(btn)
joelkb = 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
)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
try:
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
elif btn == "[]":
joelkb = 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
)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
try:
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
else:
button = eval(btn)
joelkb = await message.reply_cached_media(
fileid,
caption=reply_text or "",
reply_markup=InlineKeyboardMarkup(button),
reply_to_message_id=reply_id
)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
try:
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
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 == "[]":
joelkb = await client.send_message(
group_id,
reply_text,
disable_web_page_preview=True,
reply_to_message_id=reply_id
)
manual = await manual_filters(client, message)
if manual == False:
settings = await get_settings(message.chat.id)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
try:
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
else:
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
button = eval(btn)
joelkb = await client.send_message(
group_id,
reply_text,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(button),
reply_to_message_id=reply_id
)
manual = await manual_filters(client, message)
if manual == False:
settings = await get_settings(message.chat.id)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
try:
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
else:
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
elif btn == "[]":
joelkb = await client.send_cached_media(
group_id,
fileid,
caption=reply_text or "",
reply_to_message_id=reply_id
)
manual = await manual_filters(client, message)
if manual == False:
settings = await get_settings(message.chat.id)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
try:
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
else:
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
button = eval(btn)
joelkb = await message.reply_cached_media(
fileid,
caption=reply_text or "",
reply_markup=InlineKeyboardMarkup(button),
reply_to_message_id=reply_id
)
manual = await manual_filters(client, message)
if manual == False:
settings = await get_settings(message.chat.id)
try:
if settings['auto_ffilter']:
await auto_filter(client, message)
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
else:
try:
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await asyncio.sleep(600)
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_ffilter', True)
settings = await get_settings(message.chat.id)
if settings['auto_ffilter']:
await auto_filter(client, message)
else:
try:
if settings['auto_delete']:
await joelkb.delete()
except KeyError:
grpid = await active_connection(str(message.from_user.id))
await save_group_settings(grpid, 'auto_delete', True)
settings = await get_settings(message.chat.id)
if settings['auto_delete']:
await joelkb.delete()
except Exception as e:
logger.exception(e)
break
else:
return False