This commit is contained in:
yasirarism 2022-12-21 07:34:41 +07:00 committed by GitHub
parent 063aa981b5
commit 23f9ea2059
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@ import os
import traceback import traceback
import asyncio import asyncio
from pyrogram import filters, enums from pyrogram import filters, enums
from misskaty import app from misskaty import app, user
from misskaty.vars import COMMAND_HANDLER, SUDO from misskaty.vars import COMMAND_HANDLER, SUDO
__MODULE__ = "DevCommand" __MODULE__ = "DevCommand"
@ -55,34 +55,35 @@ async def neofetch(c, m):
@app.on_edited_message( @app.on_edited_message(
filters.command(["shell", "sh"], COMMAND_HANDLER) & filters.user(SUDO) filters.command(["shell", "sh"], COMMAND_HANDLER) & filters.user(SUDO)
) )
async def shell(client, message): async def shell(_, m):
cmd = message.text.split(" ", 1) cmd = m.text.split(" ", 1)
if len(cmd) == 1: if len(cmd) == 1:
return await message.reply("No command to execute was given.") return await m.reply("No command to execute was given.")
shell = (await shell_exec(cmd[1]))[0] shell = (await shell_exec(cmd[1]))[0]
if len(shell) > 3000: if len(shell) > 3000:
with open("shell_output.txt", "w") as file: with open("shell_output.txt", "w") as file:
file.write(shell) file.write(shell)
with open("shell_output.txt", "rb") as doc: with open("shell_output.txt", "rb") as doc:
await message.reply_document(document=doc, file_name=doc.name) await m.reply_document(document=doc, file_name=doc.name)
try: try:
os.remove("shell_output.txt") os.remove("shell_output.txt")
except: except:
pass pass
elif len(shell) != 0: elif len(shell) != 0:
await message.reply(shell, parse_mode=enums.ParseMode.HTML) await m.reply(shell, parse_mode=enums.ParseMode.HTML)
else: else:
await message.reply("No Reply") await m.reply("No Reply")
@app.on_message(filters.command(["ev", "run"], COMMAND_HANDLER) & filters.user(SUDO)) @app.on_message(filters.command(["ev", "run"], COMMAND_HANDLER) & filters.user(SUDO))
@app.on_edited_message(filters.command(["ev", "run"]) & filters.user(SUDO)) @app.on_edited_message(filters.command(["ev", "run"]) & filters.user(SUDO))
async def evaluation_cmd_t(client, message): async def evaluation_cmd_t(_, m):
status_message = await message.reply("__Processing eval pyrogram...__") status_message = await m.reply("__Processing eval pyrogram...__")
try: try:
cmd = message.text.split(" ", maxsplit=1)[1] cmd = m.text.split(" ", maxsplit=1)[1]
except IndexError: except IndexError:
return await status_message.edit("__No evaluate message!__") return await status_message.edit("__No evaluate message!__")
p = print
old_stderr = sys.stderr old_stderr = sys.stderr
old_stdout = sys.stdout old_stdout = sys.stdout
redirected_output = sys.stdout = io.StringIO() redirected_output = sys.stdout = io.StringIO()
@ -116,7 +117,7 @@ async def evaluation_cmd_t(client, message):
out_file.write(final_output) out_file.write(final_output)
await status_message.reply_document( await status_message.reply_document(
document="MissKatyEval.txt", document="MissKatyEval.txt",
caption=cmd[: 4096 // 4 - 1], caption=f"<code>{cmd[: 4096 // 4 - 1]}</code>",
disable_notification=True, disable_notification=True,
) )
os.remove("MissKatyEval.txt") os.remove("MissKatyEval.txt")