Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 8 additions & 8 deletions info.py
Original file line number Diff line number Diff line change
@@ -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"
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

print("Bot Started 💥")
Bot().run()

134 changes: 47 additions & 87 deletions plugins/search.py
Original file line number Diff line number Diff line change
@@ -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 = "<u>Here is the results 👇\n\nPromoted By </u> <b><I>@GreyMatter_Bots</I></b>\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"<b><I>♻️ {name}\n🔗 {msg.link}</I></b>\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="<b><I>I Couldn't find anything related to Your Query😕.\nDid you mean any of these?</I></b>",
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 = "<u>I Have Searched Movie With Wrong Spelling But Take care next time 👇\n\nPromoted By </u> <b><I>@GreyMatter_Bots</I></b>\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"<b><I>♻️🍿 {name}</I></b>\n\n🔗 {msg.link}</I></b>\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()
2 changes: 1 addition & 1 deletion utils/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ✅. <b><I>Enjoy 💜❤</I></b> )
Expand Down