module AutovoiceCommand
AutovoiceCommand — parse !autovoice subcommands. Public: parse, usage_message Depends: AutovoiceStore Tests: test/plugins/autovoice_test.rb
Constants
- USAGE
Public Instance Methods
Source
# File lib/autovoice/command.rb, line 19 def parse(args) text = args.to_s.strip return { action: :status } if text.empty? case text.downcase when "on" { action: :on } when "off" { action: :off } when "status" { action: :status } when "now" { action: :now } else parse_interval(text) || { error: USAGE } end end
Source
# File lib/autovoice/command.rb, line 37 def parse_interval(text) match = text.match(/\Ainterval\s+(\d+)\z/i) return nil unless match minutes = AutovoiceStore.clamp_interval(match[1]) return { error: "Interval must be between #{AutovoiceStore::MIN_INTERVAL_MIN} and #{AutovoiceStore::MAX_INTERVAL_MIN} minutes." } if minutes != match[1].to_i { action: :interval, minutes: minutes } end