From c4ba9e139f968b1e5a25c70c7338e80ec60c50d4 Mon Sep 17 00:00:00 2001 From: Stawberri Date: Sat, 6 Dec 2014 01:38:38 -0800 Subject: [PATCH] Regex soft-retweet detection I added a regex to detect 'RT @' anywhere in the content of a tweet, in case someone hides a RT in the middle of a tweet! As a bonus, it also detects a bunch of different types of quotes as well as other things people might use, like 'via,' 'by,' and 'from'! --- lib/twitter_ebooks/bot.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/twitter_ebooks/bot.rb b/lib/twitter_ebooks/bot.rb index ad55f0e..efec8bf 100644 --- a/lib/twitter_ebooks/bot.rb +++ b/lib/twitter_ebooks/bot.rb @@ -70,7 +70,7 @@ module Ebooks # - The tweet mentions list contains our username # - The tweet is not being retweeted by somebody else # - Or soft-retweeted by somebody else - @mentions.map(&:downcase).include?(@bot.username.downcase) && !@tweet.retweeted_status? && !@tweet.text.start_with?('RT ') + @mentions.map(&:downcase).include?(@bot.username.downcase) && !@tweet.retweeted_status? && !@tweet.text.start_with?('RT ') && !@tweet.text =~ /([`'‘’"“”]|RT|via|by|from)\s*@/i end # @param bot [Ebooks::Bot]