instabot 0.1.40 → 0.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/instabot.rb +10 -10
- data/lib/instabot/actions.rb +50 -45
- data/lib/instabot/banner.rb +10 -12
- data/lib/instabot/config.rb +29 -28
- data/lib/instabot/core.rb +66 -116
- data/lib/instabot/create_protocol.rb +39 -47
- data/lib/instabot/grabber.rb +81 -137
- data/lib/instabot/logger.rb +57 -57
- data/lib/instabot/login.rb +56 -73
- data/lib/instabot/modes.rb +208 -252
- data/lib/instabot/version.rb +5 -5
- metadata +31 -17
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c3419018fec180edea94e624c0522ed13d6e78ca
         | 
| 4 | 
            +
              data.tar.gz: 76ce7c414cae58d3dd256bd6f36e54128f01baac
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0aded35f0e651a7dea6d3e5978b9fcb3989333e6575a9dbd6fe687b0c7a0fbc68af57c0e00bd2c0c627e67658e86a2ebdea972ce4cd66d623546b2b649ab0240
         | 
| 7 | 
            +
              data.tar.gz: a884f333a577c19cd6d166650d08be3c7433083cbd44f86eb5bfcd47b4281dc09da2fb8432f0588655496cf29b0712572e27783ebd0ed79aa58cff1668179ee4
         | 
    
        data/lib/instabot.rb
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 | 
            -
            require  | 
| 2 | 
            -
            require  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 5 | 
            -
            require  | 
| 6 | 
            -
            require  | 
| 7 | 
            -
            require  | 
| 8 | 
            -
            require  | 
| 9 | 
            -
            require  | 
| 10 | 
            -
            require  | 
| 1 | 
            +
            require 'instabot/create_protocol'
         | 
| 2 | 
            +
            require 'instabot/version'
         | 
| 3 | 
            +
            require 'instabot/actions'
         | 
| 4 | 
            +
            require 'instabot/grabber'
         | 
| 5 | 
            +
            require 'instabot/banner'
         | 
| 6 | 
            +
            require 'instabot/logger'
         | 
| 7 | 
            +
            require 'instabot/config'
         | 
| 8 | 
            +
            require 'instabot/login'
         | 
| 9 | 
            +
            require 'instabot/modes'
         | 
| 10 | 
            +
            require 'instabot/core'
         | 
    
        data/lib/instabot/actions.rb
    CHANGED
    
    | @@ -1,51 +1,56 @@ | |
| 1 1 | 
             
            module Actions
         | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
            		return({user_id: user_id, response_code: response.code})
         | 
| 13 | 
            -
            	end
         | 
| 2 | 
            +
              def follow(user_id)
         | 
| 3 | 
            +
                log("trying to follow a user [#{user_id}]", 'ACTIONS')
         | 
| 4 | 
            +
                check_login_status
         | 
| 5 | 
            +
                url = "https://www.instagram.com/web/friendships/#{user_id}/follow/"
         | 
| 6 | 
            +
                set_mechanic_data
         | 
| 7 | 
            +
                response = @agent.post(url, @params, @headers)
         | 
| 8 | 
            +
                save_action_data user_id, :follow
         | 
| 9 | 
            +
                @local_stroage[:followed_users] << user_id
         | 
| 10 | 
            +
                { user_id: user_id, response_code: response.code }
         | 
| 11 | 
            +
              end
         | 
| 14 12 |  | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
            	end
         | 
| 13 | 
            +
              def unfollow(user_id)
         | 
| 14 | 
            +
                log("trying to unfollow a user [#{user_id}]", 'ACTIONS')
         | 
| 15 | 
            +
                check_login_status
         | 
| 16 | 
            +
                url = "https://www.instagram.com/web/friendships/#{user_id}/unfollow/"
         | 
| 17 | 
            +
                set_mechanic_data
         | 
| 18 | 
            +
                response = @agent.post(url, @params, @headers)
         | 
| 19 | 
            +
                save_action_data user_id, :unfollow
         | 
| 20 | 
            +
                @local_stroage[:unfollowed_users] << user_id
         | 
| 21 | 
            +
                { user_id: user_id, response_code: response.code }
         | 
| 22 | 
            +
              end
         | 
| 26 23 |  | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
            	end
         | 
| 24 | 
            +
              def like(media_id)
         | 
| 25 | 
            +
                log("trying to like a media[#{media_id}]", 'ACTIONS')
         | 
| 26 | 
            +
                check_login_status
         | 
| 27 | 
            +
                url = "https://www.instagram.com/web/likes/#{media_id}/like/"
         | 
| 28 | 
            +
                set_mechanic_data
         | 
| 29 | 
            +
                response = @agent.post(url, @params, @headers)
         | 
| 30 | 
            +
                save_action_data media_id, :like
         | 
| 31 | 
            +
                @local_stroage[:liked_medias] << media_id
         | 
| 32 | 
            +
                { media_id: media_id, response_code: response.code }
         | 
| 33 | 
            +
              end
         | 
| 38 34 |  | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
            	end
         | 
| 35 | 
            +
              def unlike(media_id)
         | 
| 36 | 
            +
                log("trying to unlike a media[#{media_id}]", 'ACTIONS')
         | 
| 37 | 
            +
                check_login_status
         | 
| 38 | 
            +
                url = "https://www.instagram.com/web/likes/#{media_id}/unlike/"
         | 
| 39 | 
            +
                set_mechanic_data
         | 
| 40 | 
            +
                response = @agent.post(url, @params, @headers)
         | 
| 41 | 
            +
                save_action_data media_id, :unlike
         | 
| 42 | 
            +
                @local_stroage[:unliked_medias] << media_id
         | 
| 43 | 
            +
                { media_id: media_id, response_code: response.code }
         | 
| 44 | 
            +
              end
         | 
| 50 45 |  | 
| 46 | 
            +
              def comment(media_id, text = '')
         | 
| 47 | 
            +
                log("trying to send a comment to media[#{media_id}]", 'ACTIONS')
         | 
| 48 | 
            +
                check_login_status
         | 
| 49 | 
            +
                url = "https://www.instagram.com/web/comments/#{media_id}/add/"
         | 
| 50 | 
            +
                set_mechanic_data(comment_text: text.to_s)
         | 
| 51 | 
            +
                response = @agent.post(url, @params, @headers)
         | 
| 52 | 
            +
                save_action_data media_id, :comment
         | 
| 53 | 
            +
                @local_stroage[:commented_medias] << media_id
         | 
| 54 | 
            +
                { media_id: media_id, response_code: response.code }
         | 
| 55 | 
            +
              end
         | 
| 51 56 | 
             
            end
         | 
    
        data/lib/instabot/banner.rb
    CHANGED
    
    | @@ -1,18 +1,16 @@ | |
| 1 1 | 
             
            module Banner
         | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
                	puts <<-BANNER
         | 
| 2 | 
            +
              def print_banner
         | 
| 3 | 
            +
                if options[:print_banner]
         | 
| 4 | 
            +
                  puts <<-BANNER
         | 
| 6 5 | 
             
             ██╗███╗   ██╗███████╗████████╗ █████╗ ██████╗  ██████╗ ████████╗
         | 
| 7 6 | 
             
             ██║████╗  ██║██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██╔═══██╗╚══██╔══╝
         | 
| 8 | 
            -
             ██║██╔██╗ ██║███████╗   ██║   ███████║██████╔╝██║   ██║   ██║ | 
| 9 | 
            -
             ██║██║╚██╗██║╚════██║   ██║   ██╔══██║██╔══██╗██║   ██║   ██║ | 
| 10 | 
            -
             ██║██║ ╚████║███████║   ██║   ██║  ██║██████╔╝╚██████╔╝   ██║ | 
| 11 | 
            -
             ╚═╝╚═╝  ╚═══╝╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═════╝  ╚═════╝    ╚═╝ | 
| 7 | 
            +
             ██║██╔██╗ ██║███████╗   ██║   ███████║██████╔╝██║   ██║   ██║
         | 
| 8 | 
            +
             ██║██║╚██╗██║╚════██║   ██║   ██╔══██║██╔══██╗██║   ██║   ██║
         | 
| 9 | 
            +
             ██║██║ ╚████║███████║   ██║   ██║  ██║██████╔╝╚██████╔╝   ██║
         | 
| 10 | 
            +
             ╚═╝╚═╝  ╚═══╝╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═════╝  ╚═════╝    ╚═╝
         | 
| 12 11 |  | 
| 13 12 | 
             
                	BANNER
         | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 13 | 
            +
                  puts 'An instagram bot works without instagram api '.white.bold + 'github.com/'.cyan + 'eVanilla'.cyan.bold.italic
         | 
| 14 | 
            +
                end
         | 
| 16 15 | 
             
              end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            end
         | 
| 16 | 
            +
            end
         | 
    
        data/lib/instabot/config.rb
    CHANGED
    
    | @@ -10,33 +10,34 @@ module Config | |
| 10 10 | 
             
            	end
         | 
| 11 11 |  | 
| 12 12 | 
             
            	class Configuration
         | 
| 13 | 
            -
            		attr_accessor | 
| 13 | 
            +
            		attr_accessor 	:username, :password, :tags, :use_proxy, :proxy, :comments,
         | 
| 14 | 
            +
            							:print_banner, :pre_load, :wait_per_action, :infinite_tags,
         | 
| 15 | 
            +
            							:max_like_per_day, :max_follow_per_day, :max_unfollow_per_day,
         | 
| 16 | 
            +
            							:max_comment_per_day, :unwanted_list, :white_list_users
         | 
| 14 17 | 
             
            		def initialize
         | 
| 15 | 
            -
            			@ | 
| 16 | 
            -
            			@ | 
| 17 | 
            -
            			@ | 
| 18 | 
            -
            			@ | 
| 19 | 
            -
            			@ | 
| 20 | 
            -
            			@ | 
| 21 | 
            -
            			@ | 
| 22 | 
            -
            			@ | 
| 23 | 
            -
            			@ | 
| 24 | 
            -
            			@ | 
| 25 | 
            -
            			@ | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
            			 | 
| 33 | 
            -
            			 | 
| 34 | 
            -
            			 | 
| 35 | 
            -
            			 | 
| 36 | 
            -
            			 | 
| 37 | 
            -
             | 
| 38 | 
            -
            			# @print_logs 			= true
         | 
| 39 | 
            -
            		end	
         | 
| 18 | 
            +
            			@infinite_tags        = true
         | 
| 19 | 
            +
            			@max_comment_per_day  = 50
         | 
| 20 | 
            +
            			@max_follow_per_day   = 50
         | 
| 21 | 
            +
            			@max_like_per_day     = 50
         | 
| 22 | 
            +
            			@max_unfollow_per_day = 50
         | 
| 23 | 
            +
            			@password             = nil
         | 
| 24 | 
            +
            			@pre_load             = true
         | 
| 25 | 
            +
            			@print_banner         = true
         | 
| 26 | 
            +
            			@proxy                = []
         | 
| 27 | 
            +
            			@tags                 = %w[test hello hello_world birthday food]
         | 
| 28 | 
            +
            			@unwanted_list        = nil
         | 
| 29 | 
            +
            			@use_proxy            = false
         | 
| 30 | 
            +
            			@username             = nil
         | 
| 31 | 
            +
            			@wait_per_action      = 1 * 60
         | 
| 32 | 
            +
            			@white_list_users     = nil
         | 
| 33 | 
            +
            			@comments             = [
         | 
| 34 | 
            +
            			%w[this the your],
         | 
| 35 | 
            +
            			%w[photo picture pic shot snapshot],
         | 
| 36 | 
            +
            			['is', 'looks', 'feels', 'is really'],
         | 
| 37 | 
            +
            			['great', 'super', 'good', 'very good', 'good', 'wow', 'WOW', 'cool', 'GREAT', 'magnificent', 'magical', 'very cool', 'stylish', 'beautiful', 'so beautiful', 'so stylish', 'so professional', 'lovely', 'so lovely', 'very lovely', 'glorious', 'so glorious', 'very glorious', 'adorable', 'excellent', 'amazing'],
         | 
| 38 | 
            +
            			['.', '..', '...', '!', '!!', '!!!']
         | 
| 39 | 
            +
            			]
         | 
| 40 | 
            +
            		end
         | 
| 40 41 | 
             
            	end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            end
         | 
| 42 | 
            +
            	
         | 
| 43 | 
            +
            end
         | 
    
        data/lib/instabot/core.rb
    CHANGED
    
    | @@ -1,143 +1,93 @@ | |
| 1 | 
            -
            %w[colorize mechanize io/console hashie json logger pp active_support/core_ext/numeric/time rbconfig].each {|gem| require gem} | 
| 1 | 
            +
            %w[colorize mechanize io/console hashie json logger pp active_support/core_ext/numeric/time rbconfig].each { |gem| require gem }
         | 
| 2 2 |  | 
| 3 3 | 
             
            class Instabot
         | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
            	def initialize(mode | 
| 17 | 
            -
            		@login_mode | 
| 18 | 
            -
            		@users | 
| 19 | 
            -
            		@medias | 
| 20 | 
            -
            		@log_counter | 
| 21 | 
            -
            		@login_counter | 
| 22 | 
            -
            		@login_status | 
| 23 | 
            -
            		@lib_dir | 
| 24 | 
            -
            		@root_dir | 
| 25 | 
            -
            		@logs_dir | 
| 26 | 
            -
            		@global_time | 
| 4 | 
            +
            include Version
         | 
| 5 | 
            +
            include Modes
         | 
| 6 | 
            +
            include Actions
         | 
| 7 | 
            +
            include Banner
         | 
| 8 | 
            +
            include Config
         | 
| 9 | 
            +
            include Grabber
         | 
| 10 | 
            +
            include Login
         | 
| 11 | 
            +
            include Log
         | 
| 12 | 
            +
            include Protocol
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            attr_accessor :users, :medias
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            	def initialize(mode = :default)
         | 
| 17 | 
            +
            		@login_mode    = mode
         | 
| 18 | 
            +
            		@users         = []
         | 
| 19 | 
            +
            		@medias        = []
         | 
| 20 | 
            +
            		@log_counter   = 0
         | 
| 21 | 
            +
            		@login_counter = 1
         | 
| 22 | 
            +
            		@login_status  = false
         | 
| 23 | 
            +
            		@lib_dir       = "#{Dir.pwd}/lib"
         | 
| 24 | 
            +
            		@root_dir      = Dir.pwd.to_s
         | 
| 25 | 
            +
            		@logs_dir      = "#@root_dir/logs"
         | 
| 26 | 
            +
            		@global_time   = Time.new.strftime('%H-%M-%S--%y-%m-%d')
         | 
| 27 27 | 
             
            		Configuration.new if @login_mode == :manual
         | 
| 28 | 
            -
            		@local_stroage 			= {
         | 
| 29 | 
            -
            			:followed_users 	=> [],
         | 
| 30 | 
            -
            			:unfollowed_users 	=> [],
         | 
| 31 | 
            -
            			:liked_medias 		=> [],
         | 
| 32 | 
            -
            			:commented_medias 	=> []
         | 
| 33 | 
            -
            		}  
         | 
| 34 28 |  | 
| 35 | 
            -
            		@ | 
| 36 | 
            -
            			: | 
| 37 | 
            -
            			: | 
| 38 | 
            -
            			: | 
| 39 | 
            -
            			: | 
| 40 | 
            -
            			: | 
| 41 | 
            -
            			:max_unfollows_per_day 	=> options[:max_unfollow_per_day],
         | 
| 42 | 
            -
            			:max_likes_per_day		=> options[:max_like_per_day],
         | 
| 43 | 
            -
            			:max_comments_per_day 	=> options[:max_comment_per_day]
         | 
| 29 | 
            +
            		@local_stroage = {
         | 
| 30 | 
            +
            			followed_users:   [],
         | 
| 31 | 
            +
            			unfollowed_users: [],
         | 
| 32 | 
            +
            			liked_medias:     [],
         | 
| 33 | 
            +
            			unliked_medias:   [],
         | 
| 34 | 
            +
            			commented_medias: []
         | 
| 44 35 | 
             
            		}
         | 
| 45 36 |  | 
| 46 | 
            -
            		 | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
            		 | 
| 56 | 
            -
            		# 	when /solaris|bsd/
         | 
| 57 | 
            -
            		# 		:unix
         | 
| 58 | 
            -
            		# 	else
         | 
| 59 | 
            -
            		# 		raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
         | 
| 60 | 
            -
            		# 	end
         | 
| 61 | 
            -
            		# )
         | 
| 62 | 
            -
             | 
| 37 | 
            +
            		@maximums = {
         | 
| 38 | 
            +
            			follows_in_day:        0,
         | 
| 39 | 
            +
            			unfollows_in_day:      0,
         | 
| 40 | 
            +
            			likes_in_day:          0,
         | 
| 41 | 
            +
            			comments_in_day:       0,
         | 
| 42 | 
            +
            			max_follows_per_day:   options[:max_follow_per_day],
         | 
| 43 | 
            +
            			max_unfollows_per_day: options[:max_unfollow_per_day],
         | 
| 44 | 
            +
            			max_likes_per_day:     options[:max_like_per_day],
         | 
| 45 | 
            +
            			max_comments_per_day:  options[:max_comment_per_day]
         | 
| 46 | 
            +
            		}
         | 
| 63 47 |  | 
| 64 48 | 
             
            		intro(mode)
         | 
| 65 | 
            -
            		
         | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 49 | 
             
            	end
         | 
| 69 50 |  | 
| 70 | 
            -
             | 
| 71 51 | 
             
            	def options
         | 
| 72 52 | 
             
            		if @login_mode == :default
         | 
| 73 | 
            -
            			 | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
            				# :pretty_print			=> 		Config.options.pretty_print,
         | 
| 90 | 
            -
            				# :print_logs 			=> 		Config.options.print_logs
         | 
| 53 | 
            +
            			{
         | 
| 54 | 
            +
            			comments:             Config.options.comments,
         | 
| 55 | 
            +
            			max_comment_per_day:  Config.options.max_comment_per_day,
         | 
| 56 | 
            +
            			max_follow_per_day:   Config.options.max_follow_per_day,
         | 
| 57 | 
            +
            			max_like_per_day:     Config.options.max_like_per_day,
         | 
| 58 | 
            +
            			max_unfollow_per_day: Config.options.max_unfollow_per_day,
         | 
| 59 | 
            +
            			password:             Config.options.password,
         | 
| 60 | 
            +
            			pre_load:             Config.options.pre_load,
         | 
| 61 | 
            +
            			print_banner:         Config.options.print_banner,
         | 
| 62 | 
            +
            			proxy:                Config.options.proxy,
         | 
| 63 | 
            +
            			tags:                 Config.options.tags,
         | 
| 64 | 
            +
            			unwanted_list:        Config.options.unwanted_list,
         | 
| 65 | 
            +
            			use_proxy:            Config.options.use_proxy,
         | 
| 66 | 
            +
            			username:             Config.options.username,
         | 
| 67 | 
            +
            			wait_per_action:      Config.options.wait_per_action,
         | 
| 68 | 
            +
            			white_list_users:     Config.options.white_list_users
         | 
| 91 69 | 
             
            			}
         | 
| 92 70 | 
             
            		else
         | 
| 93 | 
            -
            			 | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 71 | 
            +
            			{
         | 
| 72 | 
            +
            			max_comment_per_day:  :infinite,
         | 
| 73 | 
            +
            			max_follow_per_day:   :infinite,
         | 
| 74 | 
            +
            			max_like_per_day:     :infinite,
         | 
| 75 | 
            +
            			max_unfollow_per_day: :infinite
         | 
| 98 76 | 
             
            			}
         | 
| 99 77 | 
             
            		end
         | 
| 100 78 | 
             
            	end
         | 
| 101 79 |  | 
| 102 | 
            -
            	# def custom_puts(text="")
         | 
| 103 | 
            -
            	# 	# pretty_print_mode = options[:pretty_print]
         | 
| 104 | 
            -
            	# 	# if pretty_print_mode
         | 
| 105 | 
            -
            	# 		puts "#{text}"
         | 
| 106 | 
            -
            	# 	# else
         | 
| 107 | 
            -
            	# 		# puts "#{text}".colorize(color: :white, background: :default)
         | 
| 108 | 
            -
            	# 	# end
         | 
| 109 | 
            -
            	# end
         | 
| 110 | 
            -
            	
         | 
| 111 | 
            -
            	# def custom_print(text="")
         | 
| 112 | 
            -
            	# 	# pretty_print_mode = options[:pretty_print]
         | 
| 113 | 
            -
            	# 	# empty_space =  IO.console.winsize[1] - text.size
         | 
| 114 | 
            -
            	# 	# empty_space = 0 if empty_space < 0 
         | 
| 115 | 
            -
            	# 	# if pretty_print_mode
         | 
| 116 | 
            -
            	# 		# print "\r#{text}"
         | 
| 117 | 
            -
            	# 		# $stdout.flush
         | 
| 118 | 
            -
            	# 		# print  " " * empty_space
         | 
| 119 | 
            -
            	# 		# IO.console.flush
         | 
| 120 | 
            -
            	# 	# else
         | 
| 121 | 
            -
            	# 		print "#{text}"
         | 
| 122 | 
            -
            	# 	# end
         | 
| 123 | 
            -
            	# end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 80 | 
             
            	def intro(mode)
         | 
| 128 | 
            -
            		trap( | 
| 81 | 
            +
            		trap('INT') { exit! }
         | 
| 129 82 | 
             
            		print_banner
         | 
| 130 83 | 
             
            		check_log_files
         | 
| 131 | 
            -
            		log( | 
| 132 | 
            -
            		log( | 
| 84 | 
            +
            		log('log files are checked', 'CORE')
         | 
| 85 | 
            +
            		log('Machine started', 'CORE')
         | 
| 133 86 | 
             
            		create_mechanic
         | 
| 134 | 
            -
            		puts  | 
| 135 | 
            -
            		log( | 
| 87 | 
            +
            		puts '[+] '.cyan + 'Processing successfully completed'
         | 
| 88 | 
            +
            		log('Processing successfully completed', 'CORE')
         | 
| 136 89 | 
             
            		unless mode != :default
         | 
| 137 90 | 
             
            			login
         | 
| 138 91 | 
             
            		end
         | 
| 139 | 
            -
             | 
| 140 92 | 
             
            	end
         | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 93 | 
             
            end
         | 
| @@ -1,51 +1,43 @@ | |
| 1 1 | 
             
            module Protocol
         | 
| 2 | 
            +
              def create_mechanic
         | 
| 3 | 
            +
                @agent                  = Mechanize.new
         | 
| 4 | 
            +
                @agent.max_history      = 2
         | 
| 5 | 
            +
                @agent.ca_file          = './cacert.pem' # Because i'm using windows and... you know... ._.
         | 
| 6 | 
            +
                @agent.user_agent_alias = ['Mac Mozilla', 'Mac Safari', 'Windows IE 6', 'Windows IE 7', 'Windows IE 8', 'Windows IE 9', 'Windows Mozilla', 'Windows Chrome'].sample
         | 
| 7 | 
            +
                if options[:use_proxy]
         | 
| 8 | 
            +
                  proxy = options[:proxy]
         | 
| 9 | 
            +
                  if proxy.size == 2
         | 
| 10 | 
            +
                    @agent.set_proxy(proxy[0], proxy[1].to_i)
         | 
| 11 | 
            +
                  else
         | 
| 12 | 
            +
                    @agent.set_proxy(proxy[0], proxy[1].to_i, proxy[2], proxy[3])
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 2 15 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
            		# @agent.log 				= Logger.new(STDOUT)
         | 
| 7 | 
            -
            		@agent.ca_file			= "./cacert.pem" # => FOR WINDOWS USERS
         | 
| 8 | 
            -
            		# @agent.user_agent_alias = Mechanize::AGENT_ALIASES.to_a.sample[0]
         | 
| 9 | 
            -
            		@agent.user_agent_alias = ['Mac Mozilla','Mac Safari','Windows IE 6','Windows IE 7','Windows IE 8','Windows IE 9','Windows Mozilla','Windows Chrome'].sample
         | 
| 10 | 
            -
            		if options[:use_proxy]
         | 
| 11 | 
            -
            			proxy = options[:proxy]
         | 
| 12 | 
            -
            			if proxy.size == 2
         | 
| 13 | 
            -
            				@agent.set_proxy(proxy[0], proxy[1].to_i)
         | 
| 14 | 
            -
            			else 
         | 
| 15 | 
            -
            				@agent.set_proxy(proxy[0], proxy[1].to_i, proxy[2], proxy[3])
         | 
| 16 | 
            -
            			end
         | 
| 17 | 
            -
            		end
         | 
| 16 | 
            +
                puts 'PROCESSING: '.cyan.bold + 'protocol created'
         | 
| 17 | 
            +
                log('Protocol successfully created', 'CREATE_PROTOCOL')
         | 
| 18 | 
            +
              end
         | 
| 18 19 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
            	end
         | 
| 20 | 
            +
              def get_page(url)
         | 
| 21 | 
            +
                @agent.get(url)
         | 
| 22 | 
            +
              end
         | 
| 23 23 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
            				# 'Content-Length' 	=> '0',
         | 
| 45 | 
            -
            				'Host' 				=> 'www.instagram.com',
         | 
| 46 | 
            -
            				'Origin' 			=> 'https://www.instagram.com',
         | 
| 47 | 
            -
            				'Referer' 			=> 'https://www.instagram.com/'
         | 
| 48 | 
            -
            			}
         | 
| 49 | 
            -
            	end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
            end
         | 
| 24 | 
            +
              def set_mechanic_data(params = {})
         | 
| 25 | 
            +
                @cookies 	 = Hash[@agent.cookies.map { |key, _value| [key.name, key.value] }]
         | 
| 26 | 
            +
                @params 	  = params
         | 
| 27 | 
            +
                @headers 	 = {
         | 
| 28 | 
            +
                  'Cookie'           => "mid=#{@cookies['mid']}; csrftoken=#{@cookies['csrftoken']}; sessionid=#{@cookies['sessionid']}; ds_user_id=#{@cookies['ds_user_id']}; rur=#{@cookies['rur']}; s_network=#{@cookies['s_network']}; ig_pr= 1; ig_vw=1920",
         | 
| 29 | 
            +
                  'X-CSRFToken'      => (@cookies['csrftoken']).to_s,
         | 
| 30 | 
            +
                  'X-Requested-With' => 'XMLHttpRequest',
         | 
| 31 | 
            +
                  'Content-Type'     => 'application/x-www-form-urlencoded',
         | 
| 32 | 
            +
                  'X-Instagram-AJAX' => '1',
         | 
| 33 | 
            +
                  'Accept'           => 'application/json, text/javascript, */*',
         | 
| 34 | 
            +
                  'User-Agent'       => 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0',
         | 
| 35 | 
            +
                  'Accept-Encoding'  => 'gzip, deflate',
         | 
| 36 | 
            +
                  'Accept-Language'  => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
         | 
| 37 | 
            +
                  'Connection'       => 'keep-alive',
         | 
| 38 | 
            +
                  'Host'             => 'www.instagram.com',
         | 
| 39 | 
            +
                  'Origin'           => 'https://www.instagram.com',
         | 
| 40 | 
            +
                  'Referer'          => 'https://www.instagram.com/'
         | 
| 41 | 
            +
                }
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         |