From: John Runyon Date: Sat, 23 Mar 2024 06:09:40 +0000 (-0600) Subject: eval - add !SYSTEM X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/d522e2fd6465b955bdd53a26bb11aff6dd69b102 eval - add !SYSTEM --- diff --git a/modules/eval.py b/modules/eval.py index 77f6a1a..698b226 100644 --- a/modules/eval.py +++ b/modules/eval.py @@ -19,8 +19,8 @@ modstart = lib.modstart modstop = lib.modstop # module code +import os import sys -import ctlmod def module(name): @@ -49,6 +49,19 @@ def cmd_exec(bot, user, chan, realtarget, *args): except Exception: bot.msg(replyto, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1])) else: bot.msg(replyto, "Done.") +@lib.hook(needchan=False, wantchan=True, glevel=lib.OWNER) +@lib.help('', 'think os.system') +@lib.argsGE(1) +def system(bot, user, chan, realtarget, *args): + if chan is not None: replyto = chan + else: replyto = user + + try: prochandle = os.popen(' '.join(args)) + except Exception: bot.msg(replyto, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1])) + else: + for line in prochandle: + bot.msg(replyto, line) + @lib.hook('exception', needchan=False, glevel=lib.OWNER) @lib.help(None, "cause an exception") def cmd_exception(*args, **kwargs):