Update Akeno/plugins/eval.py
Browse files- Akeno/plugins/eval.py +57 -0
Akeno/plugins/eval.py
CHANGED
@@ -34,6 +34,62 @@ from Akeno.utils.handler import *
|
|
34 |
from Akeno.utils.scripts import get_args, get_args_raw, shell_exec, with_args
|
35 |
from config import CMD_HANDLER
|
36 |
from config import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
@Akeno(
|
39 |
~filters.scheduled
|
@@ -105,6 +161,7 @@ async def aexec(code, client, message):
|
|
105 |
+ " chat = message.chat.id\n"
|
106 |
+ " c = client\n"
|
107 |
+ " to_photo = message.reply_photo\n"
|
|
|
108 |
)
|
109 |
+ "".join(f"\n {l}" for l in code.split("\n"))
|
110 |
)
|
|
|
34 |
from Akeno.utils.scripts import get_args, get_args_raw, shell_exec, with_args
|
35 |
from config import CMD_HANDLER
|
36 |
from config import *
|
37 |
+
from urllib.parse import quote, unquote
|
38 |
+
from json.decoder import JSONDecodeError
|
39 |
+
from pprint import pprint
|
40 |
+
|
41 |
+
|
42 |
+
class u:
|
43 |
+
_ = ""
|
44 |
+
|
45 |
+
def _stringify(text=None, *args, **kwargs):
|
46 |
+
if text:
|
47 |
+
u._ = text
|
48 |
+
text = _parse_eval(text)
|
49 |
+
return print(text, *args, **kwargs)
|
50 |
+
|
51 |
+
def _unquote_text(text):
|
52 |
+
return text.replace("'", unquote("%5C%27")).replace('"', unquote("%5C%22"))
|
53 |
+
|
54 |
+
def json_parser(data, indent=None, ascii=False):
|
55 |
+
parsed = {}
|
56 |
+
try:
|
57 |
+
if isinstance(data, str):
|
58 |
+
parsed = json.loads(str(data))
|
59 |
+
if indent:
|
60 |
+
parsed = json.dumps(
|
61 |
+
json.loads(str(data)), indent=indent, ensure_ascii=ascii
|
62 |
+
)
|
63 |
+
elif isinstance(data, dict):
|
64 |
+
parsed = data
|
65 |
+
if indent:
|
66 |
+
parsed = json.dumps(data, indent=indent, ensure_ascii=ascii)
|
67 |
+
except JSONDecodeError:
|
68 |
+
parsed = eval(data)
|
69 |
+
return parsed
|
70 |
+
|
71 |
+
def _parse_eval(value=None):
|
72 |
+
if not value:
|
73 |
+
return value
|
74 |
+
if hasattr(value, "stringify"):
|
75 |
+
try:
|
76 |
+
return value.stringify()
|
77 |
+
except TypeError:
|
78 |
+
pass
|
79 |
+
elif isinstance(value, dict):
|
80 |
+
try:
|
81 |
+
return json_parser(value, indent=1)
|
82 |
+
except BaseException:
|
83 |
+
pass
|
84 |
+
elif isinstance(value, list):
|
85 |
+
newlist = "["
|
86 |
+
for index, child in enumerate(value):
|
87 |
+
newlist += "\n " + str(_parse_eval(child))
|
88 |
+
if index < len(value) - 1:
|
89 |
+
newlist += ","
|
90 |
+
newlist += "\n]"
|
91 |
+
return newlist
|
92 |
+
return str(value)
|
93 |
|
94 |
@Akeno(
|
95 |
~filters.scheduled
|
|
|
161 |
+ " chat = message.chat.id\n"
|
162 |
+ " c = client\n"
|
163 |
+ " to_photo = message.reply_photo\n"
|
164 |
+
+ " print = p = _stringify\n"
|
165 |
)
|
166 |
+ "".join(f"\n {l}" for l in code.split("\n"))
|
167 |
)
|