| 123456789101112131415161718192021222324 |
- require 'optparse'
- class Command
- attr_reader :name, :operation
- def initialize(name, description, options = {}, &block)
- @name = name
- @description = description
- @options = options
- @operation = block
- end
- attr_reader :description
- attr_reader :options
- def call(message_str, event=nil)
- match = /pkmn-\w+\s?(.*)/.match(message_str)
- args = match[1]
- params = args.split(/\s?\|\s?/).reject(&:empty?)
- operation.call(event, *params)
- end
- end
|