This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
pm_filter.py
710 lines (656 loc) · 26.5 KB
/
pm_filter.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
#Kanged From @TroJanZheX
import asyncio
import re
import ast
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, CUSTOM_FILE_CAPTION, AUTH_GROUPS, P_TTI_SHOW_OFF, IMDB, SINGLE_BUTTON, SPELL_CHECK_REPLY, IMDB_TEMPLATE
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
from pyrogram import Client, filters
from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid
from utils import get_size, is_subscribed, get_poster, temp
from database.users_chats_db import db
from database.ia_filterdb import Media, get_file_details, get_search_results
from database.filters_mdb import(
del_all,
find_filter,
get_filters,
)
BUTTONS = {}
SPELL_CHECK = {}
@Client.on_message(filters.group & filters.text & filters.incoming)
async def give_filter(client,message):
group_id = message.chat.id
name = message.text
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 == "[]":
await message.reply_text(reply_text, disable_web_page_preview=True)
else:
button = eval(btn)
await message.reply_text(
reply_text,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(button)
)
elif btn == "[]":
await message.reply_cached_media(
fileid,
caption=reply_text or ""
)
else:
button = eval(btn)
await message.reply_cached_media(
fileid,
caption=reply_text or "",
reply_markup=InlineKeyboardMarkup(button)
)
except Exception as e:
print(e)
break
else:
await auto_filter(client, message)
@Client.on_callback_query(filters.regex(r"^next"))
async def next_page(bot, query):
ident, req, key, offset = query.data.split("_")
if int(req) not in [query.from_user.id, 0]:
return await query.answer("oKda", show_alert=True)
try:
offset = int(offset)
except:
offset = 0
search = BUTTONS.get(key)
if not search:
await query.answer("You are using this for one of my old message, please send the request again.",show_alert=True)
return
files, n_offset, total = await get_search_results(search, offset=offset, filter=True)
try:
n_offset = int(n_offset)
except:
n_offset = 0
if not files:
return
if SINGLE_BUTTON:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {file.file_name}", callback_data=f'files#{file.file_id}'
),
]
for file in files
]
else:
btn = [
[
InlineKeyboardButton(
text=f"{file.file_name}", 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
]
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("⏪ BACK", callback_data=f"next_{req}_{key}_{off_set}"), InlineKeyboardButton(f"📃 Pages {round(int(offset)/10)+1} / {round(total/10)}", callback_data="pages")]
)
elif off_set is None:
btn.append([InlineKeyboardButton(f"🗓 {round(int(offset)/10)+1} / {round(total/10)}", callback_data="pages"), InlineKeyboardButton("NEXT ⏩", callback_data=f"next_{req}_{key}_{n_offset}")])
else:
btn.append(
[
InlineKeyboardButton("⏪ BACK", callback_data=f"next_{req}_{key}_{off_set}"),
InlineKeyboardButton(f"🗓 {round(int(offset)/10)+1} / {round(total/10)}", callback_data="pages"),
InlineKeyboardButton("NEXT ⏩", callback_data=f"next_{req}_{key}_{n_offset}")
],
)
try:
await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(btn)
)
except MessageNotModified:
pass
await query.answer()
@Client.on_callback_query(filters.regex(r"^spolling"))
async def advantage_spoll_choker(bot, query):
_, user, movie_ = query.data.split('#')
movies = SPELL_CHECK.get(query.message.reply_to_message.message_id)
if not movies:
return await query.answer("You are clicking on an old button which is expired.", show_alert=True)
movie = movies[(int(movie_))]
if int(user) != 0 and query.from_user.id != int(user):
return await query.answer("okDa", show_alert=True)
if movie_ == "close_spellcheck":
return await query.message.delete()
await query.answer('Checking for Movie in database...')
files, offset, total_results = await get_search_results(movie, offset=0, filter=True)
if files:
k = (movie, files, offset, total_results)
await auto_filter(bot, query, k)
else:
k = await query.message.edit('This Movie Not Found In DataBase')
await asyncio.sleep(10)
await k.delete()
@Client.on_callback_query()
async def cb_handler(client: Client, query: CallbackQuery):
if query.data == "close_data":
await query.message.delete()
elif query.data == "delallconfirm":
userid = query.from_user.id
chat_type = query.message.chat.type
if chat_type == "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("Make sure I'm present in your group!!", quote=True)
return
else:
await query.message.edit_text(
"I'm not connected to any groups!\nCheck /connections or connect to any groups",
quote=True
)
return
elif chat_type in ["group", "supergroup"]:
grp_id = query.message.chat.id
title = query.message.chat.title
else:
return
st = await client.get_chat_member(grp_id, userid)
if (st.status == "creator") or (str(userid) in ADMINS):
await del_all(query.message, grp_id, title)
else:
await query.answer("You need to be Group Owner or an Auth User to do that!",show_alert=True)
elif query.data == "delallcancel":
userid = query.from_user.id
chat_type = query.message.chat.type
if chat_type == "private":
await query.message.reply_to_message.delete()
await query.message.delete()
elif chat_type in ["group", "supergroup"]:
grp_id = query.message.chat.id
st = await client.get_chat_member(grp_id, userid)
if (st.status == "creator") or (str(userid) in ADMINS):
await query.message.delete()
try:
await query.message.reply_to_message.delete()
except:
pass
else:
await query.answer("Thats not for you!!",show_alert=True)
elif "groupcb" in query.data:
await query.answer()
group_id = query.data.split(":")[1]
title = query.data.split(":")[2]
act = query.data.split(":")[3]
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}:{title}"),
InlineKeyboardButton("DELETE", callback_data=f"deletecb:{group_id}")],
[InlineKeyboardButton("BACK", callback_data="backcb")]
])
await query.message.edit_text(
f"Group Name : **{title}**\nGroup ID : `{group_id}`",
reply_markup=keyboard,
parse_mode="md"
)
return
elif "connectcb" in query.data:
await query.answer()
group_id = query.data.split(":")[1]
title = query.data.split(":")[2]
user_id = query.from_user.id
mkact = await make_active(str(user_id), str(group_id))
if mkact:
await query.message.edit_text(
f"Connected to **{title}**",
parse_mode="md"
)
else:
await query.message.edit_text('Some error occured!!', parse_mode="md")
return
elif "disconnect" in query.data:
await query.answer()
title = query.data.split(":")[2]
user_id = query.from_user.id
mkinact = await make_inactive(str(user_id))
if mkinact:
await query.message.edit_text(
f"Disconnected from **{title}**",
parse_mode="md"
)
else:
await query.message.edit_text('Some error occured!!', parse_mode="md")
return
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(
"Successfully deleted connection"
)
else:
await query.message.edit_text('Some error occured!!', parse_mode="md")
return
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(
"There are no active connections!! Connect to some groups first.",
)
return
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}:{title}:{act}"
)
]
)
except:
pass
if buttons:
await query.message.edit_text(
"Your connected group details ;\n\n",
reply_markup=InlineKeyboardMarkup(buttons)
)
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"):
ident, file_id = query.data.split("#")
files_ = await get_file_details(file_id)
if not files_:
return await query.answer('No such file exist.')
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=title, file_size=size, file_caption=f_caption)
except Exception as e:
print(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):
await query.answer(url=f"https://t.me/{temp.U_NAME}?start={file_id}")
return
elif P_TTI_SHOW_OFF:
await query.answer(url=f"https://t.me/{temp.U_NAME}?start={file_id}")
return
else:
await client.send_cached_media(
chat_id=query.from_user.id,
file_id=file_id,
caption=f_caption
)
await query.answer('Check PM, I have sent files in pm',show_alert = True)
except UserIsBlocked:
await query.answer('Unblock the bot mahn !',show_alert = True)
except PeerIdInvalid:
await query.answer(url=f"https://t.me/{temp.U_NAME}?start={file_id}")
except Exception as e:
await query.answer(url=f"https://t.me/{temp.U_NAME}?start={file_id}")
elif query.data.startswith("checksub"):
if AUTH_CHANNEL and not await is_subscribed(client, query):
await query.answer("I Like Your Smartness, But Don't Be Oversmart 😒",show_alert=True)
return
ident, file_id = query.data.split("#")
files_ = await get_file_details(file_id)
if not files_:
return await query.answer('No such file exist.')
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=title, file_size=size, file_caption=f_caption)
except Exception as e:
print(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
)
elif query.data == "pages":
await query.answer()
elif query.data == "start":
buttons = [[
InlineKeyboardButton('➕ Add Me To Your Groups ➕', url=f'http://t.me/{temp.U_NAME}?startgroup=true')
],[
InlineKeyboardButton('🔍 Search', switch_inline_query_current_chat=''),
InlineKeyboardButton('🤖 Updates', url='https://t.me/EvaMariaUpdates')
],[
InlineKeyboardButton('ℹ️ Help', callback_data='help'),
InlineKeyboardButton('😊 About', callback_data='about')
]]
reply_markup = InlineKeyboardMarkup(buttons)
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='html'
)
elif query.data == "help":
buttons = [[
InlineKeyboardButton('Manual Filter', callback_data='manuelfilter'),
InlineKeyboardButton('Auto Filter', callback_data='autofilter')
],[
InlineKeyboardButton('Connection', callback_data='coct'),
InlineKeyboardButton('Extra Mods', callback_data='extra')
],[
InlineKeyboardButton('🏠 Home', callback_data='start'),
InlineKeyboardButton('🔮 Status', callback_data='stats')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.HELP_TXT.format(query.from_user.mention),
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "about":
buttons= [[
InlineKeyboardButton('🤖 Updates', url='https://t.me/EvaMariaUpdates'),
InlineKeyboardButton('♥️ Source', callback_data='source')
],[
InlineKeyboardButton('🏠 Home', callback_data='start'),
InlineKeyboardButton('🔐 Close', callback_data='close_data')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.ABOUT_TXT.format(temp.B_NAME),
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "source":
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='about')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.SOURCE_TXT,
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "manuelfilter":
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='help'),
InlineKeyboardButton('⏹️ Buttons', callback_data='button')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.MANUELFILTER_TXT,
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "button":
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='manuelfilter')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.BUTTON_TXT,
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "autofilter":
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='help')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.AUTOFILTER_TXT,
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "coct":
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='help')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.CONNECTION_TXT,
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "extra":
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='help'),
InlineKeyboardButton('👮♂️ Admin', callback_data='admin')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.EXTRAMOD_TXT,
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "admin":
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='extra')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await query.message.edit_text(
text=script.ADMIN_TXT,
reply_markup=reply_markup,
parse_mode='html'
)
elif query.data == "stats":
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='help'),
InlineKeyboardButton('♻️', callback_data='rfrsh')
]]
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='html'
)
elif query.data == "rfrsh":
await query.answer("Fetching MongoDb DataBase")
buttons = [[
InlineKeyboardButton('👩🦯 Back', callback_data='help'),
InlineKeyboardButton('♻️', callback_data='rfrsh')
]]
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='html'
)
async def auto_filter(client, msg, spoll=False):
if not spoll:
message = msg
if re.findall("((^\/|^,|^!|^\.|^[\U0001F600-\U000E007F]).*)", message.text):
return
if 2 < len(message.text) < 100:
search = message.text
files, offset, total_results = await get_search_results(search.lower(), offset=0, filter=True)
if not files:
if SPELL_CHECK_REPLY:
return await advantage_spell_chok(msg)
else:
return
else:
return
else:
message = msg.message.reply_to_message # msg will be callback query
search, files, offset, total_results = spoll
if SINGLE_BUTTON:
btn = [
[
InlineKeyboardButton(
text=f"[{get_size(file.file_size)}] {file.file_name}", callback_data=f'files#{file.file_id}'
),
]
for file in files
]
else:
btn = [
[
InlineKeyboardButton(
text=f"{file.file_name}",
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
]
if offset != "":
key = f"{message.chat.id}-{message.message_id}"
BUTTONS[key] = search
req = message.from_user.id if message.from_user else 0
btn.append(
[InlineKeyboardButton(text=f"🗓 1/{round(int(total_results)/10)}",callback_data="pages"), InlineKeyboardButton(text="NEXT ⏩",callback_data=f"next_{req}_{key}_{offset}")]
)
else:
btn.append(
[InlineKeyboardButton(text="🗓 1/1",callback_data="pages")]
)
imdb = await get_poster(search) if IMDB else None
if imdb:
cap = IMDB_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']
)
else:
cap = "Here is what i found for your query {search}"
if imdb and imdb.get('poster'):
try:
await message.reply_photo(photo=imdb.get('poster'), caption=cap, reply_markup=InlineKeyboardMarkup(btn))
except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty):
pic = imdb.get('poster')
poster = pic.replace('.jpg', "._V1_UX360.jpg")
await message.reply_photo(photo=poster, caption=cap, reply_markup=InlineKeyboardMarkup(btn))
except Exception as e:
print(e)
await message.reply_text(cap, reply_markup=InlineKeyboardMarkup(btn))
else:
await message.reply_text(cap, reply_markup=InlineKeyboardMarkup(btn))
if spoll:
await msg.message.delete()
async def advantage_spell_chok(msg):
query = re.sub(r"\b(pl(i|e)*?(s|z+|ease|se|ese|(e+)s(e)?)|send|snd|movie(s)?|new|latest|br((o|u)h?)*|^h(e)?(l)*(o)*|mal(ayalam)?|tamil|file|that|give|find|und(o)*|kit(t(i|y)?)?o(w)?|thar(o)*w?|kittum(o)*|aya(k)*(um(o)*)?|full\smovie|any(one)|with\ssubtitle)", "", msg.text) # plis contribute some common words
query = query.strip()
if not query:
k = await msg.reply("No valid movie name given")
await asyncio.sleep(8)
await k.delete()
return
user = msg.from_user.id if msg.from_user else 0
imdb_s = await get_poster(query, bulk=True)
movielist = [movie.get('title') for movie in imdb_s]
splitted = query.split()
if len(splitted) > 10:
k = await msg.reply("Are you telling the story of some movie??")
await asyncio.sleep(8)
await k.delete()
return
if len(splitted) > 1:
movielist += splitted
if len(splitted) % 2 == 0:
movielist += [f"{ko[1]} {splitted[ko[0] + 1]}" for ko in enumerate(splitted) if ko[0] % 2 == 0]
elif splitted[:-1]:
movielist += [f"{ko[1]} {splitted[:-1][ko[0] + 1]}" for ko in enumerate(splitted[:-1]) if ko[0] % 2 == 0]
SPELL_CHECK[msg.message_id] = movielist
btn = [[
InlineKeyboardButton(
text=movie,
callback_data=f"spolling#{user}#{k}",
)
] for k, movie in enumerate(movielist)]
btn.append([InlineKeyboardButton(text="Close", callback_data=f'spolling#{user}#close_spellcheck')])
await msg.reply('I cant find anything related to that\nDid you mean any one of these?', reply_markup=InlineKeyboardMarkup(btn))