Created
March 1, 2013 14:50
-
-
Save fukayatsu/5065136 to your computer and use it in GitHub Desktop.
みつをる(縦書ジェネレータ) for hipchat
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
| # Description: | |
| # みつをる(縦書ジェネレータ) - http://mitsuwo.net/ | |
| # | |
| # Commands: | |
| # hubot mitsuwo [body],[author] | |
| # hubot mitsuwo 寿司が<br>食べたいのです,名無し | |
| request = require('request') # add `"request": "2.14.x"` to package.json | |
| module.exports = (robot) -> | |
| robot.respond /mits?uw?o ([^,]+),(.+)/i, (msg) -> | |
| body = msg.match[1].replace(/<br>/g, "\r\n") | |
| author = msg.match[2] | |
| params = {card: {author: author, body: body}} | |
| request.post { | |
| headers: {'content-type' : 'application/x-www-form-urlencoded'}, | |
| url: 'http://mitsuwo.net/cards', | |
| body: "card[author]=#{author}&card[body]=#{body}" | |
| }, (error, res, body) -> | |
| status = res.statusCode | |
| if status == 302 | |
| url = res.headers.location | |
| request.get { url: "#{url}.json", json: true }, (error, res, card) -> | |
| msg.send url | |
| msg.send card.image | |
| else | |
| msg.send "なんかおかしいっぽい(#{status})" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment