mirror of
https://github.com/Nick80835/microbot
synced 2025-08-29 13:38:55 +00:00
add a client shortcut to eval/exec
This commit is contained in:
parent
07a5cdbcb2
commit
09ee6a4608
@ -23,7 +23,10 @@ async def evaluate(event):
|
||||
return
|
||||
|
||||
eval_msg = await event.reply("Processing…")
|
||||
|
||||
# helpful variables
|
||||
reply = await event.get_reply_message()
|
||||
client = event.client
|
||||
|
||||
try:
|
||||
eval_ret = eval(event.args)
|
||||
@ -51,6 +54,7 @@ async def evaluate(event):
|
||||
async def execute(event):
|
||||
exec_msg = await event.reply("Processing…")
|
||||
reply = await event.get_reply_message()
|
||||
client = event.client
|
||||
|
||||
if not event.args:
|
||||
await event.edit("Give me code to run!")
|
||||
@ -60,13 +64,13 @@ async def execute(event):
|
||||
|
||||
try:
|
||||
exec(
|
||||
f'async def __ex(event, reply): ' +
|
||||
f'async def __ex(event, reply, client): ' +
|
||||
''.join(f'\n {l}' for l in event.args.split('\n')),
|
||||
globals(),
|
||||
temp_locals
|
||||
)
|
||||
|
||||
eval_ret = await temp_locals['__ex'](event, reply)
|
||||
eval_ret = await temp_locals['__ex'](event, reply, client)
|
||||
except Exception as exception:
|
||||
print_exc()
|
||||
eval_ret = exception
|
||||
|
Loading…
x
Reference in New Issue
Block a user