From 596f41f15f1acc4951162ccaacde27d6ce8db911 Mon Sep 17 00:00:00 2001 From: Jaiden Mispy <^_^@mispy.me> Date: Sat, 20 Dec 2014 07:24:40 +1100 Subject: [PATCH] Keep people in convo as long as they replied once --- lib/twitter_ebooks/bot.rb | 4 ++-- spec/bot_spec.rb | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/twitter_ebooks/bot.rb b/lib/twitter_ebooks/bot.rb index ed03229..f76c1d8 100644 --- a/lib/twitter_ebooks/bot.rb +++ b/lib/twitter_ebooks/bot.rb @@ -40,8 +40,8 @@ module Ebooks # Figure out whether to keep this user in the reply prefix # We want to avoid spamming non-participating users def can_include?(username) - @tweets.length <= 6 || - !@tweets[-6..-1].select { |t| t.user.screen_name.downcase == username.downcase }.empty? + @tweets.length <= 4 || + !@tweets.select { |t| t.user.screen_name.downcase == username.downcase }.empty? end end diff --git a/spec/bot_spec.rb b/spec/bot_spec.rb index 6468524..ba07a4d 100644 --- a/spec/bot_spec.rb +++ b/spec/bot_spec.rb @@ -134,11 +134,7 @@ describe Ebooks::Bot do Timecop.travel(Time.now + 60) bot.receive_event(mock_tweet("spammer", "@test_ebooks @m1sp 3")) - expect_tweet(bot, "@spammer @m1sp echo: 3") - - Timecop.travel(Time.now + 60) - bot.receive_event(mock_tweet("spammer", "@test_ebooks @m1sp 4")) - expect_tweet(bot, "@spammer echo: 4") + expect_tweet(bot, "@spammer echo: 3") end end