Class: Lita::Handlers::Whats

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/whats.rb

Instance Method Summary collapse

Instance Method Details

#whats(response) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/lita/handlers/whats.rb', line 9

def whats(response)
  hostname = response.matches[0][0]
  whats_cmd = "whats -q -j #{hostname}"
  output = `#{whats_cmd}`
  message = ""
  JSON.parse(output).each_pair do |k,v|
    message = message + "*#{k}*:  #{v}\n"
  end
  response.reply message
end