Created
February 23, 2012 22:47
-
-
Save qmacro/1895525 to your computer and use it in GitHub Desktop.
Hubot script: Basecamp Todos
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
# 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