async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit("`Error: No scrobbling data found.`") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@SpotifyMusicDownloaderBot" await event.edit("`Getting Your Music`") async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Downloading...`") try: response = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930)) msg = await bot.send_message(chat, track) respond = await response res = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930)) r = await res await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply( "`Unblock `@SpotifyMusicDownloaderBot` and retry`") return await bot.forward_messages(event.chat_id, respond.message) await event.client.delete_messages(conv.chat_id, [msg.id, r.id, respond.id]) await event.delete()
async def lyrics(lyric): await lyric.edit("Getting information...") if GENIUS is None: await lyric.edit("Provide genius access token to Heroku ConfigVars...") return False if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: await lyric.edit("No information current lastfm scrobbling...") return False artist = playing.get_artist() song = playing.get_title() else: artist = lyric.pattern_match.group(2) song = lyric.pattern_match.group(3) await lyric.edit(f"Searching lyrics for {artist} - {song}...") songs = genius.search_song(song, artist) if songs is None: await lyric.edit(f"Song **{artist} - {song}** not found...") return False if len(songs.lyrics) > 4096: await lyric.edit("Lyrics is too big, view the file to see it.") with open("lyrics.txt", "w+") as f: f.write(f"Search query: \n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file( lyric.chat_id, "lyrics.txt", reply_to=lyric.id, ) os.remove("lyrics.txt") else: await lyric.edit(f"**Search query**:\n{artist} - {song}" f"\n\n{songs.lyrics}") return True
async def lyrics(lyric): await lyric.edit("**Processing...**") if GENIUS is None: return await lyric.edit("**Add Genius access token to config vars.**") if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await lyric.edit( "**LastFM says you're not playing anything right now.**") artist = playing.get_artist() song = playing.get_title() else: artist = lyric.pattern_match.group(2) song = lyric.pattern_match.group(3) await lyric.edit(f"**Searching lyrics for** `{artist} - {song}`**...**") songs = genius.search_song(song, artist) if songs is None: return await lyric.edit( f"**Couldn't find lyrics for** `{artist} - {song}`**.**") if len(songs.lyrics) > 4096: await lyric.edit("**Uploading lyrics as file...**") with open("lyrics.txt", "w+") as f: f.write(f"Search query: \n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file(lyric.chat_id, "lyrics.txt", reply_to=lyric.id) os.remove("lyrics.txt") else: await lyric.edit(f"**Search query**:\n`{artist}` - `{song}`" f"\n\n{songs.lyrics}")
async def get_curr_track(lfmbio): # sourcery no-metrics oldartist = "" oldsong = "" while LASTFM_.LASTFMCHECK: try: if LASTFM_.USER_ID == 0: LASTFM_.USER_ID = (await lfmbio.client.get_me()).id user_info = await catub(GetFullUserRequest(LASTFM_.USER_ID)) LASTFM_.RUNNING = True playing = User(LASTFM_USERNAME, lastfm).get_now_playing() LASTFM_.SONG = playing.get_title() LASTFM_.ARTIST = playing.get_artist() oldsong = environ.get("oldsong", None) oldartist = environ.get("oldartist", None) if (playing is not None and LASTFM_.SONG != oldsong and LASTFM_.ARTIST != oldartist): environ["oldsong"] = str(LASTFM_.SONG) environ["oldartist"] = str(LASTFM_.ARTIST) if BIO_PREFIX: lfmbio = f"{BIO_PREFIX} 🎧: {LASTFM_.ARTIST} - {LASTFM_.SONG}" else: lfmbio = f"🎧: {LASTFM_.ARTIST} - {LASTFM_.SONG}" try: if BOTLOG and LASTFM_.LastLog: await catub.send_message( BOTLOG_CHATID, f"Attempted to change bio to\n{lfmbio}") await catub(UpdateProfileRequest(about=lfmbio)) except AboutTooLongError: short_bio = f"🎧: {LASTFM_.SONG}" await catub(UpdateProfileRequest(about=short_bio)) if playing is None and user_info.about != DEFAULT_BIO: await sleep(6) await catub(UpdateProfileRequest(about=DEFAULT_BIO)) if BOTLOG and LASTFM_.LastLog: await catub.send_message( BOTLOG_CHATID, f"Reset bio back to\n{DEFAULT_BIO}") except AttributeError: try: if user_info.about != DEFAULT_BIO: await sleep(6) await catub(UpdateProfileRequest(about=DEFAULT_BIO)) if BOTLOG and LASTFM_.LastLog: await catub.send_message( BOTLOG_CHATID, f"Reset bio back to\n{DEFAULT_BIO}") except FloodWaitError as err: if BOTLOG and LASTFM_.LastLog: await catub.send_message(BOTLOG_CHATID, f"Error changing bio:\n{err}") except ( FloodWaitError, WSError, MalformedResponseError, AboutTooLongError, ) as err: if BOTLOG and LASTFM_.LastLog: await catub.send_message(BOTLOG_CHATID, f"Error changing bio:\n{err}") await sleep(2) LASTFM_.RUNNING = False
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit("`Error: No current scrobble found.`") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@WooMaiBot" link = f"/netease {track}" await event.edit("`Searching...`") async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Downloading...Please wait`") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply("`Please unblock @WooMaiBot and try again`") return await event.edit("`Sending Your Music...`") await asyncio.sleep(3) await bot.send_file(event.chat_id, respond) await event.client.delete_messages(conv.chat_id, [msg.id, response.id, respond.id]) await event.delete()
async def get_curr_track(lfmbio): global ARTIST global SONG global LASTFMCHECK global RUNNING global USER_ID oldartist = "" oldsong = "" while LASTFMCHECK: try: if USER_ID == 0: USER_ID = (await lfmbio.client.get_me()).id user_info = await bot(GetFullUserRequest(USER_ID)) RUNNING = True playing = User(LASTFM_USERNAME, lastfm).get_now_playing() SONG = playing.get_title() ARTIST = playing.get_artist() oldsong = environ.get("oldsong", None) oldartist = environ.get("oldartist", None) if playing is not None and SONG != oldsong and ARTIST != oldartist: environ["oldsong"] = str(SONG) environ["oldartist"] = str(ARTIST) if BIOPREFIX: lfmbio = f"{BIOPREFIX} 🎧: {ARTIST} - {SONG}" else: lfmbio = f"🎧: {ARTIST} - {SONG}" try: if BOTLOG and LastLog: await bot.send_message(BOTLOG_CHATID, f"Attempted to change bio to\n{lfmbio}") await bot(UpdateProfileRequest(about=lfmbio)) except AboutTooLongError: short_bio = f"🎧: {SONG}" await bot(UpdateProfileRequest(about=short_bio)) else: if playing is None and user_info.about != DEFAULT_BIO: await sleep(6) await bot(UpdateProfileRequest(about=DEFAULT_BIO)) if BOTLOG and LastLog: await bot.send_message(BOTLOG_CHATID, f"Reset bio back to\n{DEFAULT_BIO}") except AttributeError: try: if user_info.about != DEFAULT_BIO: await sleep(6) await bot(UpdateProfileRequest(about=DEFAULT_BIO)) if BOTLOG and LastLog: await bot.send_message(BOTLOG_CHATID, f"Reset bio back to\n{DEFAULT_BIO}") except FloodWaitError as err: if BOTLOG and LastLog: await bot.send_message(BOTLOG_CHATID, f"Error changing bio:\n{err}") except FloodWaitError as err: if BOTLOG and LastLog: await bot.send_message(BOTLOG_CHATID, f"Error changing bio:\n{err}") except WSError as err: if BOTLOG and LastLog: await bot.send_message(BOTLOG_CHATID, f"Error changing bio:\n{err}") await sleep(2) RUNNING = False
async def lyrics(lyric): if r"-" in lyric.text: pass else: return await lyric.edit( "`Aborted: Please use '-' as divider for **<artist> " "& <song name>**`\neg: `Nicki Minaj - Super Bass`") if GENIUS is None: await lyric.edit( "`Provide genius access token to Heroku ConfigVars...`") return False if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: await lyric.edit("`No information current lastfm scrobbling...`") return False artist = playing.get_artist() song = playing.get_title() else: genius = lyricsgenius.Genius(GENIUS) try: args = lyric.text.split('.lyrics')[1].split('-') artist = args[0].strip(' ') song = args[1].strip(' ') except Exception: return await lyric.edit( "`LMAO please provide artist and song names`") if len(args) < 1: return await lyric.edit("`Please provide artist and song names`") await lyric.edit(f"`Searching lyrics for {artist} - {song}...`") songs = genius.search_song(song, artist) if songs is None: await lyric.edit(f"`Song` **{artist} - {song}** `not found...`") return False if len(songs.lyrics) > 4096: await lyric.edit("`Lyrics is too big, view the file to see it.`") with open("lyrics.txt", "w+") as f: f.write(f"Search query: \n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file( lyric.chat_id, "lyrics.txt", reply_to=lyric.id, ) os.remove("lyrics.txt") return True else: await lyric.edit(f"**Search query**:\n`{artist}` - `{song}`" f"\n\n```{songs.lyrics}```") return True
async def last_fm(lastFM): if lastFM.fwd_from: return """ For .lastfm command, fetch scrobble data from last.fm. """ if not lastFM.text[0].isalpha() and lastFM.text[0] not in ("/", "#", "@", "!"): await lastFM.edit("Processing...") preview = None playing = User(LASTFM_USERNAME, lastfm).get_now_playing() username = f"https://www.last.fm/user/{LASTFM_USERNAME}" if playing is not None: try: image = (User(LASTFM_USERNAME, lastfm).get_now_playing().get_cover_image()) except IndexError: image = None tags = gettags(isNowPlaying=True, playing=playing) rectrack = parse.quote_plus(f"{playing}") rectrack = sub("^", "https://www.youtube.com/results?search_query=", rectrack) song = playing.get_title() artist = playing.get_artist() if image: output = f"[‎]({image})**{borg.me.first_name}** is now listening to:\n\n 🎧 **{song}**\n 💃 {artist}\n\n`{tags}`" preview = True else: output = f"**{borg.me.first_name}** is now listening to:\n\n 🎧 **{song}**\n 💃 {artist}\n\n`{tags}`" else: recent = User(LASTFM_USERNAME, lastfm).get_recent_tracks(limit=3) playing = User(LASTFM_USERNAME, lastfm).get_now_playing() output = f"**{borg.me.first_name}** was last listening to:\n\n" for i, track in enumerate(recent): print( i) # vscode hates the i being there so lets make it chill printable = artist_and_song(track) tags = gettags(track) rectrack = parse.quote_plus(str(printable)) rectrack = sub( "^", "https://www.youtube.com/results?search_query=", rectrack) output += f"[{printable}]({rectrack})\n" if tags: output += f"`{tags}`\n\n" if preview is not None: await lastFM.edit(f"{output}", parse_mode="md", link_preview=True) else: await lastFM.edit(f"{output}", parse_mode="md")
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit( "`Error: Tidak ada data scrobbling yang ditemukan.`" ) artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@SpotifyMusicDownloaderBot" await event.edit("```Mendapatkan Musik Anda```") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Mendownload...`") try: response = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930) ) msg = await bot.send_message(chat, track) respond = await response res = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930) ) r = await res """- don't spam notif -""" await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply( "`Buka Block `@SpotifyMusicDownloaderBot` Dan Coba Ulang`" ) return await bot.forward_messages(event.chat_id, respond.message) await event.client.delete_messages(conv.chat_id, [msg.id, r.id, respond.id]) await event.delete() except TimeoutError: return await event.edit( "`Error: `@SpotifyMusicDownloaderBot` tidak menanggapi!.`" )
async def lyrics(lyric): await lyric.edit("`Getting information...`") if GENIUS is None: return await lyric.edit( "`Provide genius access token to Heroku ConfigVars...`") if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await lyric.edit( "`No information current lastfm scrobbling...`" ) artist = playing.get_artist() song = playing.get_title() else: artist = lyric.pattern_match.group(2) song = lyric.pattern_match.group(3) await lyric.edit(f"`Searching lyrics for {artist} - {song}...`") try: songs = genius.search_song(song, artist) except TypeError: return await lyric.edit( "`Error credentials for GENIUS_ACCESS_TOKEN." "Use Client Access Token - click Generate Access Token " "instead of Client ID or Client Secret " "from` https://genius.com/api-clients" ) if songs is None: await lyric.edit(f"`Song` **{artist} - {song}** `not found...`") return if len(songs.lyrics) > 4096: await lyric.edit("`Lyrics is too big, view the file to see it.`") with open("lyrics.txt", "w+") as f: f.write(f"Search query: \n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file( lyric.chat_id, "lyrics.txt", reply_to=lyric.id, ) return os.remove("lyrics.txt") else: return await lyric.edit( f"**Search query**:\n`{artist}` - `{song}`" f"\n\n```{songs.lyrics}```" )
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit( "**Kesalahan** :\n`Tidak ada data scrobbling yang ditemukan.`") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@SpotifyMusicDownloaderBot" try: await event.edit("`Mendapatkan musiknya...`") async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Mengunduh...`") try: response = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930)) msg = await bot.send_message(chat, track) respond = await response res = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930)) r = await res await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply( "`Buka blokir` **@SpotifyMusicDownloaderBot** `dan ulangi!`" ) return await bot.forward_messages(event.chat_id, respond.message) await event.client.delete_messages(conv.chat_id, [msg.id, r.id, respond.id]) await event.delete() except TimeoutError: return await event.edit( "**Kesalahan** :\n**@SpotifyMusicDownloaderBot** `tidak menanggapi atau lagu tidak ditemukan.`" )
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit( "`Erro: Nenhum dado de scrobbling encontrado.`") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@SpotifyMusicDownloaderBot" await event.edit("```Obtendo sua música```") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Baixando...`") try: response = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930)) msg = await bot.send_message(chat, track) respond = await response res = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930)) r = await res """- don't spam notif -""" await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply( "`Desbloqueie `@SpotifyMusicDownloaderBot` e tente novamente`" ) return await bot.forward_messages(event.chat_id, respond.message) await event.client.delete_messages(conv.chat_id, [msg.id, r.id, respond.id]) await event.delete() except TimeoutError: return await event.edit( "`Erro: `@SpotifyMusicDownloaderBot` não está respondendo!.`")
async def lyrics(lyric): await lyric.edit("`Getting information...`") if GENIUS is None: await lyric.edit("`Provide genius access token to Heroku ConfigVars...`") return False if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: await lyric.edit("`No information current lastfm scrobbling...`") return False artist = playing.get_artist() song = playing.get_title() else: artist = lyric.pattern_match.group(2) song = lyric.pattern_match.group(3) await lyric.edit(f"`Searching lyrics for {artist} - {song}...`") songs = genius.search_song(song, artist) if songs is None: await lyric.edit(f"`Song` **{artist} - {song}** `not found...`") return False if len(songs.lyrics) > 4096: await lyric.edit("`Lyrics is too big, pasted lyrics to Nekobin. please wait.`") with open("lyrics.txt", "w+") as f: f.write(f"Search query: \n{artist} - {song}\n\n{songs.lyrics}") lirik = codecs.open("lyrics.txt", "r", encoding="utf-8") data = lirik.read() key = ( requests.post("https://nekobin.com/api/documents", json={"content": data}) .json() .get("result") .get("key") ) url = f"https://nekobin.com/raw/{key}" await lyric.edit(f"`Here the lyrics:`\n\nPasted to: [Nekobin]({url})") os.remove("lyrics.txt") else: await lyric.edit( f"**Search query**:\n`{artist}` - `{song}`" f"\n\n```{songs.lyrics}```" ) return True
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit( "**Kesalahan** :\n`Saat ini tidak ada scrobble yang ditemukan.`" ) artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@WooMaiBot" link = f"/netease {track}" await event.edit("`Sedang mencari...`") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Memproses...\nTunggu sebentar!`") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply( "`Harap buka blokir` **@WooMaiBot** `dan coba lagi!`") return await event.edit("`Mengirim musik...`") await asyncio.sleep(3) await bot.send_file(event.chat_id, respond) await event.client.delete_messages(conv.chat_id, [msg.id, response.id, respond.id]) await event.delete() except TimeoutError: return await event.edit( "**Kesalahan** :\n**@WooMaiBot** `tidak menanggapi atau lagu tidak ditemukan!`" )
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit( "`Error: Tidak ada scrobble saat ini yang ditemukan.`" ) artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@WooMaiBot" link = f"/netease {track}" await event.edit("`Sedang Mencari...`") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Sedang Mendownload...Mohon Tunggu`") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() """- don't spam notif -""" await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply("```Tolong Buka Block @WooMaiBot Dan Coba Ulang```") return await event.edit("`Mengirim Musik Anda...`") await asyncio.sleep(3) await bot.send_file(event.chat_id, respond) await event.client.delete_messages( conv.chat_id, [msg.id, response.id, respond.id] ) await event.delete() except TimeoutError: return await event.edit("`Error: `@WooMaiBot` tidak menanggapi!.`")
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit( "**Error: LastFM says you aren't playing anything.**") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@SpotifyMusicDownloaderBot" await event.edit("**Searching...**") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("**Downloading...**") try: response = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930)) msg = await bot.send_message(chat, track) respond = await response res = conv.wait_event( events.NewMessage(incoming=True, from_users=752979930)) r = await res """ - don't spam notif - """ await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: return await event.reply( "**Unblock @SpotifyMusicDownloaderBot and retry......**") await bot.forward_messages(event.chat_id, respond.message) await event.client.delete_messages(conv.chat_id, [msg.id, r.id, respond.id]) await event.delete() except TimeoutError: return await event.edit( "**Error: @SpotifyMusicDownloaderBot is not responding.**")
async def lyrics(lyric): await lyric.edit("`Medapatkan informasi...`") if GENIUS is None: await lyric.edit("`Berikan genius akses token ke ConfigVars Heroku...`" ) return False if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: await lyric.edit( "`Tidak ada informasi terkini scrobbling last.fm...`") return False artist = playing.get_artist() song = playing.get_title() else: artist = lyric.pattern_match.group(2) song = lyric.pattern_match.group(3) await lyric.edit(f"`Mencari lirik` **{artist} - {song}**`...`") songs = genius.search_song(song, artist) if songs is None: await lyric.edit(f"`Lagu` **{artist} - {song}** `tidak ditemukan...`" ) return False if len(songs.lyrics) > 4096: await lyric.edit("`Lirik terlalu besar, lihat file untuk melihatnya.`") with open("lyrics.txt", "w+") as f: f.write( f"**Kueri Pencarian** : \n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file( lyric.chat_id, "lyrics.txt", reply_to=lyric.id, ) os.remove("lyrics.txt") return True else: await lyric.edit(f"**Kueri Pencarian** :\n`{artist}` - `{song}`" f"\n\n`{songs.lyrics}`") return True
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit("`Erro: Nenhum scrobble atual encontrado.`" ) artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@WooMaiBot" link = f"/netease {track}" await event.edit("`Procurando...`") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Baixando ... Aguarde`") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() """- don't spam notif -""" await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply( "```Desbloqueie @WooMaiBot e tente novamente```") return await event.edit("`Enviando sua música...`") await asyncio.sleep(3) await bot.send_file(event.chat_id, respond) await event.client.delete_messages(conv.chat_id, [msg.id, response.id, respond.id]) await event.delete() except TimeoutError: return await event.edit("`Erro: `@WooMaiBot` não está respondendo!.`")
async def lyrics(lyric): await lyric.edit("`Obtendo informações...`") if GENIUS is None: await lyric.edit( "`Forneça o token de acesso genius nas ConfigVars do Heroku...`") return False if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: await lyric.edit("`Sem informações do scrobble atual do lastfm...`" ) return False artist = playing.get_artist() song = playing.get_title() else: artist = lyric.pattern_match.group(2) song = lyric.pattern_match.group(3) await lyric.edit(f"`Procurando letras por {artist} - {song}...`") songs = genius.search_song(song, artist) if songs is None: await lyric.edit( f"`Música` **{artist} - {song}** `não encontrada...`") return False if len(songs.lyrics) > 4096: await lyric.edit( "`A letra é muito grande, visualize o arquivo para vê-la.`") with open("lyrics.txt", "w+") as f: f.write(f"Search query: \n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file( lyric.chat_id, "lyrics.txt", reply_to=lyric.id, ) os.remove("lyrics.txt") return True else: await lyric.edit(f"**Consulta de pesquisa**:\n`{artist}` - `{song}`" f"\n\n```{songs.lyrics}```") return True
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit("`Terjadi Kesalahan.`") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@WooMaiBot" link = f"/netease {track}" await event.edit("`Hadangi satumat bungul`") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Lage aploddd.... bentar njing`") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply("`Mohon Unblock @WooMaiBot Dan Coba Lagi`") return await event.edit("`nih musik nyaa tololl.....`") await asyncio.sleep(3) await bot.send_file(event.chat_id, respond) await event.client.delete_messages( conv.chat_id, [msg.id, response.id, respond.id] ) await event.delete() except TimeoutError: return await event.edit( "`Sedang Error`" )
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit("`Error: No current scrobble found.`") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@WooMaiBot" link = f"/netease {track}" await event.edit("`Mencari...`") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Memproses... Mohon tunggu`") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply("`Tolong unblok @WooMaiBot dan coba lagi`") return await event.edit("`Mengirim musiknya...`") await asyncio.sleep(3) await bot.send_file(event.chat_id, respond) await event.client.delete_messages( conv.chat_id, [msg.id, response.id, respond.id] ) await event.delete() except TimeoutError: return await event.edit( "`Error: `@WooMaiBot` tidak merespon atau lagu tidak ditemukan!.`" )
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit("`Error: No current scrobble found.`") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@WooMaiBot" link = f"/netease {track}" await event.edit("`🐲MENCARI MOHON TUNGGU🐲...`") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("`Lagi prosess... Mohon sabar pasti ada kok..😁`") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: await event.reply("`MOHON unblock @WooMaiBot and try again`") return await event.edit( "`MENGIRIM MUSIC KAMU JEBRET SELAMAT MENDENGAR...`") await asyncio.sleep(3) await bot.send_file(event.chat_id, respond) await event.client.delete_messages(conv.chat_id, [msg.id, response.id, respond.id]) await event.delete() except TimeoutError: return await event.edit( "`Error: `@WooMaiBot` is not responding or Song not found!.`")
async def lyrics(lyric): await lyric.edit("**Processando...**") if GENIUS is None: return await lyric.edit( "**Adicionar token de acesso Genius a configvars.**") if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await lyric.edit( "**LastFM diz que você não está tocando nada no momento.**") artist = playing.get_artist() song = playing.get_title() else: artist = lyric.pattern_match.group(2) song = lyric.pattern_match.group(3) await lyric.edit(f"**Procurando letras por** `{artist} - {song}`**...**") songs = genius.search_song(song, artist) if songs is None: return await lyric.edit( f"**Não foi possível encontrar letras para** `{artist} - {song}`**.**" ) if len(songs.lyrics) > 4096: await lyric.edit("**Carregando letras como arquivo...**") with open("lyrics.txt", "w+") as f: f.write( f"Consulta de pesquisa: \n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file(lyric.chat_id, "lyrics.txt", reply_to=lyric.id) os.remove("lyrics.txt") else: await lyric.edit(f"**Consulta de pesquisa**:\n`{artist}` - `{song}`" f"\n\n{songs.lyrics}")
async def lyrics(lyric): await lyric.edit("`Getting information...`") if GENIUS is None: await lyric.edit( "`Provide Genius access token to environment variables or config.env!`" ) return False if lyric.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: await lyric.edit("`No current Last.fm scrobbling...`") return False artist = playing.get_artist() song = playing.get_title() else: artist = lyric.pattern_match.group(2) song = lyric.pattern_match.group(3) await lyric.edit(f"`Searching lyrics for {artist} - {song}...`") songs = genius.search_song(song, artist) if songs is None: await lyric.edit(f"`Song` **{artist} - {song}** `not found...`") return False if len(songs.lyrics) > 4096: await lyric.edit("`Lyrics text is too big, view the file to see it.`") with open("lyrics.txt", "w+") as f: f.write(f"Search query:\n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file( lyric.chat_id, "lyrics.txt", reply_to=lyric.id, ) os.remove("lyrics.txt") return True else: await lyric.edit(f"**Search query**:\n`{artist}` - `{song}`\n\n" f"```{songs.lyrics}```") return True
async def _(event): if event.fwd_from: return if event.pattern_match.group(1) == "now": playing = User(LASTFM_USERNAME, lastfm).get_now_playing() if playing is None: return await event.edit( "**Error: LastFM says you aren't playing anything.**") artist = playing.get_artist() song = playing.get_title() else: artist = event.pattern_match.group(2) song = event.pattern_match.group(3) track = str(artist) + " - " + str(song) chat = "@WooMaiBot" link = f"/netease {track}" await event.edit("**Searching...**") try: async with bot.conversation(chat) as conv: await asyncio.sleep(2) await event.edit("**Downloading...**") try: msg = await conv.send_message(link) response = await conv.get_response() respond = await conv.get_response() """ - don't spam notif - """ await bot.send_read_acknowledge(conv.chat_id) except YouBlockedUserError: return await event.reply("**Unblock @WooMaiBot and retry.**") await event.edit("**Uploading...**") await asyncio.sleep(3) await bot.send_file(event.chat_id, respond) await event.client.delete_messages(conv.chat_id, [msg.id, response.id, respond.id]) await event.delete() except TimeoutError: return await event.edit("**Error: @WooMaiBot is not responding.**")
async def current_lyrics(lyric): genius = lyricsgenius.Genius(GENIUS) playing = User(LASTFM_USERNAME, lastfm).get_now_playing() song = playing.get_title() artist = playing.get_artist() try: songs = genius.search_song(song, artist) except TypeError: songs = None if songs is None: return await lyric.edit(f"Song **{artist} - {song}** not found!") if len(songs.lyrics) > 4096: await lyric.edit("`Lyrics is too big, view the file to see it.`") with open("lyrics.txt", "w+") as f: f.write(f"Search query: \n{artist} - {song}\n\n{songs.lyrics}") await lyric.client.send_file( lyric.chat_id, "lyrics.txt", reply_to=lyric.id, ) os.remove("lyrics.txt") else: await lyric.edit(f"`{artist} - {song}`" f"\n\n```{songs.lyrics}```")
async def _(event): """DeezLoader by @An0nimia. Ported for UniBorg by @SpEcHlDe""" if event.fwd_from: return strings = { "name": "DeezLoad", "arl_token_cfg_doc": "ARL Token for Deezer", "invalid_arl_token": "please set the required variables for this module", "wrong_cmd_syntax": "bruh, now i think how far should we go. please terminate my Session.", "server_error": "We're experiencing technical difficulties.", "processing": "`Downloading...`", "uploading": "`Uploading...`", } ARL_TOKEN = DEEZER_ARL_TOKEN if ARL_TOKEN is None: await event.edit(strings["invalid_arl_token"]) return try: loader = deezloader.Login(ARL_TOKEN) except Exception as er: await event.edit(str(er)) return temp_dl_path = os.path.join(TEMP_DOWNLOAD_DIRECTORY, str(time.time())) if not os.path.exists(temp_dl_path): os.makedirs(temp_dl_path) required_link = event.pattern_match.group(1) required_qty = event.pattern_match.group(2) required_qty = required_qty.strip() if required_qty else "MP3_320" await event.edit(strings["processing"]) if "spotify" in required_link: if "track" in required_link: required_track = loader.download_trackspo( required_link, output=temp_dl_path, quality=required_qty, recursive_quality=True, recursive_download=True, not_interface=True, ) await event.edit(strings["uploading"]) await upload_track(required_track, event) shutil.rmtree(temp_dl_path) await event.delete() elif "album" in required_link: reqd_albums = loader.download_albumspo( required_link, output=temp_dl_path, quality=required_qty, recursive_quality=True, recursive_download=True, not_interface=True, zips=False, ) await event.edit(strings["uploading"]) for required_track in reqd_albums: await upload_track(required_track, event) shutil.rmtree(temp_dl_path) await event.delete() elif "deezer" in required_link: if "track" in required_link: required_track = loader.download_trackdee( required_link, output=temp_dl_path, quality=required_qty, recursive_quality=True, recursive_download=True, not_interface=True, ) await event.edit(strings["uploading"]) await upload_track(required_track, event) shutil.rmtree(temp_dl_path) await event.delete() elif "album" in required_link: reqd_albums = loader.download_albumdee( required_link, output=temp_dl_path, quality=required_qty, recursive_quality=True, recursive_download=True, not_interface=True, zips=False, ) await event.edit(strings["uploading"]) for required_track in reqd_albums: await upload_track(required_track, event) shutil.rmtree(temp_dl_path) await event.delete() elif "now" in required_link: playing = User(LASTFM_USERNAME, lastfm).get_now_playing() artist = str(playing.get_artist()) song = str(playing.get_title()) try: required_track = loader.download_name( artist=artist, song=song, output=temp_dl_path, quality=required_qty, recursive_quality=True, recursive_download=True, not_interface=True, ) except BaseException as err: await event.edit(f"**ERROR :** {err}") await asyncio.sleep(5) return await event.edit(strings["uploading"]) await upload_track(required_track, event) shutil.rmtree(temp_dl_path) await event.delete() else: await event.edit(strings["wrong_cmd_syntax"])