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/

All of commands are called with -h option on the startup. The command should return a usage with -h option



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

def self.register_commands
  Ruboty::ExecCommand::Command.all.each do |e|
    on /#{e.command_name}(?:\z|\s+)/i, name: "command_handler", description: e.help
  end
end

Instance Method Details

#command_handler(message) ⇒ Object



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

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

#kill_command(message) ⇒ Object



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

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

#list_commands(message) ⇒ Object



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

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