# Made by @e3ris for Ultroid

# < https://github.com/TeamUltroid/Ultroid >

"""
✘ **Plugin to Get Lyrics** ☃️

✘ **CMD :**
>>  `{i}ilyrics <song_name>`

> Uses @iLyricsBot to get Lyrics.
> eg:- `{i}ilyrics <save your tears>`
"""

from telethon import events

chat = "iLyricsBot"

@ultroid_cmd(
    pattern="ilyrics ?(.*)",
    ignore_dualmode=True,
)
async def ilyrics(event):
    if event.fwd_from:
        return
    args = event.pattern_match.group(1)
    if not args:
        return await eod(
            event, "What Song should I search for?"
        )
    eris = await eor(event, "__Getting your lyrics..__")
    query = await ultroid.inline_query(
        chat, args, entity=event.chat_id,
    )
    if len(query) > 0:
        try:
            await query[0].click(
                silent=True,
                reply_to=event.reply_to_msg_id
            )
            await eris.delete()
        except Exception as e:
            return await eod(eris, e)
    else:
        await eod(eris, f"Couldn't find any Lyrics for :\n `{args}`")