diff --git a/README.md b/README.md index ab69d5b..4973998 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,11 @@ fsub - Add a Force Subscribe Channel connections - Get connected channels list ``` -#### Credits :- +## Deploy + +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/PREETMEHRA73638/Channel-Filter-Bot) -[CyniteOfficial](https://github.com/cyniteofficial) - Developer +#### Credits :- +[CyniteOfficial](https://github.com/cyniteofficial) - Develo [@GreyMatter_Bots](https://www.telegram.dog/GreyMatter_Bots) - Me For Promoting This Open Source Project. diff --git a/info.py b/info.py index e5b13ee..fc75e82 100644 --- a/info.py +++ b/info.py @@ -1,8 +1,8 @@ -API_ID = -API_HASH = "" -BOT_TOKEN = "" -SESSION = "" -DATABASE_URI = "" -LOG_CHANNEL = -1001884373226 -ADMIN = 1350642629 -CHANNEL = "@GreyMatter_Bots" +API_ID = 25830285 +API_HASH = "0cbcabbf1b9c56a4dfc4b8950d584a2a" +BOT_TOKEN = "6643363347:AAGt8cOiwVRVHMM9fHvqFnfcG1J0Gn9YtDw" +SESSION = "BQGKI40AwawvpZtk71oauU9kev_oPsIbxu9Opw734HvCBryu3mhzeaTZ0kVsaK6BVMfSRLdbZ_5_B5rPOqbizUB2Aio0CNzkGzZsAQEB5r0YiIzSxIcEVLywLaINg9LDvaGYn8y2rFRPTjSnNDhO0J3jOUCKQKMhxeyCL9VRqaqqUi8tuZrNnPuCUQE1AzMB3gN4uMY3m7ZJN1_ai7GdgCH51Q8meexX4sv8vzKAzPyqa-VLLRG_MHifqdzh6_pxe3D7dRFzLt5Qkfwqyo64aZvGhiiYmozvNZYIYcemYnhGIOYFIE2qn5OWE8THUuo8AoZEpVmhUE_kYsb_CEeUnItvxwCHHgAAAAFrQhqtAA" +DATABASE_URI = "mongodb+srv://hegodal811:obE9Ljvn0AHXbWeL@cluster0.lls1gnb.mongodb.net/?retryWrites=true&w=majority" +LOG_CHANNEL = -1001961336094 +ADMIN = 6094461613 +CHANNEL = "@Movies_channel_7863" diff --git a/main.py b/main.py index cd642f0..6e8f2fa 100644 --- a/main.py +++ b/main.py @@ -2,4 +2,3 @@ print("Bot Started πŸ’₯") Bot().run() - diff --git a/plugins/search.py b/plugins/search.py index ae51925..813aea1 100644 --- a/plugins/search.py +++ b/plugins/search.py @@ -1,93 +1,53 @@ import asyncio -from info import * -from utils import * -from time import time -from client import User -from pyrogram import Client, filters -from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton +from pyrogram import Client, filters, idle +from pyrogram.errors import QueryIdInvalid +from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InlineQuery, InlineQueryResultArticle, \ + InputTextMessageContent +from plugins.fsub import fsub +# Bot Client for Inline Search +Bot = Client( + session_name=info.SESSION, + api_id=info.API_ID, + api_hash=info.API_HASH, + bot_token=info.BOT_TOKEN +) -@Client.on_message(filters.text & filters.group & filters.incoming & ~filters.command(["verify", "connect", "id"])) -async def search(bot, message): - f_sub = await force_sub(bot, message) - if f_sub==False: - return - channels = (await get_group(message.chat.id))["channels"] - if bool(channels)==False: - return - if message.text.startswith("/"): - return - query = message.text - head = "Here is the results πŸ‘‡\n\nPromoted By @GreyMatter_Bots\n\n" - results = "" - try: - for channel in channels: - async for msg in User.search_messages(chat_id=channel, query=query): - name = (msg.text or msg.caption).split("\n")[0] - if name in results: - continue - results += f"♻️ {name}\nπŸ”— {msg.link}\n\n" - if bool(results)==False: - movies = await search_imdb(query) - buttons = [] - for movie in movies: - buttons.append([InlineKeyboardButton(movie['title'], callback_data=f"recheck_{movie['id']}")]) - msg = await message.reply_photo(photo="https://telegra.ph/file/cf6706158b0bfaf436f54.jpg", - caption="I Couldn't find anything related to Your QueryπŸ˜•.\nDid you mean any of these?", - reply_markup=InlineKeyboardMarkup(buttons)) - else: - msg = await message.reply_text(text=head+results, disable_web_page_preview=True) - _time = (int(time()) + (15*60)) - await save_dlt_message(msg, _time) - except: - pass - - - -@Client.on_callback_query(filters.regex(r"^recheck")) -async def recheck(bot, update): - clicked = update.from_user.id - try: - typed = update.message.reply_to_message.from_user.id - except: - return await update.message.delete(2) - if clicked != typed: - return await update.answer("That's not for you! πŸ‘€", show_alert=True) +# User Client for Searching in Channel. +User = Client( + session_name=info.SESSION, + api_id=info.API_ID, + api_hash=info.API_HASH +) - m=await update.message.edit("Searching..πŸ’₯") - id = update.data.split("_")[-1] - query = await search_imdb(id) - channels = (await get_group(update.message.chat.id))["channels"] - head = "I Have Searched Movie With Wrong Spelling But Take care next time πŸ‘‡\n\nPromoted By @GreyMatter_Bots\n\n" - results = "" +@Bot.on_message(filters.incoming) +async def inline_handlers(_, event: Message): + if event.text == '/start': + return + answers = f'**Searching For "{event.text}" πŸ”**' + async for message in User.search_messages(chat_id=info.CHANNEL, limit=50, query=event.text): + if message.text: + thumb = None + f_text = message.text + msg_text = message.text.html + if "|||" in message.text: + f_text = message.text.split("|||", 1)[0] + msg_text = message.text.html.split("|||", 1)[0] + answers += f'**🍿 Title ➠ ' + '' + f_text.split("\n", 1)[0] + '' + '\n\nπŸ“œ About ➠ ' + '' + f_text.split("\n", 2)[-1] + ' \n\nβ–°β–±β–°β–±β–°β–±β–°β–±β–°β–±β–°β–±β–°β–±\nLink Will Auto Delete In 60Sec...⏰\nβ–°β–±β–°β–±β–°β–±β–°β–±β–°β–±β–°β–±β–°β–±\n\n**' try: - for channel in channels: - async for msg in User.search_messages(chat_id=channel, query=query): - name = (msg.text or msg.caption).split("\n")[0] - if name in results: - continue - results += f"β™»οΈπŸΏ {name}\n\nπŸ”— {msg.link}\n\n" - if bool(results)==False: - return await update.message.edit("Still no results found! Please Request To Group Admin", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("🎯 Request To Admin 🎯", callback_data=f"request_{id}")]])) - await update.message.edit(text=head+results, disable_web_page_preview=True) - except Exception as e: - await update.message.edit(f"❌ Error: `{e}`") - - -@Client.on_callback_query(filters.regex(r"^request")) -async def request(bot, update): - clicked = update.from_user.id - try: - typed = update.message.reply_to_message.from_user.id + msg = await event.reply_text(answers) + await asyncio.sleep(60) + await event.delete() + await msg.delete() except: - return await update.message.delete() - if clicked != typed: - return await update.answer("That's not for you! πŸ‘€", show_alert=True) + print(f"[{info.SESSION}] - Failed to Answer - {event.from_user.first_name}") + - admin = (await get_group(update.message.chat.id))["user_id"] - id = update.data.split("_")[1] - name = await search_imdb(id) - url = "https://www.imdb.com/title/tt"+id - text = f"#RequestFromYourGroup\n\nName: {name}\nIMDb: {url}" - await bot.send_message(chat_id=admin, text=text, disable_web_page_preview=True) - await update.answer("βœ… Request Sent To Admin", show_alert=True) - await update.message.delete(60) +# Start Clients +Bot.start() +User.start() +# Loop Clients till Disconnects +idle() +# After Disconnects, +# Stop Clients +Bot.stop() +User.stop() diff --git a/utils/script.py b/utils/script.py index 44e7c52..e3dd339 100644 --- a/utils/script.py +++ b/utils/script.py @@ -7,7 +7,7 @@ class script(object): HELP = """To Use me In A Group - Add me in your group & channel with all permissions. -- Send /verify in group & wait for It To Accept Or Directly Contact To Owner After Request @GreyMatter_Bots. +- Send /verify in group & wait for It To Accept Or Directly Contact To Owner After Request @ROYAL_PREET_MEHRA_786. - After verification send /connect YourChannelID - Example : /connect -100xxxxxxxxxx - Done βœ…. Enjoy πŸ’œβ€ )