Skip to content

Commit

Permalink
Update sudoers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
THE-VIP-BOY-OP authored Jan 30, 2024
1 parent 777e741 commit 47b7848
Showing 1 changed file with 40 additions and 25 deletions.
65 changes: 40 additions & 25 deletions DAXXMUSIC/plugins/sudo/sudoers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pyrogram import filters
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
from pyrogram.types import Message

from strings import get_string, helpers
from DAXXMUSIC import app
from DAXXMUSIC.misc import SUDOERS
from DAXXMUSIC.utils.database import add_sudo, remove_sudo
Expand All @@ -10,6 +11,7 @@
from config import BANNED_USERS, OWNER_ID



@app.on_message(filters.command(["addsudo"], prefixes=["/", "!", "%", ",", "", ".", "@", "#"]) & filters.user(OWNER_ID))
@language
async def useradd(client, message: Message, _):
Expand Down Expand Up @@ -44,28 +46,41 @@ async def userdel(client, message: Message, _):
await message.reply_text(_["sudo_8"])



photo_url = "https://telegra.ph/file/20b4a9fd06ea4a9457a61.jpg"

@app.on_message(filters.command(["sudolist", "listsudo", "sudoers"], prefixes=["/", "!", "%", ",", "", ".", "@", "#"]) & ~BANNED_USERS)
@language
async def sudoers_list(client, message: Message, _):
text = _["sudo_5"]
user = await app.get_users(OWNER_ID)
user = user.first_name if not user.mention else user.mention
text += f"1➤ {user}\n"
count = 0
smex = 0
for user_id in SUDOERS:
if user_id != OWNER_ID:
try:
user = await app.get_users(user_id)
user = user.first_name if not user.mention else user.mention
if smex == 0:
smex += 1
text += _["sudo_6"]
count += 1
text += f"{count}{user}\n"
except:
continue
if not text:
await message.reply_text(_["sudo_7"])
else:
await message.reply_text(text, reply_markup=close_markup(_))
async def sudoers_list(client, message: Message):
keyboard = [[InlineKeyboardButton("๏ ᴠɪᴇᴡ sᴜᴅᴏʟɪsᴛ ๏", callback_data="check_sudo_list")]]
reply_markups = InlineKeyboardMarkup(keyboard)
await message.reply_photo(photo=photo_url, caption="**» ᴄʜᴇᴄᴋ sᴜᴅᴏ ʟɪsᴛ ʙʏ ɢɪᴠᴇɴ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴ.**\n\n**» ɴᴏᴛᴇ:** ᴏɴʟʏ sᴜᴅᴏ ᴜsᴇʀs ᴄᴀɴ ᴠɪᴇᴡ. ", reply_markup=reply_markups)

@app.on_callback_query(filters.regex("^check_sudo_list$"))
async def check_sudo_list(client, callback_query: CallbackQuery):
keyboard = []
if callback_query.from_user.id in SUDOERS:
user = await app.get_users(OWNER_ID)

user_mention = (user.first_name if not user.mention else user.mention)
caption = f"**˹ʟɪsᴛ ᴏғ ʙᴏᴛ ᴍᴏᴅᴇʀᴀᴛᴏʀs˼**\n\n**🌹Oᴡɴᴇʀ** ➥ {user_mention}\n\n"

keyboard.append([InlineKeyboardButton("๏ ᴠɪᴇᴡ ᴏᴡɴᴇʀ ๏", url=f"tg://openmessage?user_id={OWNER_ID}")])

count = 1
for user_id in SUDOERS:
if user_id != OWNER_ID:
try:
user = await app.get_users(user_id)
user_mention = user.mention if user else f"**🎁 Sᴜᴅᴏ {count} ɪᴅ:** {user_id}"
caption += f"**🎁 Sᴜᴅᴏ »** {count}: {user_mention}\n"
button_text = f"๏ ᴠɪᴇᴡ sᴜᴅᴏ {count} ๏ "
keyboard.append([InlineKeyboardButton(button_text, url=f"tg://openmessage?user_id={user_id}")])
count += 1
except:
continue

if keyboard:
reply_markup = InlineKeyboardMarkup(keyboard)
await callback_query.message.edit_caption(caption=caption, reply_markup=reply_markup)
else:
await callback_query.answer("𝐍𝐢𝐤𝐚𝐥 𝐁𝐬𝐝𝐤🖕😂", show_alert=True)

0 comments on commit 47b7848

Please sign in to comment.