Skip to content

Instantly share code, notes, and snippets.

@bugcloud
Created May 18, 2015 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugcloud/6f788316658a63328f63 to your computer and use it in GitHub Desktop.
Save bugcloud/6f788316658a63328f63 to your computer and use it in GitHub Desktop.
Checklist as a Service client on hubot. https://chcklst.herokuapp.com/
# 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