class Ebooks::Conversation
Represents a single reply tree of tweets
Attributes
last_update[R]
Public Class Methods
new(bot)
click to toggle source
@param bot [Ebooks::Bot]
# File lib/bot_twitter_ebooks/bot.rb, line 22 def initialize(bot) @bot = bot @tweets = [] @last_update = Time.now end
Public Instance Methods
add(tweet)
click to toggle source
@param tweet [Twitter::Tweet] tweet to add
# File lib/bot_twitter_ebooks/bot.rb, line 29 def add(tweet) @tweets << tweet @last_update = Time.now end
can_include?(username)
click to toggle source
Figure out whether to keep this user in the reply prefix We want to avoid spamming non-participating users
# File lib/bot_twitter_ebooks/bot.rb, line 48 def can_include?(username) @tweets.length <= 4 || !@tweets.select { |t| t.user.screen_name.downcase == username.downcase }.empty? end
is_bot?(username)
click to toggle source
Make an informed guess as to whether a user is a bot based on their behavior in this conversation
# File lib/bot_twitter_ebooks/bot.rb, line 36 def is_bot?(username) usertweets = @tweets.select { |t| t.user.screen_name.downcase == username.downcase } if usertweets.length > 2 if username.include?('ebooks') || (usertweets[-1].created_at - usertweets[-3].created_at) < 12 return true end end end