1
0
mirror of https://github.com/osmarks/autobotrobot synced 2024-06-18 11:09:57 +00:00
autobotrobot/src/tio.py

25 lines
618 B
Python
Raw Normal View History

2019-10-21 20:07:17 +00:00
import pytio
import http3
import gzip
import io
tio = pytio.Tio()
def languages():
return tio.query_languages()
aliases = {
"python": "python3"
}
client = http3.AsyncClient()
async def run(lang, code):
req = pytio.TioRequest(aliases.get(lang, lang), code)
res = await client.post("https://tio.run/cgi-bin/run/api/", data=req.as_deflated_bytes(), timeout=65)
content = res.content.decode("UTF-8")
split = list(filter(lambda x: x != "\n" and x != "", content.split(content[:16])))
if len(split) == 1:
return False, split[0], None
else:
return True, split[0], split[1]