18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/lita/handlers/motionai.rb', line 18
def anything(response)
heard = response.match_data[1]
Lita.logger.debug("Message Heard: [#{heard}]")
res = client.message_bot msg: heard, session: response.user.id
Lita.logger.debug(MultiJson.encode(res.body))
if res.status == 200 && res.body.key?('botResponse')
response.reply res.body['botResponse']
else
if res.status != 200
Lita.logger.error("MotionAI API status #{res.status}")
elsif !res.body.key? 'botResponse'
Lita.logger.error("MotionAI API `botResponse` not found")
end
end
end
|