lib/socrates/core/state.rb in socrates-0.1.10 vs lib/socrates/core/state.rb in socrates-0.1.11
- old
+ new
@@ -9,14 +9,14 @@
module Socrates
module Core
module State
attr_reader :data, :context
- def initialize(data: StateData.new, adapter:, context: nil)
+ def initialize(data: StateData.new, adapter:, channel:)
@data = data
@adapter = adapter
- @context = context
+ @channel = channel
@next_state_id = nil
@next_state_action = nil
@logger = Socrates.config.logger || Socrates::Logger.default
end
@@ -44,19 +44,19 @@
message = ERB.new(source, 0, "<>").result(binding)
end
return if message.empty?
- @logger.info %(#{client_id} send: "#{format_for_logging(message)}")
- @adapter.send_message(message, context: @context)
+ @logger.info %Q(#{@channel} send: "#{format_for_logging(message)}")
+ @adapter.send_message(message, @channel)
end
def send_message(to:, message:)
displayable_to = to.respond_to?(:id) ? to.id : to
- @logger.info %(#{client_id} send direct to #{displayable_to}: "#{format_for_logging(message)}")
- @adapter.send_direct_message(message, to, context: @context)
+ @logger.info %Q(#{@channel} send direct to #{displayable_to}: "#{format_for_logging(message)}")
+ @adapter.send_direct_message(message, to)
end
def transition_to(state_id, action: nil, data: {})
if action.nil?
action =
@@ -98,13 +98,9 @@
END_OF_CONVERSATION = :__end__
def next_action(current_action)
(%i[ask listen] - [current_action]).first
- end
-
- def client_id
- @adapter.client_id_from_context(@context)
end
def format_for_logging(message)
message.gsub("\n", "\\n")
end