예제 #1
0
def eval_command(sender, args, replyTo):
  if " " not in args:
    return api.msg(replyTo, usage)

  script, arg = args.split(" ", 1)
  if not script.isalpha():
    return api.msg(replyTo, usage)

  bg(execute, sender, script, arg, replyTo)
예제 #2
0
def execute(sender, script, arg, chan):
  filepath = inspect.getfile(inspect.currentframe())
  script = os.path.join(os.path.dirname(filepath), "eval", script + ".sh")
  cmd = ["bash", script, arg]  # "'%s'"%arg]
  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  threading.Timer(5, p.terminate) # Kill after 5 seconds
  out, err=  p.communicate()

  print("EVAL RESULT", repr(cmd))
  print("OUT:" + out.decode('utf-8', 'ignore'))
  print("ERR:" + err.decode('utf-8', 'ignore'))
  print("EXT:" + str(p.returncode))

  exitLine = ""
  if p.returncode:
      exitLine = "{RED} " + humanizeSignal(p.returncode) +"{}"

  if out or exitLine:
    out = shorten(repr(out)[2:-1])
    api.msg(chan, stdoutFmt.format(exitLine, out))

  if err:
    err = repr(err)[2:-1]
    api.msg(chan, stderrFmt.format(shorten(err)))
예제 #3
0
def cmd(who, args, chan):
    args = shlex.split(args)

    cmd = args[0]
    if cmd not in whitelist:
        api.msg(chan, errFmt.format("Invalid command"))
        return

    try:
        ret = getattr(redis, cmd)(*args[1:])
    except db.redis.exceptions.ResponseError as e:
        api.msg(chan, errFmt.format(e))
        return

    api.msg(chan, okFmt.format(ret))
예제 #4
0
def cmd(who, args, chan):
  args = shlex.split(args)

  cmd = args[0]
  if cmd not in whitelist:
    api.msg(chan, errFmt.format("Invalid command"))
    return

  try:
    ret = getattr(redis, cmd)(*args[1:])
  except db.redis.exceptions.ResponseError as e:
    api.msg(chan, errFmt.format(e))
    return

  api.msg(chan, okFmt.format(ret))
예제 #5
0
def showColors(src, args, chan):
    api.msg(chan, message)
예제 #6
0
def showColors(src, args, chan):
  api.msg(chan, message)