Class: TwitterTopicBot::TweetFilterer

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_topic_bot/tweet_filterer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TweetFilterer

Returns a new instance of TweetFilterer.



3
4
5
6
# File 'lib/twitter_topic_bot/tweet_filterer.rb', line 3

def initialize(options = {})
  @max_num_mentions = options.fetch(:max_num_mentions, 1)
  @max_num_hashtags = options.fetch(:max_num_hashtags, 3)
end

Instance Method Details

#acceptable_tweet?(tweet_str, allow_links: true) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/twitter_topic_bot/tweet_filterer.rb', line 8

def acceptable_tweet?(tweet_str, allow_links: true)
  return false if is_spammy_tweet?(tweet_str) ||
                  is_sketchy_tweet?(tweet_str) ||
                  has_too_many_mentions?(tweet_str) ||
                  has_too_many_hashtags?(tweet_str)

  allow_links || !contains_link?(tweet_str)
end