async def p_cb(b, cb): global que try: lel = await client.get_chat(cb.message.chat.id) lol = lel.linked_chat.id conv = lel.linked_chat except: return que.get(lol) type_ = cb.matches[0].group(1) cb.message.chat.id cb.message.chat cb.message.reply_markup.inline_keyboard[1][0].callback_data if type_ == "playlist": queue = que.get(lol) if not queue: await cb.message.edit("Player is idle") temp = [t for t in queue] now_playing = temp[0][0] by = temp[0][1].mention(style="md") msg = "**Now Playing** in {}".format(conv.title) msg += "\n- " + now_playing msg += "\n- Req by " + by temp.pop(0) if temp: msg += "\n\n" msg += "**Queue**" for song in temp: name = song[0] usr = song[1].mention(style="md") msg += f"\n- {name}" msg += f"\n- Req by {usr}\n" await cb.message.edit(msg)
async def p_cb(b, cb): global que que.get(cb.message.chat.id) type_ = cb.matches[0].group(1) cb.message.chat.id cb.message.chat cb.message.reply_markup.inline_keyboard[1][0].callback_data if type_ == "playlist": queue = que.get(cb.message.chat.id) if not queue: await cb.message.edit("❌ **Tidak Ada Playlist**") temp = [] for t in queue: temp.append(t) now_playing = temp[0][0] by = temp[0][1].mention(style="md") msg = "**Daftar Music** yang sedang dimainkan di {} ".format( cb.message.chat.title) msg += "\n\n✾ Judul Music : " + now_playing msg += "\n✾ Request : " + by temp.pop(0) if temp: msg += "\n────────────────────────────" msg += "\n**Daftar** Antrian :" for song in temp: name = song[0] usr = song[1].mention(style="md") msg += f"\n\n✾ Judul Music : {name}" msg += f"\n✾ Request : {usr}\n" await cb.message.edit(msg)
async def playlist(client, message): global que if message.chat.id in DISABLED_GROUPS: return queue = que.get(message.chat.id) if not queue: await message.reply_text("**Tidak Ada Playlist**") temp = [] for t in queue: temp.append(t) now_playing = temp[0][0] by = temp[0][1].mention(style="md") msg = "**Daftar Music** yang sedang dimainkan di {} :".format( message.chat.title) msg += "\n\n✾ Judul Music : " + now_playing msg += "\n✾ Request : " + by temp.pop(0) if temp: msg += "\n────────────────────────────" msg += "\n**Daftar** Antrian :" for song in temp: name = song[0] usr = song[1].mention(style="md") msg += f"\n\n✾ Judul Music : {name}" msg += f"\n✾ Request : {usr}\n" await message.reply_text(msg)
async def playlist(client, message): try: lel = await client.get_chat(message.chat.id) lol = lel.linked_chat.id except: message.reply("Is this cat even linked?") return global que queue = que.get(lol) if not queue: await message.reply_text("Player is idle") temp = [t for t in queue] now_playing = temp[0][0] by = temp[0][1].mention(style="md") msg = "**Now Playing** in {}".format(lel.linked_chat.title) msg += "\n- " + now_playing msg += "\n- Req by " + by temp.pop(0) if temp: msg += "\n\n" msg += "**Queue**" for song in temp: name = song[0] usr = song[1].mention(style="md") msg += f"\n- {name}" msg += f"\n- Req by {usr}\n" await message.reply_text(msg)
async def ee(client, message): if message.chat.id in DISABLED_GROUPS: return queue = que.get(message.chat.id) stats = updated_stats(message.chat, queue) if stats: await message.reply(stats) else: await message.reply("**Tidak Ada Lagu!**")
async def ee(client, message): try: lel = await client.get_chat(message.chat.id) lol = lel.linked_chat.id conv = lel.linked_chat except: await message.reply("Is chat even linked") return queue = que.get(lol) stats = updated_stats(conv, queue) if stats: await message.reply(stats) else: await message.reply("No VC instances running in this chat")
async def settings(client, message): if message.chat.id in DISABLED_GROUPS: await message.reply("❌ **Music Player Dimatikan**") return playing = None chat_id = get_chat_id(message.chat) if chat_id in callsmusic.pytgcalls.active_calls: playing = True queue = que.get(chat_id) stats = updated_stats(message.chat, queue) if stats: if playing: await message.reply(stats, reply_markup=r_ply("pause")) else: await message.reply(stats, reply_markup=r_ply("play")) else: await message.reply("❌ **Nyalakan dulu VCG!**")
async def settings(client, message): try: lel = await client.get_chat(message.chat.id) lol = lel.linked_chat.id conv = lel.linked_chat except: await message.reply("Is chat even linked") return queue = que.get(lol) stats = updated_stats(conv, queue) if stats: playing = None if playing: await message.reply(stats, reply_markup=r_ply("pause")) else: await message.reply(stats, reply_markup=r_ply("play")) else: await message.reply("No VC instances running in this chat")
async def deezer(client: Client, message_: Message): global que lel = await message_.reply("🔄 **Processing**") try: conchat = await client.get_chat(message_.chat.id) conid = conchat.linked_chat.id conv = conchat.linked_chat chid = conid except: await message_.reply("Is chat even linked") return try: administrators = await get_administrators(conv) except: await message.reply("Am I admin of Channel") try: user = await USER.get_me() except: user.first_name = "MusicMan" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await client.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message_.from_user.id: if message_.chat.title.startswith("Channel Music: "): await lel.edit( "<b>Remember to add helper to your channel</b>", ) try: invitelink = await client.export_chat_invite_link(chid) except: await lel.edit( "<b>Add me as admin of yor channel first</b>", ) return try: await USER.join_chat(invitelink) await lel.edit( "<b>helper userbot joined your channel</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your channel due to heavy requests for userbot! Make sure user is not banned in channel." "\n\nOr manually add assistant to your Group and try again</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i> {user.first_name} Userbot not in this channel, Ask admin to send /play command for first time or add {user.first_name} manually</i>" ) return requested_by = message_.from_user.first_name text = message_.text.split(" ", 1) queryy = text[1] query = queryy res = lel await res.edit(f'Searching 👀👀👀 for `{query}` on deezer') try: songs = await arq.deezer(query, 1) if not songs.ok: await message_.reply_text(songs.result) return title = songs.result[0].title url = songs.result[0].url artist = songs.result[0].artist duration = songs.result[0].duration thumbnail = songs.result[0].thumbnail except: await res.edit( "Found Literally Nothing, You Should Work On Your English!") return keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Daftar Putar", callback_data="playlist"), InlineKeyboardButton("⛑ Channel", url="https://t.me/Lunatic0de"), ], [InlineKeyboardButton(text="🗑 Close", callback_data="cls")], ]) file_path = await convert(wget.download(url)) await res.edit("Generating Thumbnail") await generate_cover(requested_by, title, artist, duration, thumbnail) chat_id = chid if chat_id in callsmusic.pytgcalls.active_calls: await res.edit("adding in queue") position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message_.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await res.edit_text( f"🎼 **Lagu yang Anda minta Sedang Antri di posisi** `{position}`") else: await res.edit_text(f"✯{bn}✯=▶️ Playing.....") que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message_.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) callsmusic.pytgcalls.join_group_call(chat_id, file_path) await res.delete() m = await client.send_photo( chat_id=message_.chat.id, reply_markup=keyboard, photo="final.png", caption=f"Playing [{title}]({url}) Via Deezer in Linked Channel", ) os.remove("final.png")
async def play(_, message: Message): global que lel = await message.reply("🔄 **Processing**") try: conchat = await _.get_chat(message.chat.id) conv = conchat.linked_chat conid = conchat.linked_chat.id chid = conid except: await message.reply("Is chat even linked") return try: administrators = await get_administrators(conv) except: await message.reply("Am I admin of Channel") try: user = await USER.get_me() except: user.first_name = "helper" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( "<b>Remember to add helper to your channel</b>", ) try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>Add me as admin of yor channel first</b>", ) return try: await USER.join_chat(invitelink) await lel.edit( "<b>helper userbot joined your channel</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your channel due to heavy requests for userbot! Make sure user is not banned in group." "\n\nOr manually add assistant to your Group and try again</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i> {user.first_name} Userbot not in this chat, Ask channel admin to send /play command for first time or add {user.first_name} manually</i>" ) return message.from_user.id text_links = None message.from_user.first_name await lel.edit("🔎 **Finding**") message.from_user.id user_id = message.from_user.id message.from_user.first_name user_name = message.from_user.first_name rpk = "[" + user_name + "](tg://user?id=" + str(user_id) + ")" if message.reply_to_message: entities = [] toxt = message.reply_to_message.text or message.reply_to_message.caption if (message.reply_to_message.entities or message.reply_to_message.caption_entities): entities = message.reply_to_message.entities + entities urls = [entity for entity in entities if entity.type == 'url'] text_links = [ entity for entity in entities if entity.type == 'text_link' ] else: urls = None if text_links: urls = True audio = ((message.reply_to_message.audio or message.reply_to_message.voice) if message.reply_to_message else None) if audio: if round(audio.duration / 60) > DURATION_LIMIT: raise DurationLimitError( f"❌ Videos longer than {DURATION_LIMIT} minute(s) aren't allowed to play!" ) keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist", callback_data="cplaylist"), InlineKeyboardButton("Menu ⏯ ", callback_data="cmenu"), ], [InlineKeyboardButton(text="❌ Close", callback_data="ccls")], ]) file_name = get_file_name(audio) title = file_name thumb_name = "https://telegra.ph/file/f6086f8909fbfeb0844f2.png" thumbnail = thumb_name duration = round(audio.duration / 60) views = "Locally added" requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(( await message.reply_to_message.download(file_name) ) if not path.isfile(path.join("downloads", file_name)) else file_name) elif urls: query = toxt await lel.edit("🎵 **Processing**") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "**Lagu tidak ditemukan.** Coba cari dengan judul lagu yang lebih jelas, Ketik `/help` bila butuh bantuan" ) print(str(e)) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist", callback_data="cplaylist"), InlineKeyboardButton("Menu ⏯ ", callback_data="cmenu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="ccls")], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) else: query = "".join(" " + str(i) for i in message.command[1:]) print(query) await lel.edit("🎵 **Processing**") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Song not found.Try another song or maybe spell it properly.") print(str(e)) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Daftar Putar", callback_data="playlist"), InlineKeyboardButton("⛑ Channel", url="https://t.me/Lunatic0de"), ], [InlineKeyboardButton(text="🗑 Close", callback_data="cls")], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) chat_id = chid if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption= f"🎼 **Lagu yang Anda minta Sedang Antri di posisi** `{position}`", reply_markup=keyboard, ) else: chat_id = chid que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) callsmusic.pytgcalls.join_group_call(chat_id, file_path) await message.reply_photo( photo="final.png", reply_markup=keyboard, caption="🎼️ **Sedang Memutar Lagu Permintaan dari** {}".format( message.from_user.mention()), ) os.remove("final.png") return await lel.delete()
async def m_cb(b, cb): global que if (cb.message.chat.title.startswith("Channel Music: ") and chat.title[14:].isnumeric()): chet_id = int(chat.title[13:]) else: try: lel = await b.get_chat(cb.message.chat.id) lol = lel.linked_chat.id conv = lel.linked_chat chet_id = lol except: return qeue = que.get(chet_id) type_ = cb.matches[0].group(1) cb.message.chat.id m_chat = cb.message.chat the_data = cb.message.reply_markup.inline_keyboard[1][0].callback_data if type_ == "cpause": if (chet_id not in callsmusic.pytgcalls.active_calls) or ( callsmusic.pytgcalls.active_calls[chet_id] == "paused"): await cb.answer("Chat is not connected!", show_alert=True) else: callsmusic.pytgcalls.pause_stream(chet_id) await cb.answer("Music Paused!") await cb.message.edit(updated_stats(conv, qeue), reply_markup=r_ply("play")) elif type_ == "cplay": if (chet_id not in callsmusic.pytgcalls.active_calls) or ( callsmusic.pytgcalls.active_calls[chet_id] == "playing"): await cb.answer("Chat is not connected!", show_alert=True) else: callsmusic.pytgcalls.resume_stream(chet_id) await cb.answer("Music Resumed!") await cb.message.edit(updated_stats(conv, qeue), reply_markup=r_ply("pause")) elif type_ == "cplaylist": queue = que.get(cb.message.chat.id) if not queue: await cb.message.edit("Player is idle") temp = [t for t in queue] now_playing = temp[0][0] by = temp[0][1].mention(style="md") msg = "**Now Playing** in {}".format(cb.message.chat.title) msg += "\n- " + now_playing msg += "\n- Req by " + by temp.pop(0) if temp: msg += "\n\n" msg += "**Queue**" for song in temp: name = song[0] usr = song[1].mention(style="md") msg += f"\n- {name}" msg += f"\n- Req by {usr}\n" await cb.message.edit(msg) elif type_ == "cresume": if (chet_id not in callsmusic.pytgcalls.active_calls) or ( callsmusic.pytgcalls.active_calls[chet_id] == "playing"): await cb.answer("Chat is not connected or already playng", show_alert=True) else: callsmusic.pytgcalls.resume_stream(chet_id) await cb.answer("Music Resumed!") elif type_ == "cpuse": if (chet_id not in callsmusic.pytgcalls.active_calls) or ( callsmusic.pytgcalls.active_calls[chet_id] == "paused"): await cb.answer("Chat is not connected or already paused", show_alert=True) else: callsmusic.pytgcalls.pause_stream(chet_id) await cb.answer("Music Paused!") elif type_ == "ccls": await cb.answer("Closed menu") await cb.message.delete() elif type_ == "cmenu": stats = updated_stats(conv, qeue) await cb.answer("Menu opened") marr = InlineKeyboardMarkup([ [ InlineKeyboardButton("⏹", "cleave"), InlineKeyboardButton("⏸", "cpuse"), InlineKeyboardButton("▶️", "cresume"), InlineKeyboardButton("⏭", "cskip"), ], [ InlineKeyboardButton("Playlist 📖", "cplaylist"), ], [InlineKeyboardButton("❌ Close", "ccls")], ]) await cb.message.edit(stats, reply_markup=marr) elif type_ == "cskip": if qeue: qeue.pop(0) if chet_id not in callsmusic.pytgcalls.active_calls: await cb.answer("Chat is not connected!", show_alert=True) else: callsmusic.queues.task_done(chet_id) if callsmusic.queues.is_empty(chet_id): callsmusic.pytgcalls.leave_group_call(chet_id) await cb.message.edit("- No More Playlist..\n- Leaving VC!") else: callsmusic.pytgcalls.change_stream( chet_id, callsmusic.queues.get(chet_id)["file"]) await cb.answer("Skipped") await cb.message.edit((m_chat, qeue), reply_markup=r_ply(the_data)) await cb.message.reply_text( f"- Skipped track\n- Now Playing **{qeue[0][0]}**") elif chet_id in callsmusic.pytgcalls.active_calls: try: callsmusic.queues.clear(chet_id) except QueueEmpty: pass callsmusic.pytgcalls.leave_group_call(chet_id) await cb.message.edit("Successfully Left the Chat!") else: await cb.answer("Chat is not connected!", show_alert=True)
async def ytplay(_, message: Message): global que if message.chat.id in DISABLED_GROUPS: return lel = await message.reply("🔄 **Sedang Memproses Lagu**") administrators = await get_administrators(message.chat) chid = message.chat.id try: user = await USER.get_me() except: user.first_name = "MusicMan" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( f"<b>Ingatlah untuk menambahkan {user.first_name} ke Channel Anda</b>", ) pass try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>Tambahkan saya sebagai admin grup Anda terlebih dahulu</b>", ) return try: await USER.join_chat(invitelink) await lel.edit( f"<b>{user.first_name} berhasil bergabung dengan Group anda</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>⛑ Flood Wait Error ⛑\n{user.first_name} tidak dapat bergabung dengan grup Anda karena banyaknya permintaan bergabung untuk userbot! Pastikan pengguna tidak dibanned dalam grup." f"\n\nAtau tambahkan @{ASSISTANT_NAME} secara manual ke Grup Anda dan coba lagi</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i>{user.first_name} terkena banned dari Grup ini, Minta admin untuk mengirim perintah `/play` untuk pertama kalinya atau tambahkan @{ASSISTANT_NAME} secara manual</i>" ) return await lel.edit("🔎 **Sedang Mencari Lagu**") user_id = message.from_user.id user_name = message.from_user.first_name query = "" for i in message.command[1:]: query += " " + str(i) print(query) await lel.edit("🎵 **Sedang Memproses Lagu**") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "**Lagu tidak ditemukan.** Coba cari dengan judul lagu yang lebih jelas, Ketik `/help` bila butuh bantuan" ) print(str(e)) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("⛑ Channel", url="https://t.me/Lunatic0de"), ], [InlineKeyboardButton(text="🗑 Close", callback_data="cls")], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) chat_id = get_chat_id(message.chat) if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption = f"🏷 **Judul:** [{title[:60]}]({url})\n⏱ **Durasi:** {duration}\n💡 **Status:** Antrian Ke `{position}`\n" \ + f"🎼 **Request Dari:** {message.from_user.mention}", reply_markup=keyboard, ) os.remove("final.png") return await lel.delete() else: chat_id = get_chat_id(message.chat) que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) try: callsmusic.pytgcalls.join_group_call(chat_id, file_path) except: message.reply( "**Voice Chat Group tidak aktif, Saya tidak dapat bergabung**") return await message.reply_photo( photo="final.png", caption = f"🏷 **Judul:** [{title[:60]}]({url})\n⏱ **Durasi:** {duration}\n💡 **Status:** Sedang Memutar\n" \ + f"🎼 **Request Dari:** {message.from_user.mention}", reply_markup=keyboard,) os.remove("final.png") return await lel.delete()
async def play(_, message: Message): global que global useer if message.chat.id in DISABLED_GROUPS: return lel = await message.reply("🔄 **Tunggu**...") administrators = await get_administrators(message.chat) chid = message.chat.id try: user = await USER.get_me() except: user.first_name = "RobotMusic" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( f"<b>Jangan Lupa Menambahkan {user.first_name} ke Channel Anda</b>", ) pass try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>⚠️ Jadikan Bot sebagai Admin dulu!</b>", ) return try: await USER.join_chat(invitelink) await lel.edit( f"<b>🆗 **Assisten Music** Berhasil Join di Voice Chat Grup!</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>⛑ Flood Wait Error ⛑\n{user.first_name} Tidak Dapat Bergabung Di Grub Anda. Terlalu Banyak Permintaan Dari Grub Laon." f"\n\nCoba Masukkan @robotassisten secara manual dan coba lagi</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i>{user.first_name} tidak ada didalam Grup, Minta admin untuk /play command atau tambahkan {user.first_name} manual.</i>" ) return text_links = None await lel.edit("🔄 **Mencari**...") if message.reply_to_message: entities = [] toxt = message.reply_to_message.text or message.reply_to_message.caption if message.reply_to_message.entities: entities = message.reply_to_message.entities + entities elif message.reply_to_message.caption_entities: entities = message.reply_to_message.entities + entities urls = [entity for entity in entities if entity.type == 'url'] text_links = [ entity for entity in entities if entity.type == 'text_link' ] else: urls = None if text_links: urls = True user_id = message.from_user.id user_name = message.from_user.first_name rpk = "[" + user_name + "](tg://user?id=" + str(user_id) + ")" audio = ((message.reply_to_message.audio or message.reply_to_message.voice) if message.reply_to_message else None) if audio: if round(audio.duration / 60) > DURATION_LIMIT: raise DurationLimitError( f"❌ **Video terlalu panjang lebih dari** `{DURATION_LIMIT}` menit. Tidak diizinkan!" ) keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton(text="☕ ᴜᴘᴅᴀᴛᴇ", url='https://t.me/robotmusicupdate'), InlineKeyboardButton(text="ᴏᴡɴᴇʀ ☕", url='https://t.me/justthetech'), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ]) file_name = get_file_name(audio) title = file_name thumb_name = "https://telegra.ph/file/ab13882bb05849b6ba170.jpg" thumbnail = thumb_name duration = round(audio.duration / 60) views = "Locally added" requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(( await message.reply_to_message.download(file_name) ) if not path.isfile(path.join("downloads", file_name)) else file_name) elif urls: query = toxt await lel.edit("🎵 **Music** ditemukan") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "❁ **Music** tidak ditemukan.\n❁ Ketik /play (judul lagu).\n❁ Ketik /search (judul lagu)." ) print(str(e)) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton(text="☕ ᴜᴘᴅᴀᴛᴇ", url='https://t.me/robotmusicupdate'), InlineKeyboardButton(text="ᴏᴡɴᴇʀ ☕", url='https://t.me/justthetech'), ], [ InlineKeyboardButton(text="❌", callback_data='cls'), ], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) else: query = "" for i in message.command[1:]: query += " " + str(i) print(query) await lel.edit("🎵 **Music ditemukan**") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=5).to_dict() except: await lel.edit( "❁ **Music tidak ditemukan**.\n❁ Ketik /play (judul lagu).\n❁ Ketik /search (judul lagu)." ) # Looks like hell. Aren't it?? F**K OFF try: toxxt = "**Pilih Lagu yang kamu Inginkan :**\n\n" j = 0 useer = user_name emojilist = [ "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", ] while j < 6: toxxt += f"{emojilist[j]} [{results[j]['title']}](https://youtube.com{results[j]['url_suffix']})\n" toxxt += f" ├ **Durasi** : {results[j]['duration']}\n" toxxt += f" ├ **Views** : {results[j]['views']}\n" toxxt += f" └ **Channel** : {results[j]['channel']}\n\n" j += 1 koyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton( "1️⃣", callback_data=f'plll 0|{query}|{user_id}'), InlineKeyboardButton( "2️⃣", callback_data=f'plll 1|{query}|{user_id}'), InlineKeyboardButton( "3️⃣", callback_data=f'plll 2|{query}|{user_id}'), ], [ InlineKeyboardButton( "4️⃣", callback_data=f'plll 3|{query}|{user_id}'), InlineKeyboardButton( "5️⃣", callback_data=f'plll 4|{query}|{user_id}'), InlineKeyboardButton( "6️⃣", callback_data=f'plll 5|{query}|{user_id}'), ], [InlineKeyboardButton(text="❌", callback_data="cls")], ]) await lel.edit(toxxt, reply_markup=koyboard, disable_web_page_preview=True) # WHY PEOPLE ALWAYS LOVE P**N ?? (A point to think) return # Returning to pornhub except: await lel.edit( "❁ **Music tidak ditemukan.**\n❁ Ketik /play (judul lagu).\n❁ Ketik /search (judul lagu)." ) # print(results) try: url = f"https://youtube.com{results[0]['url_suffix']}" title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "❁ **Music tidak ditemukan.**\n❁ Ketik /play (judul lagu).\n❁ Ketik /search (judul lagu)." ) print(str(e)) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton(text="☕ ᴜᴘᴅᴀᴛᴇ", url='https://t.me/robotmusicupdate'), InlineKeyboardButton(text="ᴏᴡɴᴇʀ ☕", url='https://t.me/justthetech'), ], [ InlineKeyboardButton(text="❌", callback_data='cls'), ], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) chat_id = get_chat_id(message.chat) if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption= f"☕ **Judul** Music : [{title}]({url}) \n#️⃣ **Antrian** : {position}", reply_markup=keyboard) else: chat_id = get_chat_id(message.chat) que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) try: callsmusic.pytgcalls.join_group_call(chat_id, file_path) except: message.reply("❌ **Voice Chat Group tidak aktif, Hidupkan Dulu!**") return await message.reply_photo( photo="final.png", caption= f"📋 **Judul** Music : [{title}]({url}) \n⏱️ **Durasi** Music : {dur} \n👤 **Request** Dari : {useer}", reply_markup=keyboard) os.remove("final.png") return await lel.delete()
async def m_cb(b, cb): global que if (cb.message.chat.title.startswith("Channel Music: ") and chat.title[14:].isnumeric()): chet_id = int(chat.title[13:]) else: chet_id = cb.message.chat.id qeue = que.get(chet_id) type_ = cb.matches[0].group(1) cb.message.chat.id m_chat = cb.message.chat the_data = cb.message.reply_markup.inline_keyboard[1][0].callback_data if type_ == "pause": if (chet_id not in callsmusic.pytgcalls.active_calls) or ( callsmusic.pytgcalls.active_calls[chet_id] == "paused"): await cb.answer("❌ **Tdak Ada Music**!", show_alert=True) else: callsmusic.pytgcalls.pause_stream(chet_id) await cb.answer("❌ **Music Dihentikan**!") await cb.message.edit(updated_stats(m_chat, qeue), reply_markup=r_ply("play")) elif type_ == "play": if (chet_id not in callsmusic.pytgcalls.active_calls) or ( callsmusic.pytgcalls.active_calls[chet_id] == "playing"): await cb.answer("❌ **Tdak Ada Music**!", show_alert=True) else: callsmusic.pytgcalls.resume_stream(chet_id) await cb.answer("❌ **Music Dilanjutkan!**") await cb.message.edit(updated_stats(m_chat, qeue), reply_markup=r_ply("pause")) elif type_ == "playlist": queue = que.get(cb.message.chat.id) if not queue: await cb.message.edit("❌ **Tidak Ada Playlist**") temp = [] for t in queue: temp.append(t) now_playing = temp[0][0] by = temp[0][1].mention(style="md") msg = "**Daftar Music** yang sedang dimainkan di {} :".format( cb.message.chat.title) msg += "\n\n✾ Judul Music : " + now_playing msg += "\n✾ Request : " + by temp.pop(0) if temp: msg += "\n───────────────────────────" msg += "\n**Daftar** Antrian :" for song in temp: name = song[0] usr = song[1].mention(style="md") msg += f"\n\n✾ Judul Music : {name}" msg += f"\n✾ Request : {usr}\n" await cb.message.edit(msg) elif type_ == "resume": if (chet_id not in callsmusic.pytgcalls.active_calls) or ( callsmusic.pytgcalls.active_calls[chet_id] == "playing"): await cb.answer("❌ **Tdak Ada Music**!", show_alert=True) else: callsmusic.pytgcalls.resume_stream(chet_id) await cb.answer("Music Resumed!") elif type_ == "pause": if (chet_id not in callsmusic.pytgcalls.active_calls) or ( callsmusic.pytgcalls.active_calls[chet_id] == "paused"): await cb.answer("❌ **Tdak Ada Music**!", show_alert=True) else: callsmusic.pytgcalls.pause_stream(chet_id) await cb.answer("Music Paused!") elif type_ == "cls": await cb.answer("Closed menu") await cb.message.delete() elif type_ == "menu": stats = updated_stats(cb.message.chat, qeue) await cb.answer("Menu opened") marr = InlineKeyboardMarkup([ [ InlineKeyboardButton("⏹", "leave"), InlineKeyboardButton("⏸", "puse"), InlineKeyboardButton("▶️", "resume"), InlineKeyboardButton("⏭", "skip"), ], [ InlineKeyboardButton("📖 Playlist", "playlist"), ], [InlineKeyboardButton("❌ Close", "cls")], ]) await cb.message.edit(stats, reply_markup=marr) elif type_ == "skip": if qeue: qeue.pop(0) if chet_id not in callsmusic.pytgcalls.active_calls: await cb.answer("❌ **Tdak Ada Music**!", show_alert=True) else: callsmusic.queues.task_done(chet_id) if callsmusic.queues.is_empty(chet_id): callsmusic.pytgcalls.leave_group_call(chet_id) await cb.message.edit( "**Tidak*** ada playlist lagi...\n**Bot** keluar dari VCG!" ) else: callsmusic.pytgcalls.change_stream( chet_id, callsmusic.queues.get(chet_id)["file"]) await cb.answer("Skipped") await cb.message.edit((m_chat, qeue), reply_markup=r_ply(the_data)) await cb.message.reply_text( f"➠ **Skip** ke music berikutnya! \n➠ **Judul** : **{qeue[0][0]}**" ) else: if chet_id in callsmusic.pytgcalls.active_calls: try: callsmusic.queues.clear(chet_id) except QueueEmpty: pass callsmusic.pytgcalls.leave_group_call(chet_id) await cb.message.edit("❇️ Berhasil Keluar dari Chat!") else: await cb.answer("❌ **Tdak Ada Music**!", show_alert=True)
async def deezer(client: Client, message_: Message): if message_.chat.id in DISABLED_GROUPS: return global que lel = await message_.reply("🔄 **Sedang Memproses Lagu**") administrators = await get_administrators(message_.chat) chid = message_.chat.id try: user = await USER.get_me() except: user.first_name = "MusicMan" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await client.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message_.from_user.id: if message_.chat.title.startswith("Channel Music: "): await lel.edit( f"<b>Ingatlah untuk menambahkan {user.first_name} ke Channel Anda</b>", ) pass try: invitelink = await client.export_chat_invite_link(chid) except: await lel.edit( "<b>Tambahkan saya sebagai admin grup Anda terlebih dahulu</b>", ) return try: await USER.join_chat(invitelink) await lel.edit( f"<b>{user.first_name} berhasil bergabung dengan Group anda</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>⛑ Flood Wait Error ⛑\n{user.first_name} tidak dapat bergabung dengan grup Anda karena banyaknya permintaan bergabung untuk userbot! Pastikan pengguna tidak dibanned dalam grup." f"\n\nAtau tambahkan @{ASSISTANT_NAME} secara manual ke Grup Anda dan coba lagi</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i>{user.first_name} terkena banned dari Grup ini, Minta admin untuk mengirim perintah `/play` untuk pertama kalinya atau tambahkan @{ASSISTANT_NAME} secara manual</i>" ) return requested_by = message_.from_user.first_name text = message_.text.split(" ", 1) queryy = text[1] query = queryy res = lel await res.edit(f"**Sedang Mencari Lagu** `{query}` **dari deezer**") try: songs = await arq.deezer(query, 1) if not songs.ok: await message_.reply_text(songs.result) return title = songs.result[0].title url = songs.result[0].url artist = songs.result[0].artist duration = songs.result[0].duration thumbnail = "https://telegra.ph/file/ab13882bb05849b6ba170.jpg" except: await res.edit("**Tidak Ditemukan Lagu Apa Pun!**") return try: duuration = round(duration / 60) if duuration > DURATION_LIMIT: await cb.message.edit( f"**Musik lebih lama dari** `{DURATION_LIMIT}` **menit tidak diperbolehkan diputar**" ) return except: pass keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton(text="⛑ Channel", url="https://t.me/Lunatic0de") ], ]) file_path = await convert(wget.download(url)) await res.edit("📥 **Generating Thumbnail**") await generate_cover(requested_by, title, artist, duration, thumbnail) chat_id = get_chat_id(message_.chat) if chat_id in callsmusic.pytgcalls.active_calls: await res.edit("adding in queue") position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message_.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await res.edit_text( f"🎼 **Lagu yang Anda minta Sedang Antri di posisi** `{position}`") else: await res.edit_text(f"🎼️ **Playing...**") que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message_.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) try: callsmusic.pytgcalls.join_group_call(chat_id, file_path) except: res.edit( "Voice Chat Group tidak aktif, Saya tidak dapat bergabung") return await res.delete() m = await client.send_photo( chat_id=message_.chat.id, reply_markup=keyboard, photo="final.png", caption=f"🎼️ **Sedang Memutar Lagu** [{title}]({url}) **Via Deezer**", ) os.remove("final.png")
async def jiosaavn(client: Client, message_: Message): global que lel = await message_.reply("🔄 **Processing**") try: conchat = await client.get_chat(message_.chat.id) conid = conchat.linked_chat.id conv = conchat.linked_chat chid = conid except: await message_.reply("Is chat even linked") return try: administrators = await get_administrators(conv) except: await message.reply("Am I admin of Channel") try: user = await USER.get_me() except: user.first_name = "MusicMan" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await client.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message_.from_user.id: if message_.chat.title.startswith("Channel Music: "): await lel.edit( "<b>Remember to add helper to your channel</b>", ) try: invitelink = await client.export_chat_invite_link(chid) except: await lel.edit( "<b>Add me as admin of yor group first</b>", ) return try: await USER.join_chat(invitelink) await lel.edit( "<b>helper userbot joined your channel</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your channel due to heavy requests for userbot! Make sure user is not banned in group." "\n\nOr manually add @DaisyXmusic to your Group and try again</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( "<i> helper Userbot not in this channel, Ask channel admin to send /play command for first time or add assistant manually</i>" ) return requested_by = message_.from_user.first_name chat_id = message_.chat.id text = message_.text.split(" ", 1) query = text[1] res = lel await res.edit(f"Searching 👀👀👀 for `{query}` on jio saavn") try: songs = await arq.saavn(query) if not songs.ok: await message_.reply_text(songs.result) return sname = songs.result[0].song slink = songs.result[0].media_url ssingers = songs.result[0].singers sthumb = "https://telegra.ph/file/f6086f8909fbfeb0844f2.png" sduration = int(songs.result[0].duration) except Exception as e: await res.edit( "Found Literally Nothing!, You Should Work On Your English.") print(str(e)) return keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Daftar Putar", callback_data="playlist"), InlineKeyboardButton("⛑ Channel", url="https://t.me/Lunatic0de"), ], [InlineKeyboardButton(text="🗑 Close", callback_data="cls")], ]) file_path = await convert(wget.download(slink)) chat_id = chid if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = sname r_by = message_.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await res.delete() m = await client.send_photo( chat_id=message_.chat.id, reply_markup=keyboard, photo="final.png", caption=f"✯{bn}✯=#️⃣ Queued at position {position}", ) else: await res.edit_text(f"{bn}=▶️ Playing.....") que[chat_id] = [] qeue = que.get(chat_id) s_name = sname r_by = message_.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) callsmusic.pytgcalls.join_group_call(chat_id, file_path) await res.edit("Generating Thumbnail.") await generate_cover(requested_by, sname, ssingers, sduration, sthumb) await res.delete() m = await client.send_photo( chat_id=message_.chat.id, reply_markup=keyboard, photo="final.png", caption=f"Playing {sname} Via Jiosaavn in linked channel", ) os.remove("final.png")
async def lol_cb(b, cb): global que cbd = cb.data.strip() chat_id = cb.message.chat.id typed_ = cbd.split(None, 1)[1] #useer_id = cb.message.reply_to_message.from_user.id try: x, query, useer_id = typed_.split("|") except: await cb.message.edit("Lagu Tidak ditemukan") return useer_id = int(useer_id) if cb.from_user.id != useer_id: await cb.answer("Anda bukan orang yang meminta untuk memutar lagu!", show_alert=True) return await cb.message.edit("🔄 **Sedang Memproses Lagu**") x = int(x) try: useer_name = cb.message.reply_to_message.from_user.first_name except: useer_name = cb.message.from_user.first_name results = YoutubeSearch(query, max_results=5).to_dict() resultss = results[x]["url_suffix"] title = results[x]["title"][:40] thumbnail = results[x]["thumbnails"][0] duration = results[x]["duration"] views = results[x]["views"] url = f"https://youtube.com{resultss}" try: duuration = round(duration / 60) if duuration > DURATION_LIMIT: await cb.message.edit( f"Lagu lebih lama dari {DURATION_LIMIT} menit tidak diperbolehkan diputar" ) return except: pass try: thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) except Exception as e: print(e) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Daftar Putar", callback_data="playlist"), InlineKeyboardButton("⛑ Channel", url="https://t.me/Lunatic0de"), ], [InlineKeyboardButton(text="🗑 Close", callback_data="cls")], ]) requested_by = useer_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title try: r_by = cb.message.reply_to_message.from_user except: r_by = cb.message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await cb.message.delete() await b.send_photo( chat_id, photo="final.png", caption= f"🎼 **Lagu yang** {r_by.mention} **minta Sedang Antri di posisi {position}**", reply_markup=keyboard, ) os.remove("final.png") else: que[chat_id] = [] qeue = que.get(chat_id) s_name = title try: r_by = cb.message.reply_to_message.from_user except: r_by = cb.message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) callsmusic.pytgcalls.join_group_call(chat_id, file_path) await cb.message.delete() await b.send_photo( chat_id, photo="final.png", reply_markup=keyboard, caption= f"🎼️ **Sedang Memutar Lagu Permintaan dari** {r_by.mention}", ) os.remove("final.png")