class Tinderbot::Cli::Application

Constants

FACEBOOK_CREDENTIALS_FILE

Public Instance Methods

autolike() click to toggle source
# File lib/tinderbot/cli/application.rb, line 73
def autolike
  tinder_client = sign_in

  puts 'Starting likes...'
  tinder_bot = Tinderbot::Bot.new tinder_client
  tinder_bot.like_recommended_users
end
dislike(user_id) click to toggle source
# File lib/tinderbot/cli/application.rb, line 45
def dislike(user_id)
  tinder_client = sign_in
  tinder_client.dislike user_id
end
like(user_id) click to toggle source
# File lib/tinderbot/cli/application.rb, line 38
def like(user_id)
  tinder_client = sign_in
  tinder_client.like user_id
end
location(location) click to toggle source
# File lib/tinderbot/cli/application.rb, line 66
def location(location)
  tinder_client = sign_in
  tinder_client.update_location(location)
end
profile() click to toggle source
# File lib/tinderbot/cli/application.rb, line 10
def profile
  tinder_client = sign_in
  puts tinder_client.profile.to_yaml
end
remove(user_id) click to toggle source
# File lib/tinderbot/cli/application.rb, line 52
def remove(user_id)
  tinder_client = sign_in
  tinder_client.remove user_id
end
send(user_id, message) click to toggle source
# File lib/tinderbot/cli/application.rb, line 59
def send(user_id, message)
  tinder_client = sign_in
  puts tinder_client.send_message user_id, message
end
updates() click to toggle source
# File lib/tinderbot/cli/application.rb, line 24
def updates
  tinder_client = sign_in
  puts tinder_client.updates.to_yaml
end
user(user_id) click to toggle source
# File lib/tinderbot/cli/application.rb, line 17
def user(user_id)
  tinder_client = sign_in
  puts tinder_client.user(user_id).to_yaml
end

Private Instance Methods

get_facebook_credentials() click to toggle source
# File lib/tinderbot/cli/application.rb, line 103
def get_facebook_credentials
  if ENV['FACEBOOK_EMAIL']
    facebook_email = ENV['FACEBOOK_EMAIL']
  else
    puts 'Enter your facebook credentials.'
    facebook_email = ask('Email:')
  end

  if ENV['FACEBOOK_PASSWORD']
    facebook_password = ENV['FACEBOOK_PASSWORD']
  else
    facebook_password = ask('Password (typing will be hidden):', echo: false)
  end

  puts "\n"
  puts 'Getting your facebook authentication token...'
  facebook_authentication_token, facebook_user_id = Tinderbot::Facebook.get_credentials(facebook_email, facebook_password)
  return facebook_authentication_token, facebook_user_id
end
get_last_facebook_credentials(store) click to toggle source
# File lib/tinderbot/cli/application.rb, line 123
def get_last_facebook_credentials(store)
  facebook_authentication_token = store.transaction { store[:facebook_authentication_token] }
  facebook_user_id = store.transaction { store[:facebook_user_id] }
  return facebook_authentication_token, facebook_user_id
end
get_tinder_authentication_token(store, tinder_client, facebook_authentication_token, facebook_user_id) click to toggle source
# File lib/tinderbot/cli/application.rb, line 93
def get_tinder_authentication_token(store, tinder_client, facebook_authentication_token, facebook_user_id)
  tinder_authentication_token = tinder_client.get_authentication_token(facebook_authentication_token, facebook_user_id)
  unless tinder_authentication_token
    facebook_authentication_token, facebook_user_id = get_facebook_credentials
    store_facebook_credentials(store, facebook_authentication_token, facebook_user_id)
    tinder_authentication_token = tinder_client.get_authentication_token(facebook_authentication_token, facebook_user_id)
  end
  tinder_authentication_token
end
sign_in() click to toggle source
# File lib/tinderbot/cli/application.rb, line 83
def sign_in
  puts 'Connecting to tinder...'
  tinder_client = Tinderbot::Client.new logs_enabled: true
  store = PStore.new(FACEBOOK_CREDENTIALS_FILE)
  facebook_authentication_token, facebook_user_id = get_last_facebook_credentials(store)
  tinder_authentication_token = get_tinder_authentication_token(store, tinder_client, facebook_authentication_token, facebook_user_id)
  tinder_client.sign_in tinder_authentication_token
  tinder_client
end
store_facebook_credentials(store, facebook_authentication_token, facebook_user_id) click to toggle source
# File lib/tinderbot/cli/application.rb, line 129
def store_facebook_credentials(store, facebook_authentication_token, facebook_user_id)
  store.transaction do
    store[:facebook_authentication_token] = facebook_authentication_token
    store[:facebook_user_id] = facebook_user_id
  end
end