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,
                       follows_per_tag:     50,
                       unfollows_per_run:   200,
                       unfollow_threshold:  { seconds: 0,
                                              minutes: 0,
                                              hours:   1,
                                              days:    0
                       }
}.freeze
VERSION =
'0.1.3'

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, #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, #unfollow_threshold_past?

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.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/botinsta.rb', line 32

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]
  @unfollow_threshold   = params[:unfollow_threshold]

  @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



59
60
61
62
63
# File 'lib/botinsta.rb', line 59

def start
  
  tag_based_mode
  logout
end