Class: Jambots::Controllers::ChatController

Inherits:
Object
  • Object
show all
Defined in:
lib/jambots/controllers/chat_controller.rb

Constant Summary collapse

DEFAULT_BOT =
"jambot"
DEFAULT_TIMEOUT =
240

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ChatController

Returns a new instance of ChatController.



10
11
12
13
14
15
16
17
18
19
# File 'lib/jambots/controllers/chat_controller.rb', line 10

def initialize(options)
  bot_name = bot_name(options)
  bot_options = bot_options(options)
  @bot = Jambots::Bot.new(bot_name, bot_options)

  conversation_options = conversation_options(options)
  @conversation = load_conversation(conversation_options)

  @renderer = load_renderer(options)
end

Instance Attribute Details

#botObject (readonly)

Returns the value of attribute bot.



8
9
10
# File 'lib/jambots/controllers/chat_controller.rb', line 8

def bot
  @bot
end

#conversationObject (readonly)

Returns the value of attribute conversation.



8
9
10
# File 'lib/jambots/controllers/chat_controller.rb', line 8

def conversation
  @conversation
end

#rendererObject (readonly)

Returns the value of attribute renderer.



8
9
10
# File 'lib/jambots/controllers/chat_controller.rb', line 8

def renderer
  @renderer
end

Instance Method Details

#chat(query) ⇒ Object



21
22
23
24
25
# File 'lib/jambots/controllers/chat_controller.rb', line 21

def chat(query)
  renderer.render(conversation) do
    bot.message(query, conversation)
  end
end