Class: WitBot::Bot::Conversation::Base

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/wit_bot/bot/conversation/base.rb

Instance Method Summary collapse

Instance Method Details

#input(input) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/wit_bot/bot/conversation/base.rb', line 23

def input(input)
  message = thread.create_message input
  message.send 1, false
  changed
  notify_observers :input, message
  message
end

#listen_with(listener_class) ⇒ Object



31
32
33
# File 'lib/wit_bot/bot/conversation/base.rb', line 31

def listen_with(listener_class)
  listener_class.new self
end

#messages(user: true, bot: true) ⇒ Object



15
16
17
# File 'lib/wit_bot/bot/conversation/base.rb', line 15

def messages(user: true, bot: true)
  thread.messages_list user, bot
end

#metadataObject



7
8
9
# File 'lib/wit_bot/bot/conversation/base.rb', line 7

def 
  thread.
end

#output(text) ⇒ Object



35
36
37
38
39
40
# File 'lib/wit_bot/bot/conversation/base.rb', line 35

def output(text)
  message = thread.create_bot_message text
  changed
  notify_observers :output, message
  message
end

#send_message(text, sender = nil) ⇒ Object



19
20
21
# File 'lib/wit_bot/bot/conversation/base.rb', line 19

def send_message(text, sender=nil)
  sender && sender.bot? ? output(text) : input(text)
end

#threadObject



11
12
13
# File 'lib/wit_bot/bot/conversation/base.rb', line 11

def thread
  @thread ||= MessageThread.new("#{self.class.name}-#{SecureRandom.uuid}")
end