Class: Instabot

Inherits:
Object
  • Object
show all
Includes:
Actions, Banner, Config, Grabber, Log, Login, Modes, Protocol, TorProtocol, Version
Defined in:
lib/instabot/core.rb

Overview

main core class

Constant Summary

Constants included from Version

Version::DESCRIPTION, Version::SUMMARY, Version::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Protocol

#create_protocol, #get_page, #set_mechanic_data

Methods included from Log

#check_log_files, #log, #save_action_log, #write_file

Methods included from Login

#check_login_status, #login, #logout

Methods included from Grabber

#handle_media_information_data, #handle_user_information_data_by_user_id, #handle_user_information_data_by_user_name, #search, #set_media_information, #set_user_information

Methods included from Config

setup

Methods included from Banner

#print_banner

Methods included from Actions

#comment, #follow, #like, #unfollow, #unlike

Methods included from Modes

#auto_comment, #auto_follow, #auto_like, #auto_unfollow, #check_date, #comments_in_day_are_full?, #fall_in_asleep, #follows_in_day_are_full?, #generate_a_comment, #is_user_valid?, #likes_in_day_are_full?, #maximums_are_full?, #mode, #unfollows_in_day_are_full?

Constructor Details

#initialize(mode = :default) ⇒ Instabot

Returns a new instance of Instabot.



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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/instabot/core.rb', line 25

def initialize(mode = :default)
    @login_mode                 = mode 
    @users                      = []
    @medias                     = []
    @log_counter                = 0
    @login_counter              = 1
    @login_status               = false
    @lib_dir                    = "#{Dir.pwd}/lib"
    @root_dir                   = Dir.pwd.to_s
    @logs_dir                   = "#@root_dir/logs"
    @started_time               = Time.new.strftime('%H-%M-%S--%y-%m-%d')
    @errors_iteration           = 0
    # auto increments 
    @follows_auto_increment     = 0
    @unfollows_auto_increment   = 0
    @likes_auto_increment       = 0
    @comments_auto_increment    = 0

    Configuration.new if @login_mode == :manual

    @local_stroage = {
        followed_users:   [],
        unfollowed_users: [],
        liked_medias:     [],
        unliked_medias:   [],
        commented_medias: []
    }

    @maximums = {
        follows_in_day:        0,
        unfollows_in_day:      0,
        likes_in_day:          0,
        comments_in_day:       0,
        max_follows_per_day:   options[:max_follow_per_day],
        max_unfollows_per_day: options[:max_unfollow_per_day],
        max_likes_per_day:     options[:max_like_per_day],
        max_comments_per_day:  options[:max_comment_per_day]
    }

    intro(mode)
end

Instance Attribute Details

#media_informationObject

Returns the value of attribute media_information.



23
24
25
# File 'lib/instabot/core.rb', line 23

def media_information
  @media_information
end

#mediasObject

Returns the value of attribute medias.



23
24
25
# File 'lib/instabot/core.rb', line 23

def medias
  @medias
end

#user_informationObject

Returns the value of attribute user_information.



23
24
25
# File 'lib/instabot/core.rb', line 23

def user_information
  @user_information
end

#usersObject

Returns the value of attribute users.



23
24
25
# File 'lib/instabot/core.rb', line 23

def users
  @users
end

Instance Method Details

#intro(mode) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/instabot/core.rb', line 100

def intro(mode)
    trap('INT') { exit! }
    print_banner
    check_log_files
    log('log files are checked', 'CORE')
    log('Machine started', 'CORE')
    create_protocol
    puts '[+] '.cyan + 'Processing successfully completed'
    log('Processing successfully completed', 'CORE')
    unless mode != :default
        
    end
end

#optionsObject

will return Config.options…



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/instabot/core.rb', line 68

def options
    if @login_mode == :default
        {
            comments:             Config.options.comments,
            max_comment_per_day:  Config.options.max_comment_per_day,
            max_follow_per_day:   Config.options.max_follow_per_day,
            max_like_per_day:     Config.options.max_like_per_day,
            max_unfollow_per_day: Config.options.max_unfollow_per_day,
            username:             Config.options.username,
            password:             Config.options.password,
            pre_load:             Config.options.pre_load,
            print_banner:         Config.options.print_banner,
            proxy:                Config.options.proxy,
            tags:                 Config.options.tags,
            use_proxy:            Config.options.use_proxy,
            use_tor:              Config.options.use_tor,
            wait_per_action:      Config.options.wait_per_action,
            log_status:           Config.options.log_status,
            add_tag_per_post:     Config.options.add_tag_per_post,
            unwanted_list:        Config.options.unwanted_list,
            white_list_users:     Config.options.white_list_users,
        }
    else
        {
            max_comment_per_day:  :infinite,
            max_follow_per_day:   :infinite,
            max_like_per_day:     :infinite,
            max_unfollow_per_day: :infinite
        }
    end
end