class Voltron::Defender::Command

Attributes

input[RW]

Public Instance Methods

answer(text, adapter) click to toggle source
# File lib/voltron/defender/command.rb, line 39
def answer(text, adapter)
end
args() click to toggle source
# File lib/voltron/defender/command.rb, line 35
def args
  @input[:args].to_s.split(/\s+/)
end
command() click to toggle source
# File lib/voltron/defender/command.rb, line 27
def command
  @input[:command].to_s
end
error() click to toggle source
# File lib/voltron/defender/command.rb, line 17
def error
  if ::Voltron::Defender::Error.exists?(id)
    ::Voltron::Defender::Error.find(id)
  elsif ::Voltron::Defender::Error.count > 0
    ::Voltron::Defender::Error.last
  else
    false
  end
end
help() click to toggle source
# File lib/voltron/defender/command.rb, line 42
def help
end
id() click to toggle source
# File lib/voltron/defender/command.rb, line 31
def id
  @input[:id].to_i
end
matches?(text) click to toggle source
# File lib/voltron/defender/command.rb, line 12
def matches?(text)
  parse(text)
  Array.wrap(responds_to).include?(command)
end
parse(text) click to toggle source
# File lib/voltron/defender/command.rb, line 7
def parse(text)
  text.downcase!
  @input = /^\.(?<command>[a-z]+)\s*(?<id>[0-9]+)*\s*(?<args>.*)/.match(text) || {}
end