This commit is contained in:
Luke Rogers 2011-11-20 22:23:31 +13:00
commit 37588421f3
100 changed files with 22673 additions and 0 deletions

24
plugins/pyexec.py Normal file
View file

@ -0,0 +1,24 @@
import re
from util import hook, http
re_lineends = re.compile(r'[\r\n]*')
@hook.command
def python(inp):
".python <prog> -- executes python code <prog>"
inp = inp.replace("~n", "\n")
res = http.get("http://eval.appspot.com/eval", statement=inp).splitlines()
if len(res) == 0:
return
res[0] = re_lineends.split(res[0])[0]
if not res[0] == 'Traceback (most recent call last):':
return res[0].decode('utf8', 'ignore')
else:
return res[-1].decode('utf8', 'ignore')