class BitlbeeConfig::Accounts::Facebook

Constants

USERNAME_SUFFIX

Attributes

auth_strategy[RW]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method BitlbeeConfig::Accounts::Jabber::new
# File lib/bitlbee_config/accounts/facebook.rb, line 8
def initialize(options = {})
  # username needs to be downcased when not using OAuth. Just always downcase it, always works
  options[:handle] &&= options[:handle].downcase

  # unless otherwise specified, use oauth authentication
  @auth_strategy = options.delete(:auth_strategy) || :oauth

  options = add_auth_strategy_options(options)

  super({ tag: "fb",
          nick_format: "%full_name"
        }.merge(options))

  ensure_handle_is_suffixed if @handle
end

Public Instance Methods

add_auth_strategy_options(init_options) click to toggle source

Depending on the authentication strategy, we set a few things

@param [Hash] init_options The options passed to initialize @return [Hash] The original options, which may be modified now

# File lib/bitlbee_config/accounts/facebook.rb, line 33
def add_auth_strategy_options(init_options)
  case @auth_strategy
  when :oauth
    init_options[:oauth] = "on"
    init_options[:cleartext_password] ||= ""
  end

  init_options
end
ensure_handle_is_suffixed() click to toggle source

We don’t want the user to have to enter “@chat.facebook.com” with their handle, so we do it for them

# File lib/bitlbee_config/accounts/facebook.rb, line 25
def ensure_handle_is_suffixed
  @handle += USERNAME_SUFFIX unless @handle =~ /#{ USERNAME_SUFFIX }$/
end