forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindsong.py
More file actions
32 lines (30 loc) · 1.31 KB
/
Findsong.py
File metadata and controls
32 lines (30 loc) · 1.31 KB
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
import requests
from telethon import events
from telethon.errors.rpcerrorlist import YouBlockedUserError
@ultroid_cmd(pattern="findsong$", outgoing=True)
async def _(event):
if event.fwd_from:
return
if not event.reply_to_msg_id:
await edit_delete(event, "Reply to an audio message.")
return
reply_message = await event.get_reply_message()
chat = "@auddbot"
snku = await edit_or_reply(event, "Identifying the song")
async with event.client.conversation(chat) as conv:
try:
start_msg = await conv.send_message("/start")
await conv.get_response()
await conv.send_message(reply_message)
check = await conv.get_response()
if not check.text.startswith("Audio received"):
return await snku.edit("An error while identifying the song. Try to use a 5-10s long audio message.")
await snku.edit("Wait just a sec...")
result = await conv.get_response()
await event.client.send_read_acknowledge(conv.chat_id)
except YouBlockedUserError:
await snku.edit("Please unblock (@auddbot) and try again")
return
namem = f"**Song Name : **{result.text.splitlines()[0]}\
\n\n**Details : **__{result.text.splitlines()[2]}__"
await snku.edit(namem)