class Ruboty::Handlers::Evaluate

Public Instance Methods

evaluate(message) click to toggle source
# File lib/ruboty/handlers/evaluate.rb, line 8
def evaluate(message)
  thread = Thread.start do
    stdout, stderr, _status = Open3.capture3(message[:command])
    stdout.chomp!.split("\n").each {|line| message.reply(line) } if stdout
    stderr.chomp!.split("\n").each {|line| message.reply(line) } if stderr
  end
  Thread.start do
    sleep 10
    thread.kill
  end
end