Sha256: 7d7fcaf6b71c2c7e33288efc6756476b734c821a6d80af1e39c8b279b12b594e

Contents?: true

Size: 636 Bytes

Versions: 5

Compression:

Stored size: 636 Bytes

Contents

require 'retrobot/tweet_filters/base'

class Retrobot
  module TweetFilters
    class SuppressPattern < Base
      def initialize(retrobot)
        super
      end

      def filter(tweet)
        text = text tweet
        if pattern && text =~ pattern
          logger.info "Skipped by suppress_pattern: #{tweet.text}"
          nil
        else
          tweet
        end
      end

      private
      def pattern
        config.suppress_pattern ? Regexp.new(config.suppress_pattern) : nil
      end

      def text(tweet)
        tweet.retweeted_status_id ? tweet.text.sub(/^RT @.+: /, '') : tweet.text
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
retrobot-0.3.5 lib/retrobot/tweet_filters/suppress_pattern.rb
retrobot-0.3.4 lib/retrobot/tweet_filters/suppress_pattern.rb
retrobot-0.3.3 lib/retrobot/tweet_filters/suppress_pattern.rb
retrobot-0.3.2 lib/retrobot/tweet_filters/suppress_pattern.rb
retrobot-0.3.1 lib/retrobot/tweet_filters/suppress_pattern.rb