Sha256: 25185f2716a1320f4dadc264b331fd528d40a423a5fb505a987d77ebe2793416

Contents?: true

Size: 921 Bytes

Versions: 2

Compression:

Stored size: 921 Bytes

Contents

module StreamBot
  class Filter
    USER="USER"
    CONTENT="CONTENT"
    LANGUAGE="LANGUAGE"
    TIMEZOME="TIMEZONE"

    def initialize(filters=nil, blacklist=nil)
      @filters = filters
      if (!@blacklist.nil?)
        warn "blacklisting is deprecated and will be removed in 0.6.0"
      end
      @blacklist = blacklist
    end

    def match?(status)
      username = status.user.screen_name
      if (@blacklist.nil? || !@blacklist.include?(username)) && !@filters.nil?
        @filters.each do |key, value|
          @type = filter["type"]
          @value = filter["value"]
          if @type == USER then
            status.user.screen_name.eql?(@value)
          elsif @type == CONTENT then
            status.text.include?(@value)
          elsif @type == LANGUAGE then
            status.user.lang.eql?(@value)
          elsif @type == TIMEZONE then

          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
streambot-0.5.0.beta5 lib/streambot/filter.rb
streambot-0.5.0.beta4 lib/streambot/filter.rb