Sha256: 2623f799da0d3786727942fe2c70462e845d353b1941bf43ccb5ad51efc80275

Contents?: true

Size: 689 Bytes

Versions: 4

Compression:

Stored size: 689 Bytes

Contents

module Ruboty
  module Actions
    class Help < Base
      def call
        message.reply(body, code: true)
      end

      private

      def body
        descriptions = all_descriptions
        if message[:filter]
          descriptions.select! do |description|
            description.include?(message[:filter])
          end
        end
        descriptions.join("\n")
      end

      def all_descriptions
        _descriptions = Ruboty.actions.reject(&:hidden?).sort.map do |action|
          prefix = ""
          prefix << message.robot.name << " " unless  action.all?
          "#{prefix}#{action.pattern.inspect} - #{action.description}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruboty-1.2.3 lib/ruboty/actions/help.rb
ruboty-1.2.2 lib/ruboty/actions/help.rb
ruboty-1.2.1 lib/ruboty/actions/help.rb
ruboty-1.2.0 lib/ruboty/actions/help.rb