-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinline.py
72 lines (68 loc) · 2.49 KB
/
inline.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
from pyrogram.types import (InlineKeyboardButton,
InlineKeyboardMarkup,
InlineQueryResultPhoto)
from youtubesearchpython.__future__ import VideosSearch
from config import BANNED_USERS, MUSIC_BOT_NAME
from AnonX import app
from AnonX.utils.inlinequery import answer
from strings.filters import command
@app.on_inline_query(~BANNED_USERS)
async def inline_query_handler(client, query):
text = query.query.strip().lower()
answers = []
if text.strip() == "":
try:
await client.answer_inline_query(
query.id, results=answer, cache_time=10
)
except:
return
else:
a = VideosSearch(text, limit=20)
result = (await a.next()).get("result")
for x in range(15):
title = (result[x]["title"]).title()
duration = result[x]["duration"]
views = result[x]["viewCount"]["short"]
thumbnail = result[x]["thumbnails"][0]["url"].split("?")[
0
]
channellink = result[x]["channel"]["link"]
channel = result[x]["channel"]["name"]
link = result[x]["link"]
published = result[x]["publishedTime"]
description = f"{views} | {duration} Mins | {channel} | {published}"
buttons = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="• ʏᴏᴜᴛᴜʙᴇ •",
url=link,
)
],
]
)
searched_text = f"""
📌 **ᴛɪᴛʟᴇ:** [{title}]({link})
⏳ **ᴅᴜʀᴀᴛɪᴏɴ:** {duration} Mins
👀 **ᴠɪᴇᴡs:** `{views}`
⏰ **ᴩᴜʙʟɪsʜᴇᴅ ᴏɴ:** {published}
🎥 **ᴄʜᴀɴɴᴇʟ:** {channel}
📎 **ᴄʜᴀɴɴᴇʟ ʟɪɴᴋ:** [ᴠɪsɪᴛ ᴄʜᴀɴɴᴇʟ]({channellink})
💖 **sᴇᴀʀᴄʜ ᴩᴏᴡᴇʀᴇᴅ ʙʏ {MUSIC_BOT_NAME}**"""
answers.append(
InlineQueryResultPhoto(
photo_url=thumbnail,
title=title,
thumb_url=thumbnail,
description=description,
caption=searched_text,
reply_markup=buttons,
)
)
try:
return await client.answer_inline_query(
query.id, results=answers
)
except:
return