Sha256: 6a7c80876a273897ae13e28443294baa786f520703cbae8f68a892a14fffae07
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
Contents
module Lita module Handlers class Help < Handler route(/^help\s*(.+)?/, to: :help, command: true) def self.help robot_name = Lita.config.robot.name { "#{robot_name}: help" => "Lists help information for terms and commands #{robot_name} will respond to.", "#{robot_name}: help COMMAND" => "Lists help information for terms and commands starting with COMMAND." } end def help(matches) commands = {} Lita.handlers.each do |handler| commands.merge!(handler.help) if handler.respond_to?(:help) end filter = matches[0][0] if filter robot_name = Lita.config.robot.name commands.select! do |key, value| /^#{filter}/i === key.sub(/^\s*@?#{robot_name}[:,]?\s*/, "") end end message = commands.map do |command, description| "#{command} - #{description}" end.join("\n") reply message end end Lita.register_handler(Help) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lita-1.1.2 | lib/lita/handlers/help.rb |
lita-1.1.1 | lib/lita/handlers/help.rb |
lita-1.1.0 | lib/lita/handlers/help.rb |
lita-1.0.0 | lib/lita/handlers/help.rb |