Class: WitBot::MessageThread
- Inherits:
-
Object
- Object
- WitBot::MessageThread
- Defined in:
- lib/wit_bot/models/message_thread.rb
Instance Attribute Summary collapse
-
#bot_messages ⇒ Object
readonly
Returns the value of attribute bot_messages.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Instance Method Summary collapse
- #context ⇒ Object
- #create_bot_message(text, id = SecureRandom.uuid) ⇒ Object
- #create_message(text, id = SecureRandom.uuid) ⇒ Object
-
#initialize(id = SecureRandom.uuid) ⇒ MessageThread
constructor
A new instance of MessageThread.
- #message(id) ⇒ Object
- #messages_list(user: true, bot: false) ⇒ Object
- #reset_context ⇒ Object
Constructor Details
#initialize(id = SecureRandom.uuid) ⇒ MessageThread
Returns a new instance of MessageThread.
7 8 9 10 11 |
# File 'lib/wit_bot/models/message_thread.rb', line 7 def initialize(id=SecureRandom.uuid) @id = id = ActiveSupport::OrderedHash.new = ActiveSupport::OrderedHash.new end |
Instance Attribute Details
#bot_messages ⇒ Object (readonly)
Returns the value of attribute bot_messages.
5 6 7 |
# File 'lib/wit_bot/models/message_thread.rb', line 5 def end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/wit_bot/models/message_thread.rb', line 5 def id @id end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
5 6 7 |
# File 'lib/wit_bot/models/message_thread.rb', line 5 def end |
#metadata ⇒ Object
Returns the value of attribute metadata.
3 4 5 |
# File 'lib/wit_bot/models/message_thread.rb', line 3 def end |
Instance Method Details
#context ⇒ Object
31 32 33 |
# File 'lib/wit_bot/models/message_thread.rb', line 31 def context @context ||= Context.new end |
#create_bot_message(text, id = SecureRandom.uuid) ⇒ Object
27 28 29 |
# File 'lib/wit_bot/models/message_thread.rb', line 27 def (text, id=SecureRandom.uuid) [id] = WitBot::Bot::Message.new self, text, id: id end |
#create_message(text, id = SecureRandom.uuid) ⇒ Object
23 24 25 |
# File 'lib/wit_bot/models/message_thread.rb', line 23 def (text, id=SecureRandom.uuid) [id] = WitBot::Message.new self, text, id: id end |
#message(id) ⇒ Object
13 14 15 |
# File 'lib/wit_bot/models/message_thread.rb', line 13 def (id) [id] end |
#messages_list(user: true, bot: false) ⇒ Object
17 18 19 20 21 |
# File 'lib/wit_bot/models/message_thread.rb', line 17 def (user: true, bot: false) = bot ? .values : [] = user ? .values : [] + end |
#reset_context ⇒ Object
35 36 37 |
# File 'lib/wit_bot/models/message_thread.rb', line 35 def reset_context @context = Context.new end |