2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-29 21:48:17 +00:00

add a client shortcut to eval/exec

This commit is contained in:
Nick80835 2023-10-12 21:57:53 -04:00
parent 07a5cdbcb2
commit 09ee6a4608

View File

@ -23,7 +23,10 @@ async def evaluate(event):
return return
eval_msg = await event.reply("Processing…") eval_msg = await event.reply("Processing…")
# helpful variables
reply = await event.get_reply_message() reply = await event.get_reply_message()
client = event.client
try: try:
eval_ret = eval(event.args) eval_ret = eval(event.args)
@ -51,6 +54,7 @@ async def evaluate(event):
async def execute(event): async def execute(event):
exec_msg = await event.reply("Processing…") exec_msg = await event.reply("Processing…")
reply = await event.get_reply_message() reply = await event.get_reply_message()
client = event.client
if not event.args: if not event.args:
await event.edit("Give me code to run!") await event.edit("Give me code to run!")
@ -60,13 +64,13 @@ async def execute(event):
try: try:
exec( 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')), ''.join(f'\n {l}' for l in event.args.split('\n')),
globals(), globals(),
temp_locals temp_locals
) )
eval_ret = await temp_locals['__ex'](event, reply) eval_ret = await temp_locals['__ex'](event, reply, client)
except Exception as exception: except Exception as exception:
print_exc() print_exc()
eval_ret = exception eval_ret = exception