Sha256: a04f4088b8394dc052bbc3bf4e49889fa0a52d37bb979f92c9b177fdb6197625

Contents?: true

Size: 641 Bytes

Versions: 7

Compression:

Stored size: 641 Bytes

Contents

module Chatterbot

  #
  # methods for only tweeting to users on a specific list
  module Safelist
    attr_accessor :safelist

    alias :whitelist :safelist
    
    # A list of Twitter users that we can communicate with
    def safelist
      @safelist || []
    end

    def safelist=(b)
      @safelist = b.flatten.collect { |e|
        from_user(e).downcase
      }
      @safelist
    end

    def has_safelist?
      !safelist.empty?
    end

    #
    # Is this tweet from a user on our safelist?
    def on_safelist?(s)
      search = from_user(s).downcase
      safelist.any? { |b| search.include?(b.downcase) }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chatterbot-2.2.0 lib/chatterbot/safelist.rb
chatterbot-2.1.0 lib/chatterbot/safelist.rb
chatterbot-2.0.5 lib/chatterbot/safelist.rb
chatterbot-2.0.4 lib/chatterbot/safelist.rb
chatterbot-2.0.3 lib/chatterbot/safelist.rb
chatterbot-2.0.2 lib/chatterbot/safelist.rb
chatterbot-2.0.0.pre lib/chatterbot/safelist.rb