Skip to content

Commit

Permalink
add list projects feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dougmcbride committed Nov 5, 2009
1 parent fdd5a92 commit 53e40cf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion trakbot.rb
Expand Up @@ -65,6 +65,7 @@ class Trakbot < Chatbot
trak help: this
trak token <token>: Teach trakbot your nick's Pivotal Tracker API token
trak new project <id>: Add a project to trakbot via its id
trak projects: List known projects
EOT

def initialize(options)
Expand All @@ -90,8 +91,13 @@ def initialize(options)
/^(?:trak\s+new\s+project)\s*(\S+)$/ => lambda {|e,m|
ensure_user e.from
@state[:users][e.from][:projects][m[1]] ||= {}
t = ensure_tracker e.from, m[1]
save_state
reply e, "Got it, #{e.from}."
reply e, "New project: #{t.project[:name]}"
},

/^(?:trak\s+projects)/ => lambda {|e,m|
@state[:users][e.from][:projects].keys.each {|p| reply e, "#{p}: " + ensure_tracker(e.from, p).project[:name]}
},

/^(trak.*help|\.\?)$/ => lambda {|e,m| HELP.each_line{|l| reply e, l}}
Expand Down

0 comments on commit 53e40cf

Please sign in to comment.