Skip to content

Instantly share code, notes, and snippets.

@qmacro
Created February 23, 2012 22:47
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 qmacro/1895525 to your computer and use it in GitHub Desktop.
Save qmacro/1895525 to your computer and use it in GitHub Desktop.
Hubot script: Basecamp Todos
# Basecamp todos
# Reports a count of the person's outstanding todo items per todo list.
# Uses bcapi.coffee (coming soon!)
# (Don't forget to set the HUBOT_BASECAMP_KEY and HUBOT_BASECAMP_URL)
bcapi = require '../src/bcapi'
module.exports = (robot) ->
robot.hear /my todo(s| item)?/i, (msg) ->
basecamp_users msg, (people) ->
msg_from = msg.message.user.email_address.toLowerCase()
basecamp_id = people[msg_from]
if basecamp_id?
msg.send "Your outstanding todo items, by todo list:"
bcapi.get "todo_lists.xml?responsible_party=#{basecamp_id}", (data) ->
for list in data['todo-list']
msg.send "#{list.name}: #{list['todo-items']['todo-item'].length or 1}"
# Return hash of Basecamp users as email:id pairs
basecamp_users = (msg, handler) ->
bcapi.get 'people.xml', (data) ->
users = {}
users[person['email-address'].toLowerCase()] = person['id']['#'] for person in data.person
handler users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment