taslim19
commited on
Commit
·
9c12daf
1
Parent(s):
ce02678
chore: user-updated dev.py
Browse files- DragMusic/plugins/tools/dev.py +20 -61
DragMusic/plugins/tools/dev.py
CHANGED
@@ -10,27 +10,30 @@ from time import time
|
|
10 |
from pyrogram import filters
|
11 |
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, CallbackQuery
|
12 |
|
13 |
-
from
|
14 |
-
from config import OWNER_ID
|
15 |
-
from
|
16 |
-
from DragMusic.misc import SUDOERS
|
17 |
-
from DragMusic.core.mongo import mongodb
|
18 |
-
from DragMusic.utils.decorators.admins import AdminActual
|
19 |
-
from DragMusic.utils.pastebin import paste
|
20 |
-
|
21 |
|
22 |
async def aexec(code, client, message):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
exec(
|
24 |
-
"async def __aexec(client, message
|
25 |
-
+ "
|
26 |
-
|
27 |
-
|
28 |
-
+ " chat = message.chat.id\n"
|
29 |
-
+ "".join(f" {l}\\n" for l in code.split("\n"))
|
30 |
-
+ " except Exception as e:\n"
|
31 |
-
+ " print(traceback.format_exc())"
|
32 |
)
|
33 |
-
|
|
|
34 |
|
35 |
|
36 |
async def edit_or_reply(msg: Message, **kwargs):
|
@@ -38,25 +41,6 @@ async def edit_or_reply(msg: Message, **kwargs):
|
|
38 |
await func(**kwargs)
|
39 |
|
40 |
|
41 |
-
@app.on_message(
|
42 |
-
filters.command(["eval", "e"]) & SUDOERS & ~filters.forwarded & ~filters.via_bot
|
43 |
-
)
|
44 |
-
async def executor(client, message: Message):
|
45 |
-
if len(message.command) < 2:
|
46 |
-
return await message.reply_text("<b>» ᴡʜᴀᴛ ʏᴏᴜ ᴡᴀɴɴᴀ ᴇxᴇᴄᴜᴛᴇ ?</b>")
|
47 |
-
try:
|
48 |
-
cmd = message.text.split(" ", maxsplit=1)[1]
|
49 |
-
except IndexError:
|
50 |
-
return await message.delete()
|
51 |
-
t1 = time.time()
|
52 |
-
try:
|
53 |
-
await aexec(cmd, client, message)
|
54 |
-
except Exception as e:
|
55 |
-
await message.reply_text(e)
|
56 |
-
t2 = time.time()
|
57 |
-
await message.reply_text(f"<b>» ᴛᴏᴏᴋ {round(t2 - t1, 3)} sᴇᴄᴏɴᴅs ᴛᴏ ᴇxᴇᴄᴜᴛᴇ.</b>")
|
58 |
-
|
59 |
-
|
60 |
@app.on_message(filters.text & filters.user(OWNER_ID) & ~filters.forwarded & ~filters.via_bot)
|
61 |
async def executor(client: app, message: Message):
|
62 |
"""Executes Python or shell commands based on plain text input."""
|
@@ -143,28 +127,3 @@ async def close_command(_, CallbackQuery: CallbackQuery):
|
|
143 |
|
144 |
await CallbackQuery.message.delete()
|
145 |
await CallbackQuery.answer()
|
146 |
-
|
147 |
-
|
148 |
-
@app.on_message(filters.command("checkban") & filters.user(OWNER_ID))
|
149 |
-
async def check_ban_status(client, message):
|
150 |
-
"""Check if owner is banned and unban if needed."""
|
151 |
-
user_id = message.from_user.id
|
152 |
-
|
153 |
-
# Check if user is banned locally
|
154 |
-
is_banned = await is_banned_user(user_id)
|
155 |
-
# Check if user is globally banned
|
156 |
-
is_gbanned = await is_gbanned_user(user_id)
|
157 |
-
|
158 |
-
if is_banned:
|
159 |
-
await remove_banned_user(user_id)
|
160 |
-
await message.reply_text("✅ You were locally banned. You have been unbanned.")
|
161 |
-
elif is_gbanned:
|
162 |
-
await remove_gban_user(user_id)
|
163 |
-
await message.reply_text("✅ You were globally banned. You have been unbanned.")
|
164 |
-
else:
|
165 |
-
await message.reply_text("✅ You are not banned.")
|
166 |
-
|
167 |
-
# Also remove from BANNED_USERS set if present
|
168 |
-
if user_id in BANNED_USERS:
|
169 |
-
BANNED_USERS.remove(user_id)
|
170 |
-
await message.reply_text("✅ Removed from BANNED_USERS set.")
|
|
|
10 |
from pyrogram import filters
|
11 |
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, CallbackQuery
|
12 |
|
13 |
+
from AnonXMusic import app
|
14 |
+
from config import OWNER_ID
|
15 |
+
from AnonXMusic.core.mongo import mongodb
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
async def aexec(code, client, message):
|
18 |
+
afkdb = mongodb.afk
|
19 |
+
|
20 |
+
# Create a local execution environment
|
21 |
+
local_vars = {
|
22 |
+
"client": client,
|
23 |
+
"message": message,
|
24 |
+
"afkdb": afkdb,
|
25 |
+
"get_afk_users": lambda: afkdb.find({"user_id": {"$gt": 0}}).to_list(1000),
|
26 |
+
}
|
27 |
+
|
28 |
+
# Prepare the async wrapper function
|
29 |
exec(
|
30 |
+
f"async def __aexec(client, message):\n"
|
31 |
+
+ "".join(f" {l}\n" for l in code.split("\n")),
|
32 |
+
globals(),
|
33 |
+
local_vars,
|
|
|
|
|
|
|
|
|
34 |
)
|
35 |
+
|
36 |
+
return await local_vars["__aexec"](client, message)
|
37 |
|
38 |
|
39 |
async def edit_or_reply(msg: Message, **kwargs):
|
|
|
41 |
await func(**kwargs)
|
42 |
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
@app.on_message(filters.text & filters.user(OWNER_ID) & ~filters.forwarded & ~filters.via_bot)
|
45 |
async def executor(client: app, message: Message):
|
46 |
"""Executes Python or shell commands based on plain text input."""
|
|
|
127 |
|
128 |
await CallbackQuery.message.delete()
|
129 |
await CallbackQuery.answer()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|