Class: Ruboty::Handlers::Command
- Inherits:
-
Base
- Object
- Base
- Ruboty::Handlers::Command
- Defined in:
- lib/ruboty/handlers/command.rb
Class Method Summary collapse
-
.register_commands ⇒ Object
Registering commands.
Instance Method Summary collapse
Class Method Details
.register_commands ⇒ Object
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() Ruboty::ExecCommand::Actions::Command.new().call end |
#kill_command(message) ⇒ Object
33 34 35 |
# File 'lib/ruboty/handlers/command.rb', line 33 def kill_command() Ruboty::ExecCommand::Actions::Command.new().kill_command end |
#list_commands(message) ⇒ Object
29 30 31 |
# File 'lib/ruboty/handlers/command.rb', line 29 def list_commands() Ruboty::ExecCommand::Actions::Command.new().list_commands end |