class Pepito::Handlers::Help

Handler to give an help command.

Public Instance Methods

chat_help(_source, _match_data) click to toggle source

Return the help strings. @param _source [Pepito::Source] Source of the message. Not used. @param _match_data [MatchData] Match Data. Not used. @return [Array<String>]

# File lib/pepito/handlers/help.rb, line 17
def chat_help(_source, _match_data)
  strings = []
  @robot.handlers.each do |_, handler|
    handler.chat_routes.each do |route|
      next if route.help.nil?
      strings << help_string(route)
    end
  end
  strings
end
run() click to toggle source

Run the handler. @return [void]

# File lib/pepito/handlers/help.rb, line 9
def run
  chat_route(/^help$/i, :chat_help, command: true, help: 'help -> show this screen')
end

Private Instance Methods

help_string(route) click to toggle source
# File lib/pepito/handlers/help.rb, line 30
def help_string(route)
  return @robot.name + ' ' + route.help if route.command
  route.help
end