From 8e4945f8fa4aea8172464bb89bbd9537401c1586 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 11 Feb 2022 14:05:22 +0700 Subject: [PATCH] revert back --- program/admins.py | 219 ++++++++++++++++++++++++---------------------- 1 file changed, 114 insertions(+), 105 deletions(-) diff --git a/program/admins.py b/program/admins.py index f84fe6c..684a877 100644 --- a/program/admins.py +++ b/program/admins.py @@ -232,113 +232,122 @@ async def unmute(client, m: Message): await m.reply("āŒ **nothing is streaming**") -@Client.on_callback_query( - filters.regex( - pattern=r"^(set_pause|set_resume|set_stop|set_mute|set_unmute)$" - ) -) -async def data_stream_markup(_, query: CallbackQuery): +@Client.on_callback_query(filters.regex("set_pause")) +async def cbpause(_, query: CallbackQuery): user_id = query.from_user.id + if await is_gbanned_user(user_id): + await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) + return + a = await _.get_chat_member(query.message.chat.id, query.from_user.id) + if not a.can_manage_voice_chats: + return await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) chat_id = query.message.chat.id - data = query.matches[0].group(1) - if data == "set_pause": - if await is_gbanned_user(user_id): - await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) - return - a = await _.get_chat_member(query.message.chat.id, query.from_user.id) - if not a.can_manage_voice_chats: - await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) - return - if chat_id in QUEUE: - try: - if not await is_music_playing(chat_id): - await query.answer("ā„¹ļø The music is already paused.", show_alert=True) - return - await calls.pause_stream(chat_id) - await music_off(chat_id) - await query.answer("āø The music has paused !\n\nĀ» to resume the music click on resume button !", show_alert=True) - except Exception as e: - await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) - else: - await query.answer("āŒ nothing is currently streaming", show_alert=True) - elif data == "set_resume": - if await is_gbanned_user(user_id): - await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) - return - a = await _.get_chat_member(query.message.chat.id, query.from_user.id) - if not a.can_manage_voice_chats: - await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) - return - if chat_id in QUEUE: - try: - if await is_music_playing(chat_id): - await query.answer("ā„¹ļø The music is already resumed.", show_alert=True) - return - await calls.resume_stream(chat_id) - await music_on(chat_id) - await query.answer("ā–¶ļø The music has resumed !\n\nĀ» to pause the music click on pause button !", show_alert=True) - except Exception as e: - await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) - else: - await query.answer("āŒ nothing is currently streaming", show_alert=True) - elif data == "set_stop": - if await is_gbanned_user(user_id): - await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) - return - a = await _.get_chat_member(query.message.chat.id, query.from_user.id) - if not a.can_manage_voice_chats: - await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) - return - if chat_id in QUEUE: - try: - await calls.leave_group_call(chat_id) - await remove_active_chat(chat_id) - clear_queue(chat_id) - await query.edit_message_text("āœ… **this streaming has ended**", reply_markup=close_mark) - except Exception as e: - await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) - else: - await query.answer("āŒ nothing is currently streaming", show_alert=True) - elif data == "set_mute": - if await is_gbanned_user(user_id): - await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) - return - a = await _.get_chat_member(query.message.chat.id, query.from_user.id) - if not a.can_manage_voice_chats: - await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) - return - if chat_id in QUEUE: - try: - if not await is_music_playing(chat_id): - await query.answer("ā„¹ļø The stream userbot is already muted.", show_alert=True) - return - await calls.mute_stream(chat_id) - await music_off(chat_id) - await query.answer("šŸ”‡ The stream userbot has muted !\n\nĀ» to unmute the userbot click on unmute button !", show_alert=True) - except Exception as e: - await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) - else: - await query.answer("āŒ nothing is currently streaming", show_alert=True) - elif data == "set_unmute": - if await is_gbanned_user(user_id): - await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) - return - a = await _.get_chat_member(query.message.chat.id, query.from_user.id) - if not a.can_manage_voice_chats: - await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) - return - if chat_id in QUEUE: - try: - if await is_music_playing(chat_id): - await query.answer("ā„¹ļø The stream userbot is already unmuted.", show_alert=True) - return - await calls.unmute_stream(chat_id) - await music_on(chat_id) - await query.answer("šŸ”Š The stream userbot has unmuted !\n\nĀ» to mute the userbot click on mute button !", show_alert=True) - except Exception as e: - await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) - else: - await query.answer("āŒ nothing is currently streaming", show_alert=True) + if chat_id in QUEUE: + try: + if not await is_music_playing(chat_id): + await query.answer("ā„¹ļø The music is already paused.", show_alert=True) + return + await calls.pause_stream(chat_id) + await music_off(chat_id) + await query.answer("āø The music has paused !\n\nĀ» to resume the music click on resume button !", show_alert=True) + except Exception as e: + await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) + else: + await query.answer("āŒ nothing is currently streaming", show_alert=True) + + +@Client.on_callback_query(filters.regex("set_resume")) +async def cbresume(_, query: CallbackQuery): + user_id = query.from_user.id + if await is_gbanned_user(user_id): + await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) + return + a = await _.get_chat_member(query.message.chat.id, query.from_user.id) + if not a.can_manage_voice_chats: + return await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) + chat_id = query.message.chat.id + if chat_id in QUEUE: + try: + if await is_music_playing(chat_id): + await query.answer("ā„¹ļø The music is already resumed.", show_alert=True) + return + await calls.resume_stream(chat_id) + await music_on(chat_id) + await query.answer("ā–¶ļø The music has resumed !\n\nĀ» to pause the music click on pause button !", show_alert=True) + except Exception as e: + await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) + else: + await query.answer("āŒ nothing is currently streaming", show_alert=True) + + +@Client.on_callback_query(filters.regex("set_stop")) +async def cbstop(_, query: CallbackQuery): + user_id = query.from_user.id + if await is_gbanned_user(user_id): + await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) + return + a = await _.get_chat_member(query.message.chat.id, query.from_user.id) + if not a.can_manage_voice_chats: + return await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) + chat_id = query.message.chat.id + if chat_id in QUEUE: + try: + await calls.leave_group_call(chat_id) + await remove_active_chat(chat_id) + clear_queue(chat_id) + await query.edit_message_text("āœ… **this streaming has ended**", reply_markup=close_mark) + except Exception as e: + await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) + else: + await query.answer("āŒ nothing is currently streaming", show_alert=True) + + +@Client.on_callback_query(filters.regex("set_mute")) +async def cbmute(_, query: CallbackQuery): + user_id = query.from_user.id + if await is_gbanned_user(user_id): + await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) + return + a = await _.get_chat_member(query.message.chat.id, query.from_user.id) + if not a.can_manage_voice_chats: + return await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) + chat_id = query.message.chat.id + if chat_id in QUEUE: + try: + if not await is_music_playing(chat_id): + await query.answer("ā„¹ļø The stream userbot is already muted.", show_alert=True) + return + await calls.mute_stream(chat_id) + await music_off(chat_id) + await query.answer("šŸ”‡ The stream userbot has muted !\n\nĀ» to unmute the userbot click on unmute button !", show_alert=True) + except Exception as e: + await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) + else: + await query.answer("āŒ nothing is currently streaming", show_alert=True) + + +@Client.on_callback_query(filters.regex("set_unmute")) +async def cbunmute(_, query: CallbackQuery): + user_id = query.from_user.id + if await is_gbanned_user(user_id): + await query.answer("ā—ļø You've blocked from using this bot!", show_alert=True) + return + a = await _.get_chat_member(query.message.chat.id, query.from_user.id) + if not a.can_manage_voice_chats: + return await query.answer("šŸ’” Only admin with manage video chat permission that can tap this button !", show_alert=True) + chat_id = query.message.chat.id + if chat_id in QUEUE: + try: + if await is_music_playing(chat_id): + await query.answer("ā„¹ļø The stream userbot is already unmuted.", show_alert=True) + return + await calls.unmute_stream(chat_id) + await music_on(chat_id) + await query.answer("šŸ”Š The stream userbot has unmuted !\n\nĀ» to mute the userbot click on mute button !", show_alert=True) + except Exception as e: + await query.edit_message_text(f"šŸš« **error:**\n\n`{e}`", reply_markup=close_mark) + else: + await query.answer("āŒ nothing is currently streaming", show_alert=True) @Client.on_message(