Module: Chatterbot::Whitelist

Included in:
Bot
Defined in:
lib/chatterbot/whitelist.rb

Overview

methods for only tweeting to users on a specific list

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#whitelistObject

A list of Twitter users that we can communicate with


9
10
11
# File 'lib/chatterbot/whitelist.rb', line 9

def whitelist
  @whitelist
end

Instance Method Details

#has_whitelist?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/chatterbot/whitelist.rb', line 21

def has_whitelist?
  !whitelist.empty?
end

#on_whitelist?(s) ⇒ Boolean

Is this tweet from a user on our whitelist?

Returns:

  • (Boolean)

27
28
29
30
# File 'lib/chatterbot/whitelist.rb', line 27

def on_whitelist?(s)
  search = (s.respond_to?(:user) ? from_user(s) : s).downcase
  whitelist.any? { |b| search.include?(b.downcase) }
end