diff --git a/README.md b/README.md index caaf9af..818fd10 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ gem "lita-retro" Throughout the week, team members may think of things they'd like to discuss at the next team retro. They can store their topic ideas with Lita and Lita will list all the topics when it comes time to meet and discuss them. Topics can be classified as good, bad, or neutral, signified by a happy face, a sad face, or a straight face, respectively. +Now it's possible each team to have the lita retro at your channel/room + ``` Carl: Lita retro :) Our new documentation was super useful! Lita: Good topic added! diff --git a/lib/lita/handlers/retro.rb b/lib/lita/handlers/retro.rb index 60e4eaa..b9e34c7 100644 --- a/lib/lita/handlers/retro.rb +++ b/lib/lita/handlers/retro.rb @@ -35,13 +35,15 @@ def add_neutral(response) def list(response) topics = [ - list_type("good"), - list_type("bad"), - list_type("neutral") + list_type("good",response.room.id), + list_type("bad",response.room.id), + list_type("neutral",response.room.id) ].compact if topics.empty? response.reply(t("no_topics")) + elsif topics.inspect == "[" + '"' + '"' + "]" + response.reply(t("no_topics")) else response.reply(topics.join("\n")) end @@ -49,7 +51,7 @@ def list(response) def clear(response) %w(good bad neutral).map do |type| - redis.smembers(type).each { |id| redis.del("#{type}:#{id}") } + redis.smembers("#{type}:#{response.room.id}").each { |id| redis.del("#{type}:#{response.room.id}:#{id}") } redis.del(type) end @@ -59,13 +61,14 @@ def clear(response) private def add_type(type, response) - redis.sadd("#{type}:#{response.user.id}", response.matches[0][0]) - redis.sadd("#{type}", response.user.id) + redis.sadd("#{type}:#{response.room.id}:#{response.user.id}", response.matches[0][0]) + redis.sadd("#{type}:#{response.room.id}", response.user.id) + redis.sadd("#{type}", response.room.id) response.reply(t("added", type: type)) end - def list_type(type) - user_ids = redis.smembers(type) + def list_type(type,room) + user_ids = redis.smembers("#{type}:#{room}") return if user_ids.empty? topics = [] @@ -74,7 +77,7 @@ def list_type(type) user = User.find_by_id(user_id) next unless user - redis.smembers("#{type}:#{user.id}").each do |topic| + redis.smembers("#{type}:#{room}:#{user.id}").each do |topic| topics << t("topic", type: type.capitalize, name: user.name, topic: topic) end end