Created
May 18, 2015 16:28
-
-
Save bugcloud/6f788316658a63328f63 to your computer and use it in GitHub Desktop.
Checklist as a Service client on hubot. https://chcklst.herokuapp.com/
This file contains 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: | |
# Generate a simple checklist. | |
# | |
# Commands: | |
# hubot checklist <title> <item1,item2,...> - リストタイトルとアイテムを指定してチェックリストを生成 | |
# | |
chcklst = 'https://chcklst.herokuapp.com' | |
module.exports = (robot) -> | |
robot.respond /(checklist|chcklst|チェックリスト) (.*) (.*)/i, (msg) -> | |
title = msg.match[2] | |
items = msg.match[3].split(',').map (item) -> | |
item.trim() | |
data = JSON.stringify({ | |
title: title | |
items: items.join(',') | |
}) | |
robot.http("#{chcklst}/api/lists.json") | |
.headers('Accept': 'application/json', 'Content-Type': 'application/json') | |
.post(data) (err, res, body) -> | |
unless res.statusCode is 200 | |
msg.send "A list have not generated :(" | |
return | |
else | |
result = JSON.parse(body) | |
msg.send "Got back #{result.list.url}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment