class Ruboty::Handlers::Talk
Constants
- NAMESPACE
Public Instance Methods
talk(message)
click to toggle source
# File lib/ruboty/handlers/talk.rb, line 18 def talk(message) response = client.create_dialogue(message[:body], params) @context = response.body["context"] message.reply(response.body["utt"]) rescue Exception => e Ruboty.logger.error(%<Error: #{e.class}: #{e.message}\n#{e.backtrace.join("\n")}>) end
Private Instance Methods
character_id()
click to toggle source
# File lib/ruboty/handlers/talk.rb, line 28 def character_id if ENV["DOCOMO_CHARACTER_ID"] ENV["DOCOMO_CHARACTER_ID"].to_i end end
client()
click to toggle source
# File lib/ruboty/handlers/talk.rb, line 34 def client @client ||= Docomoru::Client.new(api_key: ENV["DOCOMO_API_KEY"]) end
params()
click to toggle source
# File lib/ruboty/handlers/talk.rb, line 38 def params { context: @context, t: character_id, }.reject do |key, value| value.nil? end end