-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
140 lines (131 loc) · 5.05 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
from configs import Config
from pyrogram import Client, filters, idle
from pyrogram.errors import QueryIdInvalid
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InlineQuery, InlineQueryResultArticle, \
InputTextMessageContent
from TeamTeleRoid.forcesub import ForceSub
import asyncio
# Bot Client for Inline Search
Bot = Client(
session_name=Config.BOT_SESSION_NAME,
api_id=Config.API_ID,
api_hash=Config.API_HASH,
bot_token=Config.BOT_TOKEN
)
# User Client for Searching in Channel.
User = Client(
session_name=Config.USER_SESSION_STRING,
api_id=Config.API_ID,
api_hash=Config.API_HASH
)
@Bot.on_message(filters.private & filters.command("start"))
async def start_handler(_, event: Message):
await event.reply_photo("https://telegra.ph/file/19eeb26fa2ce58765917a.jpg",
caption=Config.START_MSG.format(event.from_user.mention),
reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton('❤ Donation Link', url='https://www.telegram.dog/greymatters_about')],
[InlineKeyboardButton("Updates 𝙲𝚑𝚊𝚗𝚗𝚊𝚕", url="https://t.me/GreyMatter_Bots")],
[InlineKeyboardButton("Donation", callback_data="Help_msg"),
InlineKeyboardButton("About", callback_data="About_msg")]
]))
@Bot.on_message(filters.private & filters.command("help"))
async def help_handler(_, event: Message):
await event.reply_text(Config.ABOUT_HELP_TEXT.format(event.from_user.mention),
reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton('❤ Donation Link', url='https://www.telegram.dog/greymatters_about')
],[InlineKeyboardButton("Updates 𝙲𝚑𝚊𝚗𝚗𝚊𝚕", url="https://t.me/GreyMatter_Bots"),
InlineKeyboardButton("𝙰𝚋𝚘𝚞𝚝", callback_data="About_msg")]
])
)
@Bot.on_message(filters.incoming)
async def inline_handlers(_, event: Message):
if event.text == '/start':
return
answers = f'**📂 Results For ➠ {event.text} \n\n➠ Type Only Movie Name With Correct Spelling.✍️\n➠ Add Year For Better Result.🗓️\n➠ Join @GreyMatter_Bots\n▰▱▰▱▰▱▰▱▰▱▰▱▰▱\n\n**'
async for message in User.search_messages(chat_id=Config.CHANNEL_ID, 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**'
try:
msg = await event.reply_text(answers)
await asyncio.sleep(65)
await event.delete()
await msg.delete()
except:
print(f"[{Config.BOT_SESSION_NAME}] - Failed to Answer - {event.from_user.first_name}")
@Bot.on_callback_query()
async def button(bot, cmd: CallbackQuery):
cb_data = cmd.data
if "About_msg" in cb_data:
await cmd.message.edit(
text=Config.ABOUT_BOT_TEXT,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('❤ Donation Link', url='https://www.telegram.dog/greymatters_about')
],
[
InlineKeyboardButton("Updates 𝙲𝚑𝚊𝚗𝚗𝚊𝚕", url="https://t.me/GreyMatter_Bots")
],
[
InlineKeyboardButton("Home", callback_data="gohome")
]
]
),
parse_mode="html"
)
elif "Help_msg" in cb_data:
await cmd.message.edit(
text=Config.ABOUT_HELP_TEXT,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('❤ Donation Link', url='https://www.telegram.dog/greymatters_about')
],
[
InlineKeyboardButton("Updates 𝙲𝚑𝚊𝚗𝚗𝚊𝚕", url="https://t.me/GreyMatter_Bots")
],
[
InlineKeyboardButton("Home", callback_data="gohome"),
InlineKeyboardButton("About", callback_data="About_msg")
]
]
),
parse_mode="html"
)
elif "gohome" in cb_data:
await cmd.message.edit(
text=Config.START_MSG.format(cmd.from_user.mention),
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('❤ Donation Link', url='https://www.telegram.dog/greymatters_about')
],
[
InlineKeyboardButton("Updates 𝙲𝚑𝚊𝚗𝚗𝚊𝚕", url="https://t.me/GreyMatter_Bots")
],
[
InlineKeyboardButton("Donation", callback_data="Help_msg"),
InlineKeyboardButton("About", callback_data="About_msg")
]
]
),
parse_mode="html"
)
# Start Clients
Bot.start()
User.start()
# Loop Clients till Disconnects
idle()
# After Disconnects,
# Stop Clients
Bot.stop()
User.stop()