Sha256: 5d3e263520fd6a95e90dfc0387b825b2641df091c3b728fcf6fdaa48a0e5948d

Contents?: true

Size: 453 Bytes

Versions: 10

Compression:

Stored size: 453 Bytes

Contents

class Bot::BotController < ActionController::Base
  def notify
    @responses = bot_handler.handle(messages).compact

    adapter.send_messages(@responses, params[:bot_username]) if @responses.present?

    render json: []
  end

  private

  def messages
    Array.wrap(params[:messages]).map do |m|
      m.merge(to: params[:bot_username])
    end
  end

  def adapter
    Bot.configuration.adapter
  end

  def bot_handler
    params[:bot]
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bot-0.0.35 app/controllers/bot/bot_controller.rb
bot-0.0.34 app/controllers/bot/bot_controller.rb
bot-0.0.33 app/controllers/bot/bot_controller.rb
bot-0.0.32 app/controllers/bot/bot_controller.rb
bot-0.0.31 app/controllers/bot/bot_controller.rb
bot-0.0.30 app/controllers/bot/bot_controller.rb
bot-0.0.29 app/controllers/bot/bot_controller.rb
bot-0.0.28 app/controllers/bot/bot_controller.rb
bot-0.0.27 app/controllers/bot/bot_controller.rb
bot-0.0.26 app/controllers/bot/bot_controller.rb