Skip to content

Instantly share code, notes, and snippets.

@nhnmomonga
Created May 20, 2015 22:36
Show Gist options
  • Save nhnmomonga/ac86581a29d9034f5e6b to your computer and use it in GitHub Desktop.
Save nhnmomonga/ac86581a29d9034f5e6b to your computer and use it in GitHub Desktop.
ERROR_MESSAGE = process.env.HUBOT_ZATSUDAN_ERROR_MESSAGE or 'エラーです'
zatsudan = (msg, zatsudan) ->
request = require('request')
request.post({url : "https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY=XXXXXX",
form : {"utt" : "#{zatsudan}", "place" : "東京", "mode" : "dialog"}}, (err, httpResponse, body) ->
if error or httpResponse.statusCode != 200
return msg.send("雑談に失敗しました")
data = JSON.parse(body)[0]
msg.send "#{data.utt}")
module.exports = (robot) ->
robot.respond /[To:1157553]( +(.*))?/i, (msg) ->
text = msg.match[1]
zatsudan msg, text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment