Class: Lita::Handlers::Fortune
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Fortune
- Defined in:
- lib/lita/handlers/fortune.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.default_config(handler_config) ⇒ Object
10 11 |
# File 'lib/lita/handlers/fortune.rb', line 10 def self.default_config(handler_config) end |
Instance Method Details
#fortune(response) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lita/handlers/fortune.rb', line 17 def fortune(response) if File.exist?('/usr/bin/fortune') cmd = '/usr/bin/fortune' elsif File.exist?('/usr/local/bin/fortune') cmd = '/usr/local/bin/fortune' elsif File.exist?('/usr/games/fortune') cmd = '/usr/games/fortune' else cmd = 'fortune' end f = run_cmd(cmd) f = "No fortune for you!" if ! f || f.empty? response.reply f end |
#run_cmd(cmd) ⇒ Object
13 14 15 |
# File 'lib/lita/handlers/fortune.rb', line 13 def run_cmd(cmd) `#{cmd}` end |