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'!
This commit is contained in:
Stawberri 2014-12-06 01:38:38 -08:00
parent fe34c94e04
commit c4ba9e139f

View file

@ -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]