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.active_chats) or ( callsmusic.active_chats[chet_id] == "paused" ): await cb.answer("Chat is not connected!", show_alert=True) else: callsmusic.pause(chet_id) await cb.answer("Music Paused!") await cb.message.edit( updated_stats(m_chat, qeue), reply_markup=r_ply("play") ) elif type_ == "play": if (chet_id not in callsmusic.active_chats) or ( callsmusic.active_chats[chet_id] == "playing" ): await cb.answer("Chat is not connected!", show_alert=True) else: callsmusic.resume(chet_id) await cb.answer("Music Resumed!") 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("Player is idle") temp = [] for t in queue: temp.append(t) 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_ == "resume": if (chet_id not in callsmusic.active_chats) or ( callsmusic.active_chats[chet_id] == "playing" ): await cb.answer("Chat is not connected or already playng", show_alert=True) else: callsmusic.resume(chet_id) await cb.answer("Music Resumed!") elif type_ == "puse": if (chet_id not in callsmusic.active_chats) or ( callsmusic.active_chats[chet_id] == "paused" ): await cb.answer("Chat is not connected or already paused", show_alert=True) else: callsmusic.pause(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.active_chats: await cb.answer("Chat is not connected!", show_alert=True) else: queues.task_done(chet_id) if queues.is_empty(chet_id): callsmusic.stop(chet_id) await cb.message.edit("- No More Playlist..\n- Leaving VC!") else: await callsmusic.set_stream( chet_id, queues.get(chet_id)["file"] ) await cb.answer.reply_text("✅ <b>Skipped</b>") 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]}**" ) else: if chet_id in callsmusic.active_chats: try: queues.clear(chet_id) except QueueEmpty: pass await callsmusic.stop(chet_id) await cb.message.edit("Successfully Left the Chat!") else: await cb.answer("Chat is not connected!", show_alert=True)
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.active_chats: await cb.answer("Chat is not connected!", show_alert=True) else: queues.task_done(chet_id) if queues.is_empty(chet_id): callsmusic.stop(chet_id) await cb.message.edit("- No More Playlist..\n- Leaving VC!") else: await callsmusic.set_stream(chet_id, queues.get(chet_id)["file"]) await cb.answer.reply_text("✅ <b>Skipped</b>") 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]}**" ) else: if chet_id in callsmusic.active_chats: try: queues.clear(chet_id) except QueueEmpty: pass