2019-05-25 20:40:06 +00:00
|
|
|
#--depends-on commands
|
|
|
|
|
2019-11-08 12:46:25 +00:00
|
|
|
import urllib.parse
|
2018-10-03 12:22:37 +00:00
|
|
|
from src import ModuleManager, utils
|
2018-09-19 12:56:57 +00:00
|
|
|
|
2019-11-08 12:46:25 +00:00
|
|
|
EVAL_URL = "http://dotpy3.herokuapp.com/"
|
2018-10-17 14:02:04 +00:00
|
|
|
|
2018-09-26 17:27:17 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2018-10-08 11:47:48 +00:00
|
|
|
_name = "Python"
|
2018-10-12 11:39:01 +00:00
|
|
|
|
2019-11-08 12:46:25 +00:00
|
|
|
@utils.hook("received.command.py", alias_of="python")
|
|
|
|
@utils.hook("received.command.python")
|
|
|
|
def _eval(self, event):
|
|
|
|
url = "%s?%s" % (EVAL_URL, urllib.parse.quote(event["args"]))
|
|
|
|
|
2018-10-24 12:54:22 +00:00
|
|
|
page = None
|
2018-09-19 12:56:57 +00:00
|
|
|
try:
|
2019-11-08 12:46:25 +00:00
|
|
|
page = utils.http.request(url)
|
2018-10-12 10:56:13 +00:00
|
|
|
except:
|
|
|
|
pass
|
2018-09-19 12:56:57 +00:00
|
|
|
|
2019-01-15 12:39:27 +00:00
|
|
|
if page and page.data:
|
2019-11-08 12:46:25 +00:00
|
|
|
event["stdout"].write("%s: %s" % (event["user"].nickname,
|
|
|
|
page.data.rstrip("\n")))
|
2018-10-12 11:39:01 +00:00
|
|
|
else:
|
|
|
|
event["stderr"].write("%s: failed to eval" % event["user"].nickname)
|