Sha256: 73c4a48799d6d406360e7581218f2a6c5c12dea0308199cec6288f402d8c4014

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 Bytes

Contents

module Lita
  module Extensions
    class Confirmation
      attr_reader :handler, :message, :robot, :route

      def self.call(payload)
        new(
          payload.fetch(:handler),
          payload.fetch(:message),
          payload.fetch(:robot),
          payload.fetch(:route)
        ).call
      end

      def initialize(handler, message, robot, route)
        @handler = handler
        @message = message
        @robot = robot
        @route = route
      end

      def call
        if (options = route.extensions[:confirmation])
          message.reply(
            I18n.t(
              "lita.extensions.confirmation.request",
              code: UnconfirmedCommand.new(handler, message, robot, route, options).code
            )
          )

          return false
        end

        true
      end
    end

    Lita.register_hook(:validate_route, Confirmation)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lita-confirmation-1.0.1 lib/lita/extensions/confirmation.rb
lita-confirmation-1.0.0 lib/lita/extensions/confirmation.rb
lita-confirmation-0.0.1 lib/lita/extensions/confirmation.rb