Class: Socrates::SampleStates::Dms

Inherits:
Object
  • Object
show all
Includes:
Core::State
Defined in:
lib/socrates/sample_states.rb

Instance Attribute Summary

Attributes included from Core::State

#adapter, #data, #session, #user

Instance Method Summary collapse

Methods included from Core::State

#end_conversation, #initialize, #next_state_action, #next_state_id, #repeat_action, #respond, #send_message, #transition_to

Instance Method Details

#askObject



175
176
177
# File 'lib/socrates/sample_states.rb', line 175

def ask
  respond message: "I will send whatever you type to two other users as direct messages."
end

#listen(message) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
# File 'lib/socrates/sample_states.rb', line 179

def listen(message)
  users = @adapter.users.sample(2)

  users.each do |user|
    send_message(to: user, message: "Message: #{message}")
  end

  respond message: "Direct messages sent!"

  end_conversation
end