Class: WitBot::Bot::Conversation::Base
- Inherits:
-
Object
- Object
- WitBot::Bot::Conversation::Base
- Includes:
- Observable
- Defined in:
- lib/wit_bot/bot/conversation/base.rb
Instance Method Summary collapse
- #input(input) ⇒ Object
- #listen_with(listener_class) ⇒ Object
- #messages(user: true, bot: true) ⇒ Object
- #metadata ⇒ Object
- #output(text) ⇒ Object
- #send_message(text, sender = nil) ⇒ Object
- #thread ⇒ Object
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) = thread. input .send 1, false changed notify_observers :input, 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 (user: true, bot: true) thread. user, bot end |
#metadata ⇒ Object
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) = thread. text changed notify_observers :output, end |
#send_message(text, sender = nil) ⇒ Object
19 20 21 |
# File 'lib/wit_bot/bot/conversation/base.rb', line 19 def (text, sender=nil) sender && sender.bot? ? output(text) : input(text) end |
#thread ⇒ Object
11 12 13 |
# File 'lib/wit_bot/bot/conversation/base.rb', line 11 def thread @thread ||= MessageThread.new("#{self.class.name}-#{SecureRandom.uuid}") end |