Class: Ruboty::Handlers::Command

Inherits:
Base
  • Object
show all
Defined in:
lib/ruboty/handlers/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.register_commandsObject

Registering commands. Each command is located under “commands” directory. The path name to the executable command is gonna be a command name.

i.e. commands/server/monitor => /server monitor/

The command should return a usage with -h option



18
19
20
21
22
# File 'lib/ruboty/handlers/command.rb', line 18

def self.register_commands
  Ruboty::ExecCommand::Command.all.each do |e|
    on /#{e.command_name}/i, name: "command_handler", description: e.help
  end
end

Instance Method Details

#command_handler(message) ⇒ Object



24
25
26
# File 'lib/ruboty/handlers/command.rb', line 24

def command_handler(message)
  Ruboty::ExecCommand::Actions::Command.new(message).call
end

#kill_command(message) ⇒ Object



32
33
34
# File 'lib/ruboty/handlers/command.rb', line 32

def kill_command(message)
  Ruboty::ExecCommand::Actions::Command.new(message).kill_command
end

#list_commands(message) ⇒ Object



28
29
30
# File 'lib/ruboty/handlers/command.rb', line 28

def list_commands(message)
  Ruboty::ExecCommand::Actions::Command.new(message).list_commands
end