Created
May 20, 2015 22:36
-
-
Save nhnmomonga/ac86581a29d9034f5e6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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