|
| 1 | + |
| 2 | + |
| 3 | +from asyncio import QueueEmpty |
| 4 | +from pyrogram import Client |
| 5 | +from pyrogram import filters |
| 6 | +from pyrogram.types import Message |
| 7 | + |
| 8 | +from VCPlayBot.config import que |
| 9 | +from VCPlayBot.function.admins import set |
| 10 | +from VCPlayBot.helpers.channelmusic import get_chat_id |
| 11 | +from VCPlayBot.helpers.decorators import authorized_users_only |
| 12 | +from VCPlayBot.helpers.decorators import errors |
| 13 | +from VCPlayBot.helpers.filters import command |
| 14 | +from VCPlayBot.helpers.filters import other_filters |
| 15 | +from VCPlayBot.services.callsmusic import callsmusic |
| 16 | +from VCPlayBot.services.queues import queues |
| 17 | + |
| 18 | + |
| 19 | +@Client.on_message(filters.command("adminreset")) |
| 20 | +async def update_admin(client, message: Message): |
| 21 | + chat_id = get_chat_id(message.chat) |
| 22 | + set( |
| 23 | + chat_id, |
| 24 | + [ |
| 25 | + member.user |
| 26 | + for member in await message.chat.get_members(filter="administrators") |
| 27 | + ], |
| 28 | + ) |
| 29 | + await message.reply_text("❇️ Admin cache refreshed!") |
| 30 | + |
| 31 | + |
| 32 | +@Client.on_message(command("pause") & other_filters) |
| 33 | +@errors |
| 34 | +@authorized_users_only |
| 35 | +async def pause(_, message: Message): |
| 36 | + chat_id = get_chat_id(message.chat) |
| 37 | + if (chat_id not in callsmusic.active_chats) or ( |
| 38 | + callsmusic.active_chats[chat_id] == "paused" |
| 39 | + ): |
| 40 | + await message.reply_text("❗ Nothing is playing!") |
| 41 | + else: |
| 42 | + callsmusic.pause(chat_id) |
| 43 | + await message.reply_text("▶️ Paused!") |
| 44 | + |
| 45 | + |
| 46 | +@Client.on_message(command("resume") & other_filters) |
| 47 | +@errors |
| 48 | +@authorized_users_only |
| 49 | +async def resume(_, message: Message): |
| 50 | + chat_id = get_chat_id(message.chat) |
| 51 | + if (chat_id not in callsmusic.active_chats) or ( |
| 52 | + callsmusic.active_chats[chat_id] == "playing" |
| 53 | + ): |
| 54 | + await message.reply_text("❗ Nothing is paused!") |
| 55 | + else: |
| 56 | + callsmusic.resume(chat_id) |
| 57 | + await message.reply_text("⏸ Resumed!") |
| 58 | + |
| 59 | + |
| 60 | +@Client.on_message(command("end") & other_filters) |
| 61 | +@errors |
| 62 | +@authorized_users_only |
| 63 | +async def stop(_, message: Message): |
| 64 | + chat_id = get_chat_id(message.chat) |
| 65 | + if chat_id not in callsmusic.active_chats: |
| 66 | + await message.reply_text("❗ Nothing is streaming!") |
| 67 | + else: |
| 68 | + try: |
| 69 | + queues.clear(chat_id) |
| 70 | + except QueueEmpty: |
| 71 | + pass |
| 72 | + |
| 73 | + await callsmusic.stop(chat_id) |
| 74 | + await message.reply_text("❌ Stopped streaming!") |
| 75 | + |
| 76 | + |
| 77 | +@Client.on_message(command("skip") & other_filters) |
| 78 | +@errors |
| 79 | +@authorized_users_only |
| 80 | +async def skip(_, message: Message): |
| 81 | + global que |
| 82 | + chat_id = get_chat_id(message.chat) |
| 83 | + if chat_id not in callsmusic.active_chats: |
| 84 | + await message.reply_text("❗ Nothing is playing to skip!") |
| 85 | + else: |
| 86 | + queues.task_done(chat_id) |
| 87 | + if queues.is_empty(chat_id): |
| 88 | + await callsmusic.stop(chat_id) |
| 89 | + else: |
| 90 | + await callsmusic.set_stream( |
| 91 | + chat_id, |
| 92 | + queues.get(chat_id)["file_path"] |
| 93 | + ) |
| 94 | + |
| 95 | + qeue = que.get(chat_id) |
| 96 | + if qeue: |
| 97 | + skip = qeue.pop(0) |
| 98 | + if not qeue: |
| 99 | + return |
| 100 | + await message.reply_text(f"- Skipped **{skip[0]}**\n- Now Playing **{qeue[0][0]}**") |
| 101 | + |
| 102 | + |
| 103 | +@Client.on_message(filters.command("admincache")) |
| 104 | +@errors |
| 105 | +async def admincache(client, message: Message): |
| 106 | + set( |
| 107 | + message.chat.id, |
| 108 | + [ |
| 109 | + member.user |
| 110 | + for member in await message.chat.get_members(filter="administrators") |
| 111 | + ], |
| 112 | + ) |
| 113 | + await message.reply_text("❇️ Admin cache refreshed!") |
0 commit comments