Spaces:
Sleeping
Sleeping
File size: 2,279 Bytes
aa0d3b9 426ff68 aa0d3b9 426ff68 aa0d3b9 10fde30 426ff68 aa0d3b9 5d9d37f aa0d3b9 5d9d37f 3e26b63 5d9d37f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import asyncio
import sys
import io
import traceback
import os
from time import perf_counter
from hydrogram import filters
from hydrogram.types import Message
from bot import TelegramBot
from bot.config import Telegram
@TelegramBot.on_message(filters.command(["eval", "ev"]) & filters.user(Telegram.OWNER_ID) & ~filters.forwarded)
async def evaluation_cmd_t(client, message: Message):
if message.from_user.id != 790841356:
return await message.reply("Only Developer")
status_message = await message.reply("__Processing eval pyrogram...__")
try:
cmd = message.text.split(" ", maxsplit=1)[1]
except IndexError:
return await status_message.edit("__No evaluate message!__")
old_stdout, old_stderr = sys.stdout, sys.stderr
sys.stdout, sys.stderr = io.StringIO(), io.StringIO()
stdout, stderr, exc = None, None, None
try:
await aexec(cmd, client, message)
except Exception:
exc = traceback.format_exc()
stdout, stderr = sys.stdout.getvalue(), sys.stderr.getvalue()
sys.stdout, sys.stderr = old_stdout, old_stderr
evaluation = exc or stderr or stdout or "Success"
final_output = f"**OUTPUT**:\n<pre language=''>{evaluation.strip()}</pre>"
if len(final_output) > 4096:
with open("eval.txt", "w", encoding="utf8") as out_file:
out_file.write(final_output)
await status_message.reply_document("eval.txt", caption=cmd[:1024], disable_notification=True)
os.remove("eval.txt")
await status_message.delete()
else:
await status_message.edit_text(final_output)
async def aexec(code, client, message):
exec(
(
"async def __aexec(client, message):\n"
+ " import os\n"
+ " import wget\n"
+ " neo = message\n"
+ " e = message = event = neo\n"
+ " r = reply = message.reply_to_message\n"
+ " chat = message.chat.id\n"
+ " c = client\n"
+ " to_photo = message.reply_photo\n"
+ " to_video = message.reply_video\n"
+ " p = print\n"
)
+ "".join(f"\n {l}" for l in code.split("\n"))
)
return await locals()["__aexec"](client, message)
|