Update admins.py

This commit is contained in:
Tofik Denianto 2021-10-30 01:55:54 +07:00 committed by GitHub
parent 8ed427e449
commit 663f948e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,12 @@
from cache.admins import admins from cache.admins import admins
from driver.filters import command, other_filters from config import BOT_USERNAME, GROUP_SUPPORT, IMG_3, UPDATES_CHANNEL
from pyrogram import Client, filters
from driver.veez import call_py, bot
from driver.queues import QUEUE, clear_queue
from driver.decorators import authorized_users_only from driver.decorators import authorized_users_only
from driver.filters import command, other_filters
from driver.queues import QUEUE, clear_queue
from driver.utils import skip_current_song, skip_item from driver.utils import skip_current_song, skip_item
from config import BOT_USERNAME, IMG_3, GROUP_SUPPORT, UPDATES_CHANNEL from driver.veez import call_py
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup from pyrogram import Client
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
@Client.on_message(command(["reload", f"reload@{BOT_USERNAME}"]) & other_filters) @Client.on_message(command(["reload", f"reload@{BOT_USERNAME}"]) & other_filters)
@ -26,89 +26,100 @@ async def update_admin(client, message):
@Client.on_message(command(["skip", f"skip@{BOT_USERNAME}", "vskip"]) & other_filters) @Client.on_message(command(["skip", f"skip@{BOT_USERNAME}", "vskip"]) & other_filters)
@authorized_users_only @authorized_users_only
async def skip(client, m: Message): async def skip(client, m: Message):
keyboard = InlineKeyboardMarkup( keyboard = InlineKeyboardMarkup(
[
[ [
[ InlineKeyboardButton(
InlineKeyboardButton( text="✨ ɢʀᴏᴜᴘ", url=f"https://t.me/{GROUP_SUPPORT}"
text="✨ ɢʀᴏᴜᴘ", ),
url=f"https://t.me/{GROUP_SUPPORT}"), InlineKeyboardButton(
InlineKeyboardButton( text="🌻 ᴄʜᴀɴɴᴇʟ", url=f"https://t.me/{UPDATES_CHANNEL}"
text="🌻 ᴄʜᴀɴɴᴇʟ", ),
url=f"https://t.me/{UPDATES_CHANNEL}")
]
] ]
) ]
)
chat_id = m.chat.id
if len(m.command) < 2: chat_id = m.chat.id
op = await skip_current_song(chat_id) if len(m.command) < 2:
if op==0: op = await skip_current_song(chat_id)
await m.reply("❌ nothing is currently playing") if op == 0:
elif op==1: await m.reply("❌ nothing is currently playing")
await m.reply("✅ __Queues__ is empty.\n\n• userbot leaving voice chat") elif op == 1:
else: await m.reply("✅ __Queues__ is empty.\n\n• userbot leaving voice chat")
await m.reply_photo( else:
photo=f"{IMG_3}", await m.reply_photo(
caption=f"⏭ **Skipped to the next track.**\n\n🏷 **Name:** [{op[0]}]({op[1]})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}", photo=f"{IMG_3}",
reply_markup=keyboard, caption=f"⏭ **Skipped to the next track.**\n\n🏷 **Name:** [{op[0]}]({op[1]})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}",
) reply_markup=keyboard,
else: )
skip = m.text.split(None, 1)[1] else:
OP = "🗑 **removed song from queue:**" skip = m.text.split(None, 1)[1]
if chat_id in QUEUE: OP = "🗑 **removed song from queue:**"
items = [int(x) for x in skip.split(" ") if x.isdigit()] if chat_id in QUEUE:
items.sort(reverse=True) items = [int(x) for x in skip.split(" ") if x.isdigit()]
for x in items: items.sort(reverse=True)
if x==0: for x in items:
pass if x == 0:
else: pass
hm = await skip_item(chat_id, x) else:
if hm==0: hm = await skip_item(chat_id, x)
pass if hm == 0:
else: pass
OP = OP + "\n" + f"**#{x}** - {hm}" else:
await m.reply(OP) OP = OP + "\n" + f"**#{x}** - {hm}"
await m.reply(OP)
@Client.on_message(command(["stop", f"stop@{BOT_USERNAME}", "end", f"end@{BOT_USERNAME}", "vstop"]) & other_filters) @Client.on_message(
command(["stop", f"stop@{BOT_USERNAME}", "end", f"end@{BOT_USERNAME}", "vstop"])
& other_filters
)
@authorized_users_only @authorized_users_only
async def stop(client, m: Message): async def stop(client, m: Message):
chat_id = m.chat.id chat_id = m.chat.id
if chat_id in QUEUE: if chat_id in QUEUE:
try: try:
await call_py.leave_group_call(chat_id) await call_py.leave_group_call(chat_id)
clear_queue(chat_id) clear_queue(chat_id)
await m.reply("✅ **streaming has ended.**") await m.reply("✅ **streaming has ended.**")
except Exception as e: except Exception as e:
await m.reply(f"🚫 **error:**\n\n`{e}`") await m.reply(f"🚫 **error:**\n\n`{e}`")
else: else:
await m.reply("❌ **nothing in streaming**") await m.reply("❌ **nothing in streaming**")
@Client.on_message(command(["pause", f"pause@{BOT_USERNAME}", "vpause"]) & other_filters) @Client.on_message(
command(["pause", f"pause@{BOT_USERNAME}", "vpause"]) & other_filters
)
@authorized_users_only @authorized_users_only
async def pause(client, m: Message): async def pause(client, m: Message):
chat_id = m.chat.id chat_id = m.chat.id
if chat_id in QUEUE: if chat_id in QUEUE:
try: try:
await call_py.pause_stream(chat_id) await call_py.pause_stream(chat_id)
await m.reply("⏸ **Track paused.**\n\n• **To resume the stream, use the**\n» /resume command.") await m.reply(
except Exception as e: "⏸ **Track paused.**\n\n• **To resume the stream, use the**\n» /resume command."
await m.reply(f"🚫 **error:**\n\n`{e}`") )
else: except Exception as e:
await m.reply("❌ **nothing in streaming**") await m.reply(f"🚫 **error:**\n\n`{e}`")
else:
await m.reply("❌ **nothing in streaming**")
@Client.on_message(command(["resume", f"resume@{BOT_USERNAME}", "vresume"]) & other_filters) @Client.on_message(
command(["resume", f"resume@{BOT_USERNAME}", "vresume"]) & other_filters
)
@authorized_users_only @authorized_users_only
async def resume(client, m: Message): async def resume(client, m: Message):
chat_id = m.chat.id chat_id = m.chat.id
if chat_id in QUEUE: if chat_id in QUEUE:
try: try:
await call_py.resume_stream(chat_id) await call_py.resume_stream(chat_id)
await m.reply("▶️ **Track resumed.**\n\n• **To pause the stream, use the**\n» /pause command.") await m.reply(
except Exception as e: "▶️ **Track resumed.**\n\n• **To pause the stream, use the**\n» /pause command."
await m.reply(f"🚫 **error:**\n\n`{e}`") )
else: except Exception as e:
await m.reply("❌ **nothing in streaming**") await m.reply(f"🚫 **error:**\n\n`{e}`")
else:
await m.reply("❌ **nothing in streaming**")