This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/util/execute.py
2012-09-02 23:48:47 +12:00

21 lines
529 B
Python

import http, web
import json, urllib2, sys
def eval_py(code, paste_multiline=True):
while True:
output = http.get("http://eval.appspot.com/eval", statement=code).rstrip('\n')
if output:
break
else:
pass
if "Traceback (most recent call last):" in output:
status = "Python error: "
else:
status = "Code executed sucessfully: "
if "\n" in output and paste_multiline:
return status + web.haste(output)
else:
return output