Skip to content

Commit

Permalink
don't reply with empty cc after multiple mentions
Browse files Browse the repository at this point in the history
Fixes #6
  • Loading branch information
bhouse committed Mar 13, 2015
1 parent d04e1b0 commit c03c1c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/lita/handlers/group_mention.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ class GroupMention < Handler
def group_mention(response) # rubocop:disable AbcSize
return if response.message.body =~ /group\s+mention/
groups = response.matches.flatten

groups.each do |g|
groups.delete(g) unless redis_groups.keys.include?(g)
end
groups.reject! { |g| !redis_groups.keys.include?(g) }
return if groups.empty?

response.reply(t('mention.cc') + union_members(groups))
Expand Down
7 changes: 7 additions & 0 deletions spec/lita/handlers/group_mention_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,11 @@
)
end
end

context 'sending a message with multiple mentions of non-groups' do
it "doesn't respond with a cc" do
send_message('Hello @user1 @user2')
expect(replies.last).not_to match(/^cc/)
end
end
end

0 comments on commit c03c1c9

Please sign in to comment.