This commit is contained in:
levina 2022-02-11 08:58:32 +07:00 committed by GitHub
parent 7f5c7a7068
commit 7d2829777b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ from driver.filters import command, other_filters
from driver.decorators import authorized_users_only from driver.decorators import authorized_users_only
from driver.utils import skip_current_song, skip_item from driver.utils import skip_current_song, skip_item
from driver.database.dbpunish import is_gbanned_user from driver.database.dbpunish import is_gbanned_user
from driver.database.dbqueue import ( from driver.database.dbqueue import (
is_music_playing, is_music_playing,
remove_active_chat, remove_active_chat,
@ -231,122 +232,113 @@ async def unmute(client, m: Message):
await m.reply("❌ **nothing is streaming**") await m.reply("❌ **nothing is streaming**")
@Client.on_callback_query(filters.regex("set_pause")) @Client.on_callback_query(
async def cbpause(_, query: CallbackQuery): filters.regex(
pattern=r"^(set_pause|set_resume|set_stop|set_mute|set_unmute)$"
)
)
async def data_stream_markup(_, query: CallbackQuery):
user_id = query.from_user.id 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 chat_id = query.message.chat.id
if chat_id in QUEUE: data = query.matches[0].group(1)
try: if data == "set_pause":
if not await is_music_playing(chat_id): if await is_gbanned_user(user_id):
await query.answer(" The music is already paused.") await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
return return
await calls.pause_stream(chat_id) a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
await music_off(chat_id) if not a.can_manage_voice_chats:
await query.answer("⏸ The music has paused !\n\n» to resume the music click on resume button !", show_alert=True) await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
except Exception as e: return
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark) if chat_id in QUEUE:
else: try:
await query.answer("❌ nothing is currently streaming", show_alert=True) if not await is_music_playing(chat_id):
await query.answer(" The music is already paused.")
return
@Client.on_callback_query(filters.regex("set_resume")) await calls.pause_stream(chat_id)
async def cbresume(_, query: CallbackQuery): await music_off(chat_id)
user_id = query.from_user.id await query.answer("⏸ The music has paused !\n\n» to resume the music click on resume button !", show_alert=True)
if await is_gbanned_user(user_id): except Exception as e:
await query.answer("❗️ You've blocked from using this bot!", show_alert=True) await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
return else:
a = await _.get_chat_member(query.message.chat.id, query.from_user.id) await query.answer("❌ nothing is currently streaming", show_alert=True)
if not a.can_manage_voice_chats: if data == "set_resume":
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True) if await is_gbanned_user(user_id):
chat_id = query.message.chat.id await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
if chat_id in QUEUE: return
try: a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
if await is_music_playing(chat_id): if not a.can_manage_voice_chats:
await query.answer(" The music is already resumed.") await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
return return
await calls.resume_stream(chat_id) if chat_id in QUEUE:
await music_on(chat_id) try:
await query.answer("⏯ The music has resumed !\n\n» to pause the music click on pause button !", show_alert=True) if await is_music_playing(chat_id):
except Exception as e: await query.answer(" The music is already resumed.")
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark) return
else: await calls.resume_stream(chat_id)
await query.answer("❌ nothing is currently streaming", show_alert=True) 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:
@Client.on_callback_query(filters.regex("set_stop")) await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
async def cbstop(_, query: CallbackQuery): else:
user_id = query.from_user.id await query.answer("❌ nothing is currently streaming", show_alert=True)
if await is_gbanned_user(user_id): if data == "set_stop":
await query.answer("❗️ You've blocked from using this bot!", show_alert=True) if await is_gbanned_user(user_id):
return await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
a = await _.get_chat_member(query.message.chat.id, query.from_user.id) return
if not a.can_manage_voice_chats: a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True) if not a.can_manage_voice_chats:
chat_id = query.message.chat.id await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
if chat_id in QUEUE: return
try: if chat_id in QUEUE:
await calls.leave_group_call(chat_id) try:
await remove_active_chat(chat_id) await calls.leave_group_call(chat_id)
clear_queue(chat_id) await remove_active_chat(chat_id)
await query.edit_message_text("✅ **this streaming has ended**", reply_markup=close_mark) clear_queue(chat_id)
except Exception as e: await query.edit_message_text("✅ **this streaming has ended**", reply_markup=close_mark)
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark) except Exception as e:
else: await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
await query.answer("❌ nothing is currently streaming", show_alert=True) else:
await query.answer("❌ nothing is currently streaming", show_alert=True)
if data == "set_mute":
@Client.on_callback_query(filters.regex("set_mute")) if await is_gbanned_user(user_id):
async def cbmute(_, query: CallbackQuery): await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
user_id = query.from_user.id return
if await is_gbanned_user(user_id): a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
await query.answer("❗️ You've blocked from using this bot!", show_alert=True) 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)
a = await _.get_chat_member(query.message.chat.id, query.from_user.id) return
if not a.can_manage_voice_chats: if chat_id in QUEUE:
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True) try:
chat_id = query.message.chat.id if not await is_music_playing(chat_id):
if chat_id in QUEUE: await query.answer(" The stream userbot is already muted.")
try: return
if not await is_music_playing(chat_id): await calls.mute_stream(chat_id)
await query.answer(" The stream userbot is already muted.") await music_off(chat_id)
return await query.answer("🔇 The stream userbot has muted !\n\n» to unmute the userbot click on unmute button !", show_alert=True)
await calls.mute_stream(chat_id) except Exception as e:
await music_off(chat_id) await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
await query.answer("🔇 The stream userbot has muted !\n\n» to unmute the userbot click on unmute button !", show_alert=True) else:
except Exception as e: await query.answer("❌ nothing is currently streaming", show_alert=True)
await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark) if data = "set_unmute":
else: if await is_gbanned_user(user_id):
await query.answer("❌ nothing is currently streaming", show_alert=True) 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)
@Client.on_callback_query(filters.regex("set_unmute")) if not a.can_manage_voice_chats:
async def cbunmute(_, query: CallbackQuery): await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
user_id = query.from_user.id return
if await is_gbanned_user(user_id): if chat_id in QUEUE:
await query.answer("❗️ You've blocked from using this bot!", show_alert=True) try:
return if await is_music_playing(chat_id):
a = await _.get_chat_member(query.message.chat.id, query.from_user.id) await query.answer(" The stream userbot is already unmuted.")
if not a.can_manage_voice_chats: return
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True) await calls.unmute_stream(chat_id)
chat_id = query.message.chat.id await music_on(chat_id)
if chat_id in QUEUE: await query.answer("🔊 The stream userbot has unmuted !\n\n» to mute the userbot click on mute button !", show_alert=True)
try: except Exception as e:
if await is_music_playing(chat_id): await query.edit_message_text(f"🚫 **error:**\n\n`{e}`", reply_markup=close_mark)
await query.answer(" The stream userbot is already unmuted.") else:
return await query.answer("❌ nothing is currently streaming", show_alert=True)
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( @Client.on_message(