-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.py
219 lines (201 loc) · 8.53 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# (c) @PredatorHackerzZ
# I just made this for searching a channel message from inline.
# Maybe you can use this for something else.
# I first made this for @TGBotListBot ...
# Edit according to your use.
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
# 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_text(Config.START_MSG.format(event.from_user.mention),
reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton("Bots Channel", url="https://t.me/TeleRoidGroup"),
InlineKeyboardButton("Support Group", url="https://t.me/TeleRoid14")],
[InlineKeyboardButton("♻ Help", callback_data="Help_msg"),
InlineKeyboardButton("👥 About", callback_data="About_msg")],
[InlineKeyboardButton(" Add Your Bots Here ", callback_data="addbots")],
[InlineKeyboardButton("Search Inline", switch_inline_query_current_chat=""), InlineKeyboardButton("Go Inline", switch_inline_query="")]
])
)
@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("🚸 Pᴏᴡᴇʀᴇᴅ Bʏ", url="https://t.me/MoviesFlixers_DL"),
InlineKeyboardButton("🌱 Inspired Channel ", url="https://t.me/TGRobot_List"),
InlineKeyboardButton("👥 About", callback_data="About_msg")],
[InlineKeyboardButton("Search Inline", switch_inline_query_current_chat=""), InlineKeyboardButton("Go Inline", switch_inline_query="")]
])
)
@Bot.on_inline_query()
async def inline_handlers(_, event: InlineQuery):
answers = list()
# If Search Query is Empty
if event.query == "":
answers.append(
InlineQueryResultArticle(
title="This is Inline BotList Search Bot 🔍",
description="You Can Search All Bots Available On TeleGram.",
thumb_url="https://telegra.ph/file/cb4099b549491a622c481.jpg",
input_message_content=InputTextMessageContent(
message_text="A dream does not become reality through magic; it takes sweat, determination, and hard work."\n
"<a>@TheTeleRoid || @Space_X_Bots</a>"\n
"<a>🔴 YouTube Channel :</a>"\n
"<a>https://youtube.com/channel/UCeAteLGyraSil9pErMFTZAg </a>"\n
"<a>👥 BotChat : @TeleRoid14 </a>"\n
"<a> Follow Our Bot Updates Channel : @TeleRoidGroup</a>",\n
disable_web_page_preview=True
),
reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton("Search Here", switch_inline_query_current_chat="")],
[InlineKeyboardButton("TeleRoid Bots", url="https://t.me/joinchat/t1ko_FOJxhFiOThl"),
InlineKeyboardButton("Bots Channel", url="https://t.me/TeleRoidGroup")],
[InlineKeyboardButton("TeleGram Bots", url="https://t.me/TGRobot_List")]
])
)
)
# Search Channel Message using Search Query Words
else:
async for message in User.search_messages(chat_id=Config.CHANNEL_ID, limit=50, query=event.query):
if message.text:
thumb = None
f_text = message.text
msg_text = message.text.html
if "|||" in message.text:
thumb = message.text.split("|||",1)[1].strip()
f_text = message.text.split("|||",1)[0]
msg_text = message.text.html.split("|||",1)[0]
answers.append(InlineQueryResultArticle(
title="{}".format(f_text.split("\n", 1)[0]),
description="{}".format(f_text.split("\n", 2)[-1]),
thumb_url=thumb,
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Search Again", switch_inline_query_current_chat=""), InlineKeyboardButton("Go Inline", switch_inline_query="")]]),
input_message_content=InputTextMessageContent(
message_text=msg_text,
parse_mode="html",
disable_web_page_preview=True
)
))
try:
await event.answer(
results=answers,
cache_time=0
)
print(f"[{Config.BOT_SESSION_NAME}] - Answered Successfully - {event.from_user.first_name}")
except QueryIdInvalid:
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("💢 Github", callback_data="https://github.com/PredatorHackerzZ/MessageSearchBot"),
InlineKeyboardButton("🚸 Powered By", url="https://t.me/MoviesFlixers_DL")
],
[
InlineKeyboardButton("👨💻 Developer ", url="https://t.me/TheTeleRoid"),
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("👥 About", callback_data="About_msg"),
InlineKeyboardButton("💢 Github Repo", url="https://t.me/Moviesflixers_DL")
],
[
InlineKeyboardButton("Bot List", url="https://t.me/joinchat/t1ko_FOJxhFiOThl"),
InlineKeyboardButton("🏠 Home", callback_data="gohome")
]
]
),
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("🛑 Support 🛑", url="https://t.me/TeleRoid14"),
InlineKeyboardButton("⭕ Channel ⭕", url="https://t.me/TeleRoidGroup")
],
[
InlineKeyboardButton("👥 Help", callback_data="Help_msg"),
InlineKeyboardButton("♻ About", callback_data="About_msg")
],
[
InlineKeyboardButton("+ Add Your Bots Here + ", callback_data="addbots")
],
[
InlineKeyboardButton("Search Inline ⤵", switch_inline_query_current_chat=""),
InlineKeyboardButton("Go Inline", switch_inline_query="")
]
]
),
parse_mode="html"
)
elif "addbots" in cb_data:
await cmd.message.edit(
text=Config.ADD_BOTS,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("👥 TeleRoid Support 👥", url="https://t.me/TeleRoid14"),
InlineKeyboardButton("👥 Space X Bots 👥", url="https://t.me/Sources_Codes")
],
[
InlineKeyboardButton("👥 CodeXBotz 👥", url="https://t.me/CodeXBotZSupport"),
InlineKeyboardButton("👥 Universal Bots 👥", url="https://t.me/JV_Community")
],
[
InlineKeyboardButton("👥 Heiman Support 👥", url="https://t.me/HeimanSupport"),
InlineKeyboardButton("👥 TGRobot Support👥", url="https://t.me/joinchat/rqSonBIiCP01NWI1")
],
[
InlineKeyboardButton("🏠 Home ", callback_data="gohome")
]
]
),
parse_mode="html"
)
# Start Clients
Bot.start()
User.start()
# Loop Clients till Disconnects
idle()
# After Disconnects,
# Stop Clients
Bot.stop()
User.stop()