Class: Pepito::Handlers::Help

Inherits:
Pepito::Handler show all
Defined in:
lib/pepito/handlers/help.rb

Overview

Handler to give an help command.

Instance Attribute Summary

Attributes inherited from Pepito::Handler

#robot

Instance Method Summary collapse

Methods inherited from Pepito::Handler

#initialize, #start

Methods included from Pepito::Handler::ChatRouter

#chat_route, #chat_routes

Methods included from Pepito::Handler::HTTPRouter

#http_route, #http_routes

Constructor Details

This class inherits a constructor from Pepito::Handler

Instance Method Details

#chat_help(_source, _match_data) ⇒ Array<String>

Return the help strings.

Parameters:

  • _source (Pepito::Source)

    Source of the message. Not used.

  • _match_data (MatchData)

    Match Data. Not used.

Returns:

  • (Array<String>)


17
18
19
20
21
22
23
24
25
26
# 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

#runvoid

This method returns an undefined value.

Run the handler.



9
10
11
# File 'lib/pepito/handlers/help.rb', line 9

def run
  chat_route(/^help$/i, :chat_help, command: true, help: 'help -> show this screen')
end