def c_eval(self, message, server, channel, author, stmt, args):
"""
Evaluates Python code
{prefix}eval <code>
If the result is a coroutine, it will be awaited
"""
stmt = ' '.join([stmt, *args])
try:
result = eval(stmt)
if inspect.isawaitable(result):
result = await result
except Exception as e:
exc = traceback.format_exc().splitlines()
result = exc[-1]
log.debug("Evaluated: {} - Result was: {}".format(stmt, result))
return Response("```xl\n--- In ---\n{}\n--- Out ---\n{}\n```".format(stmt, result))
评论列表
文章目录