Class: Botinsta

Inherits:
Object
  • Object
show all
Includes:
ClassMethods
Defined in:
lib/botinsta.rb,
lib/botinsta/version.rb

Overview

This is our main class from which we will be instantiating our bot.

Constant Summary collapse

DEFAULT_PARAMETERS =
{ tags:              %w[photography fotografia vsco],
                       tag_blacklist:     %w[nsfw hot sexy],
                       user_blacklist:    [],
                       likes_per_tag:     10,
                       unfollows_per_run: 200,
                       follows_per_tag:   50
}.freeze
VERSION =
'0.1.2'

Instance Method Summary collapse

Methods included from Requests

#set_cookies, #set_request_headers, #set_request_params

Methods included from Pages

#get_first_page_data, #get_js_link, #get_next_page_data, #get_user_page_data, #set_query_id

Methods included from Modes

#tag_based_mode

Methods included from Login

#login, #logout

Methods included from Helpers

#delete_from_db, #handle_database_creation, #one_day_past?, #print_action_sum, #print_error_message, #print_login_message, #print_success_message, #print_tag_message, #print_time_stamp, #print_try_message, #refresh_db_related, #sleep_rand

Methods included from Actions

#follow_if_not_in_db, #follow_user, #like_if_not_in_db, #like_media, #unfollow_user, #unlike_media

Constructor Details

#initialize(**params) ⇒ Botinsta

Returns a new instance of Botinsta.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/botinsta.rb', line 25

def initialize(**params)

  params = DEFAULT_PARAMETERS.merge(params)

  @username           = params[:username]
  @password           = params[:password]
  @tags               = params[:tags]
  @tag_blacklist      = params[:tag_blacklist]
  @user_blacklist     = params[:user_blacklist]
  @likes_per_tag      = params[:likes_per_tag]
  @follows_per_tag    = params[:follows_per_tag]
  @unfollows_per_run  = params[:unfollows_per_run]

  @total_likes        = 0
  @total_follows      = 0
  @total_unfollows    = 0

  @agent = Mechanize.new

  handle_database_creation
  return if @table_follows.empty?

  @first_db_entry = @table_follows.first
  @last_follow_time = @table_follows.first[:follow_time]
end

Instance Method Details

#startObject



51
52
53
54
55
# File 'lib/botinsta.rb', line 51

def start
  
  tag_based_mode
  logout
end