class Ruboty::Handlers::Command

Public Class Methods

register_commands() click to toggle source

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

# 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

Public Instance Methods

command_handler(message) click to toggle source
# File lib/ruboty/handlers/command.rb, line 25
def command_handler(message)
  Ruboty::ExecCommand::Actions::Command.new(message).call
end
kill_command(message) click to toggle source
# File lib/ruboty/handlers/command.rb, line 33
def kill_command(message)
  Ruboty::ExecCommand::Actions::Command.new(message).kill_command
end
list_commands(message) click to toggle source
# File lib/ruboty/handlers/command.rb, line 29
def list_commands(message)
  Ruboty::ExecCommand::Actions::Command.new(message).list_commands
end