]> jfr.im git - erebus.git/commitdiff
eval - add !SYSTEM
authorJohn Runyon <redacted>
Sat, 23 Mar 2024 06:09:40 +0000 (00:09 -0600)
committerJohn Runyon <redacted>
Sat, 23 Mar 2024 06:09:40 +0000 (00:09 -0600)
modules/eval.py

index 77f6a1adcb12a332c08e00a8f420990fe734337b..698b226463a8dd372013fb30adf0065b9fc7d455 100644 (file)
@@ -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('<command line>', '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):