| 12345678910111213141516171819202122232425262728 |
- require 'optparse'
- class Command
- attr_reader :name, :operation
- def initialize(name, description, options ={}, &block)
- @name = name
- @description = description
- @options = options
- @operation = block
- end
- def description
- @description
- end
- def options
- @options
- end
- 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
|