instabot 0.1.38 → 0.1.40

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f808851229fae36a82e51941365164b50749f143
4
- data.tar.gz: 52b4340f9cf369c776493d0f394a32fd347eda2e
3
+ metadata.gz: cbe88bf15a913c67baae5177edc8e64c0b2ff808
4
+ data.tar.gz: 04129dcc66f800d63900113e90722545a14f6dd9
5
5
  SHA512:
6
- metadata.gz: 1f1d2fba7b8916ce434eb64506afc72b49780d7b7c01b51564715b3974c0ae004cffd8fbfc19b0d7b6df01a5668c06a55285f3ee38233de00a56c6dffc9d753c
7
- data.tar.gz: 86d9f7bb7271f831ce0ce63f804385190f45a17034d85f621e1ade9f9f4fcbfc3afb626ece683f8fa9f49a4470f61ed2eab592206b7ff5fc00091823caaab203
6
+ metadata.gz: 78380ca16e71a5a68f4f367d8d6dd87c3adf364cd4f3bcfe982bb5b3b707ca67d74b161ed22fc9d049fbaa6339aa18d701bb85c0c07b182783fe6c5cd97129ae
7
+ data.tar.gz: b0c3f60e4b097964cc08522c2bca74100b7c9a7d1f61269b0e99c97735f9662ec924e492b6f96b8da58b4b637e3060eee4044d61294ece22b5d23b8b5b3cc8df
@@ -1,8 +1,8 @@
1
1
  module Actions
2
2
 
3
3
  def follow(user_id)
4
- log("trying to follow a user [#{user_id}]")
5
- check_login_status(:auto_retry)
4
+ log("trying to follow a user [#{user_id}]", "ACTIONS")
5
+ check_login_status()
6
6
  follow_url = "https://www.instagram.com/web/friendships/#{user_id}/follow/"
7
7
  set_mechanic_data
8
8
  response = @agent.post(follow_url, @params, @headers)
@@ -13,8 +13,8 @@ module Actions
13
13
  end
14
14
 
15
15
  def unfollow(user_id)
16
- log("trying to unfollow a user [#{user_id}]")
17
- check_login_status(:auto_retry)
16
+ log("trying to unfollow a user [#{user_id}]", "ACTIONS")
17
+ check_login_status()
18
18
  unfollow_url = "https://www.instagram.com/web/friendships/#{user_id}/unfollow/"
19
19
  set_mechanic_data
20
20
  response = @agent.post(unfollow_url, @params, @headers)
@@ -25,8 +25,8 @@ module Actions
25
25
  end
26
26
 
27
27
  def like(media_id)
28
- log("trying to like a media[#{media_id}]")
29
- check_login_status(:auto_retry)
28
+ log("trying to like a media[#{media_id}]", "ACTIONS")
29
+ check_login_status()
30
30
  comment_url = "https://www.instagram.com/web/likes/#{media_id}/like/"
31
31
  set_mechanic_data
32
32
  response = @agent.post(comment_url, @params, @headers)
@@ -36,9 +36,9 @@ module Actions
36
36
  return({media_id: media_id, response_code: response.code})
37
37
  end
38
38
 
39
- def comment(media_id=0, text="")
40
- log("trying to send a comment to media[#{media_id}]")
41
- check_login_status(:auto_retry)
39
+ def comment(media_id, text="")
40
+ log("trying to send a comment to media[#{media_id}]", "ACTIONS")
41
+ check_login_status()
42
42
  comment_url = "https://www.instagram.com/web/comments/#{media_id}/add/"
43
43
  set_mechanic_data({ comment_text: text.to_s })
44
44
  response = @agent.post(comment_url, @params, @headers)
@@ -11,7 +11,7 @@ module Banner
11
11
  ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝
12
12
 
13
13
  BANNER
14
- puts "A instagram bot works without IG api".white.bold + " #Author ".yellow + "github.com/eVanilla".cyan
14
+ puts "An instagram bot works without instagram api ".white.bold + "github.com/".cyan + "eVanilla".cyan.bold.italic
15
15
  end
16
16
  end
17
17
 
@@ -10,7 +10,7 @@ module Config
10
10
  end
11
11
 
12
12
  class Configuration
13
- attr_accessor :username, :password, :tags, :comments, :pretty_print, :print_banner, :pre_load, :wait_per_action, :infinite_tags, :max_like_per_day, :max_follow_per_day, :max_unfollow_per_day, :max_comment_per_day, :unwanted_list, :white_list_users#, :print_logs
13
+ attr_accessor :username, :password, :tags, :use_proxy, :proxy, :comments, :print_banner, :pre_load, :wait_per_action, :infinite_tags, :max_like_per_day, :max_follow_per_day, :max_unfollow_per_day, :max_comment_per_day, :unwanted_list, :white_list_users#, :print_logs
14
14
  def initialize
15
15
  @username = nil
16
16
  @password = nil
@@ -22,7 +22,6 @@ module Config
22
22
  @max_follow_per_day = 50
23
23
  @max_unfollow_per_day = 50
24
24
  @max_comment_per_day = 50
25
- @print_logs = true
26
25
  @comments = [
27
26
  ["this", "the", "your"],
28
27
  ["photo", "picture", "pic", "shot", "snapshot"],
@@ -30,10 +29,12 @@ module Config
30
29
  ["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"],
31
30
  [".", "..", "...", "!","!!","!!!"]
32
31
  ]
32
+ @use_proxy = false
33
+ @proxy = []
33
34
  @infinite_tags = true
34
35
  @pre_load = true
35
- @pretty_print = true
36
36
  @print_banner = true
37
+ # @pretty_print = true
37
38
  # @print_logs = true
38
39
  end
39
40
  end
data/lib/instabot/core.rb CHANGED
@@ -18,6 +18,7 @@ class Instabot
18
18
  @users = []
19
19
  @medias = []
20
20
  @log_counter = 0
21
+ @login_counter = 1
21
22
  @login_status = false
22
23
  @lib_dir = "#{Dir.pwd}/lib"
23
24
  @root_dir = "#{Dir.pwd}"
@@ -82,8 +83,10 @@ class Instabot
82
83
  :wait_per_action => Config.options.wait_per_action,
83
84
  :comments => Config.options.comments,
84
85
  :pre_load => Config.options.pre_load,
85
- :pretty_print => Config.options.pretty_print,
86
+ :use_proxy => Config.options.use_proxy,
87
+ :proxy => Config.options.proxy,
86
88
  :print_banner => Config.options.print_banner
89
+ # :pretty_print => Config.options.pretty_print,
87
90
  # :print_logs => Config.options.print_logs
88
91
  }
89
92
  else
@@ -96,28 +99,28 @@ class Instabot
96
99
  end
97
100
  end
98
101
 
99
- def custom_puts(text="")
100
- pretty_print_mode = options[:pretty_print]
101
- if pretty_print_mode
102
- puts "#{text}"
103
- else
104
- puts "#{text}".colorize(color: :white, background: :default)
105
- end
106
- end
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
107
110
 
108
- def custom_print(text="")
109
- pretty_print_mode = options[:pretty_print]
110
- empty_space = IO.console.winsize[1] - text.size
111
- empty_space = 0 if empty_space < 0
112
- if pretty_print_mode
113
- print "\r#{text}"
114
- # $stdout.flush
115
- print " " * empty_space
116
- # IO.console.flush
117
- else
118
- print "#{text}\n".white
119
- end
120
- end
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
121
124
 
122
125
 
123
126
 
@@ -125,14 +128,13 @@ class Instabot
125
128
  trap("INT") { exit! }
126
129
  print_banner
127
130
  check_log_files
131
+ log("log files are checked", "CORE")
132
+ log("Machine started","CORE")
128
133
  create_mechanic
129
- custom_print "[+] ".cyan + "Processing successfully completed"
130
- puts
131
-
132
- if mode == :default
134
+ puts "[+] ".cyan + "Processing successfully completed"
135
+ log("Processing successfully completed", "CORE")
136
+ unless mode != :default
133
137
  login
134
- elsif mode == :manual
135
- else
136
138
  end
137
139
 
138
140
  end
@@ -1,23 +1,32 @@
1
1
  module Protocol
2
+
2
3
  def create_mechanic
3
- puts Dir.glob("")
4
4
  @agent = Mechanize.new
5
5
  @agent.max_history = 2
6
6
  # @agent.log = Logger.new(STDOUT)
7
- @agent.ca_file = "./cacert.pem"
8
- @agent.user_agent_alias = "Mac Safari"
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
18
+
9
19
  # @agent.set_proxy()
10
- custom_print "PROCESSING: ".cyan.bold + "protocol created"
20
+ puts "PROCESSING: ".cyan.bold + "protocol created"
21
+ log("Protocol successfully created", "CREATE_PROTOCOL")
11
22
  end
12
23
 
13
-
14
24
  def get_page(url)
15
25
  response = @agent.get(url)
16
26
  # @temp_jar = @agent.cookie_jar
17
27
  # @temp_jar.save("#{@lib_dir}/cookies.yaml", session: true) # => saving the cookies
18
28
  end
19
29
 
20
-
21
30
  def set_mechanic_data(params={})
22
31
  @cookies = Hash[@agent.cookies.map {|key, value| [key.name, key.value]}]
23
32
  @params = params
@@ -2,23 +2,27 @@ module Grabber
2
2
 
3
3
  def get_user_informations(user_id)
4
4
  # puts "=".cyan*10
5
- begin
6
- user_page = "https://www.instagram.com/web/friendships/#{user_id}/follow/"
7
- response = get_page(user_page)
8
- last_page = @agent.history.last.uri.to_s
9
- username = last_page.split('/')[3]
10
- response = @agent.get("https://instagram.com/#{username}/?__a=1")
11
- rescue Exception => e
12
- if response.code == "404"
13
- puts "ERORR: [404] Notfound\t#{e.message}".red
14
- exit!
15
- elsif response.code == "403"
16
- exit! if @error_403_times == 3
17
- @error_403_times += 1
18
- puts "ERROR: [403] (looks like you're banned from IG)".red
19
- retry
20
- end
21
- end
5
+ # begin
6
+ puts "[+] ".cyan + "Trying to get user (#{user_id}) informations"
7
+ log("Trying to get user (#{user_id}) informations", "GRABBER")
8
+ user_page = "https://www.instagram.com/web/friendships/#{user_id}/follow/"
9
+ response = get_page(user_page)
10
+ last_page = response.uri.to_s
11
+ username = last_page.split('/')[3]
12
+ pp username
13
+ pp last_page
14
+ response = @agent.get("https://instagram.com/#{username}/?__a=1")
15
+ # rescue Exception => e
16
+ # if response.code == "404"
17
+ # puts "ERORR: [404] Notfound\t#{e.message}".red
18
+ # exit!
19
+ # elsif response.code == "403"
20
+ # exit! if @error_403_times == 3
21
+ # @error_403_times += 1
22
+ # puts "ERROR: [403] (looks like you're banned from IG)".red
23
+ # retry
24
+ # end
25
+ # end
22
26
  data = JSON.parse(response.body)
23
27
  data.extend Hashie::Extensions::DeepFind
24
28
 
@@ -38,20 +42,21 @@ module Grabber
38
42
 
39
43
  def get_media_informations(media_id)
40
44
  # puts "=".cyan*10
41
- custom_puts "[+] ".cyan + "Trying to get media (#{media_id}) information"
42
- begin
43
- response = @agent.get("https://www.instagram.com/p/#{media_id}/?__a=1")
44
- rescue Exception => e
45
- if response.code == "404"
46
- puts "ERORR: [404] Notfound\t#{e.message}".red
47
- exit!
48
- elsif response.code == "403"
49
- exit! if @error_403_times == 3
50
- @error_403_times += 1
51
- puts "ERROR: [403] (looks like you're banned from IG)".red
52
- retry
53
- end
54
- end
45
+ puts "[+] ".cyan + "Trying to get media (#{media_id}) informations"
46
+ log("Trying to get media (#{media_id}) informations","GRABBER")
47
+ # begin
48
+ response = @agent.get("https://www.instagram.com/p/#{media_id}/?__a=1")
49
+ # rescue Exception => e
50
+ # if response.code == "404"
51
+ # puts "ERORR: [404] Notfound\t#{e.message}".red
52
+ # exit!
53
+ # elsif response.code == "403"
54
+ # exit! if @error_403_times == 3
55
+ # @error_403_times += 1
56
+ # puts "ERROR: [403] (looks like you're banned from IG)".red
57
+ # retry
58
+ # end
59
+ # end
55
60
  data = JSON.parse(response.body)
56
61
  data.extend Hashie::Extensions::DeepFind
57
62
  # pp data.extend Hashie::Extensions::DeepFind
@@ -92,7 +97,7 @@ module Grabber
92
97
  Config.options.tags << tag
93
98
  end
94
99
  end
95
- custom_puts "\n[+] ".cyan + "[" + "#{id}".yellow + "] New tags added"
100
+ puts "[+] ".cyan + "[" + "#{id}".yellow + "] New tags added"
96
101
  # pp Config.options.tags
97
102
  end
98
103
  # puts @informations
@@ -104,7 +109,8 @@ module Grabber
104
109
  def search(tags=[])
105
110
  tags.each do |tag|
106
111
  url = "https://www.instagram.com/explore/tags/#{tag}/?__a=1"
107
- custom_print "[+] ".cyan + "Searching in [##{tag}] tag"
112
+ puts "[+] ".cyan + "Searching in hashtags [##{tag}]"
113
+ log("Searching in hashtags [##{tag}]", "GRABBER")
108
114
  response = @agent.get(url)
109
115
  # puts response.body.to_s.cyan[0..50]
110
116
  data = JSON.parse(response.body)
@@ -115,8 +121,9 @@ module Grabber
115
121
  media_codes.map {|code| medias << code}
116
122
  Config.options.tags.delete(tag)
117
123
  end
118
- custom_puts "\n[+] ".cyan + "Total grabbed users [" + "#{users.size}".yellow + "]"
119
- custom_puts "[+] ".cyan + "Total grabbed medias [" + "#{medias.size}".yellow + "]\n"
124
+ puts "[+] ".cyan + "Total grabbed users [" + "#{users.size}".yellow + "]"
125
+ puts "[+] ".cyan + "Total grabbed medias [" + "#{medias.size}".yellow + "]"
126
+ log("Total grabbed users(#{users.size}) & Total grabbed medias(#{medias.size})", "GRABBER")
120
127
  end
121
128
 
122
129
 
@@ -1,13 +1,22 @@
1
1
  module Log
2
2
 
3
3
  def check_log_files
4
- custom_print "PROCESSING: ".cyan.bold + "checking log files"
4
+ puts "PROCESSING: ".cyan.bold + "checking log files"
5
+ log("checking log files", "LOGGER")
5
6
  if !File.exists?(@logs_dir)
6
7
  Dir.mkdir(@logs_dir)
7
8
  end
8
-
9
- if File.exists?("#{@logs_dir}/logs.log")
10
- # File.delete("#{@logs_dir}/logs.log")
9
+
10
+ if options[:pre_load]
11
+ if Dir.exists?('./logs')
12
+ files = ["commented_medias", "followed_users", "liked_medias", "unfollowed_users"]
13
+ files.each do |file|
14
+ File.open("./logs/#{file}.txt","r+") do |buffer|
15
+ data = buffer.read.split(',')
16
+ @local_stroage[file.to_sym] = data
17
+ end
18
+ end
19
+ end
11
20
  end
12
21
  end
13
22
 
@@ -17,8 +26,12 @@ module Log
17
26
 
18
27
  def log(text="",from="")
19
28
  time = Time.new.strftime("%H:%M:%S %y-%m-%d")
20
- File.open("#{@logs_dir}/logs-#{@global_time}.log","a+") do |log_file|
21
- log_file.puts "[#{@log_counter}] [#{time}] [#{from}] -- : #{text}"
29
+ if File.exists?(@logs_dir)
30
+ File.open("#{@logs_dir}/logs-#{@global_time}.log","a+") do |log_file|
31
+ log_file.puts "[#{@log_counter}] [#{time}] [#{from}] -- : #{text}"
32
+ end
33
+ else
34
+ Dir.mkdir(@logs_dir)
22
35
  end
23
36
  @log_counter += 1
24
37
  end
@@ -34,9 +47,9 @@ module Log
34
47
  when :comment
35
48
  write_file("commented_medias.txt",id)
36
49
  when :default
37
- puts "please choice a type"
50
+ puts "please choose a type"
38
51
  else
39
- puts "please choice a type"
52
+ puts "please choose a type"
40
53
  end
41
54
  end
42
55
 
@@ -8,48 +8,71 @@ module Login
8
8
  username = options[:username]
9
9
  password = options[:password]
10
10
  end
11
- log("trying to login")
12
- custom_print "[+] ".cyan + "Trying to login into [#{username}] account"
11
+ log("Trying to login into [#{username}] account", "LOGIN")
12
+ puts "[+] ".cyan + "Trying to login into [#{username}] account"
13
13
  login_page = @agent.get("https://www.instagram.com/accounts/login/?force_classic_login")
14
14
  page_form = login_page.forms.last
15
15
  page_form.username = username
16
16
  page_form.password = password
17
17
  page = page_form.submit
18
- if page.code == "200"
18
+ # pp page
19
+ # puts "=".cyan*100
20
+ # pp page.body
21
+ # puts "=".cyan*100
22
+ # pp page.code
23
+ # puts "=".cyan*100
24
+
25
+ # puts "=".cyan*100
26
+ # pp @agent.history.last.uri
27
+ if page.code == "200" && page.uri.to_s != "https://www.instagram.com/accounts/login/?force_classic_login" && !"#{page.uri.to_s}".include?("challenge")
19
28
  @login_status = true
20
- log("successfully logged in")
21
- custom_print "[+] ".cyan + "Successfully logged in".green.bold
29
+ log("successfully logged in","LOGIN")
30
+ puts "[+] ".cyan + "Successfully logged in".green.bold
22
31
  else
23
32
  @login_status = false
24
- custom_print "[-] ".cyan + "Invalid username or password or maybe a bug!".red.bold
25
- exit
33
+ if "#{page.uri.to_s}".include?("challenge")
34
+ puts "[-] ".cyan + "Your account needs veryfication or it has banned from instagram".red.bold
35
+ else
36
+ puts "[-] ".cyan + "Invalid username or password".red.bold
37
+ end
38
+ check_login_status()
26
39
  end
27
- puts
28
40
  rescue Exception => e
29
- log("a error detected: #{e.class} #{e}")
41
+ log("an error detected: #{e.class} #{e} #{e.backtrace}","LOGIN")
30
42
  @login_status = false
31
- custom_print "[-] ".cyan + "#{e.class} #{e.message}".red
43
+ puts "[-] ".cyan + "#{e.class} #{e.message}".red
44
+ exit
32
45
  end
33
46
 
34
47
  def logout
35
- log("trying to logout")
36
- custom_print "[+] ".cyan + "Trying to logging out"
48
+ log("trying to logout", "LOGIN")
49
+ puts "[+] ".cyan + "Trying to logging out"
37
50
  set_mechanic_data
38
51
  logout_page = @agent.get("https://www.instagram.com/accounts/logout/")
39
52
  @logout_status = true
40
- log("successfully logged out")
41
- custom_print "[+] ".cyan + "Successfully logged out"
53
+ log("successfully logged out", "LOGIN")
54
+ puts "[+] ".cyan + "Successfully logged out"
42
55
  end
43
56
 
44
57
  def check_login_status(mode=:default)
45
- # custom_print "[+] ".cyan + "Checking login status"
46
- log("checking loging status")
58
+ puts "[+] ".cyan + "Checking login status" if @login_mode != :manual
59
+ log("checking loging status", "LOGIN")
47
60
  if @login_status
48
61
  return true
49
62
  else
50
- custom_print "[-] ".cyan + "you're not logged in.".red.bold
51
- return false
52
- login if mode == :auto_retry
63
+ puts "[-] [##{@login_counter}] ".cyan + "You're not logged in (or it is an error with the request)\t[TRYING AGAIN]".red.bold
64
+ # if @login_mode != :manual
65
+ # if mode == :auto_retry
66
+ exit! if @login_counter == 3
67
+ @login_counter += 1
68
+ login
69
+ # else
70
+ # exit!
71
+ # end
72
+ # else
73
+
74
+ # return false
75
+ # end
53
76
  end
54
77
  end
55
78
 
@@ -3,40 +3,45 @@ module Modes
3
3
  def mode(mode=:default)
4
4
  case mode
5
5
  when :infinite
6
- custom_print "[+] ".cyan + "Auto mode is turned on".yellow
6
+ puts "[+] ".cyan + "[Auto] mode is turned on".yellow
7
+ log("[Auto] mode is turned on", "MODES")
7
8
  search(options[:tags])
8
- @next_day = Time.new + 1.days
9
- puts
9
+ @tomorrow = Time.new + 1.days
10
+ @today = Time.new
10
11
  while true
11
12
  # if @maximums[:likes_in_day] != @maximums[:max_likes_per_day] && @maximums[:follows_in_day] != @maximums[:max_follows_per_day] && @maximums[:unfollows_in_day] != @maximums[:max_unfollows_per_day] && @maximums[:comments_in_day] != @maximums[:max_comments_per_day]
12
13
  if !maximums_are_full?
13
- # custom_puts "[+] " + "".red
14
+ # puts "[+] " + "".red
14
15
  if @maximums[:follows_in_day] != @maximums[:max_follows_per_day]
15
16
  @maximums[:follows_in_day] += 1
16
17
  auto_follow
17
18
  else
18
- custom_puts "[+] ".cyan + "Maximum follows per day"
19
+ puts "[+] ".cyan + "Maximum follows per day".upcase
20
+ log("Maximum follows per day", "MODES")
19
21
  end
20
22
 
21
23
  if @maximums[:unfollows_in_day] != @maximums[:max_unfollows_per_day]
22
24
  @maximums[:unfollows_in_day] += 1
23
25
  auto_unfollow
24
26
  else
25
- custom_puts "[+] ".cyan + "Maximum unfollows per day"
27
+ puts "[+] ".cyan + "Maximum unfollows per day".upcase
28
+ log("Maximum unfollows per day", "MODES")
26
29
  end
27
30
 
28
31
  if @maximums[:likes_in_day] != @maximums[:max_likes_per_day]
29
32
  @maximums[:likes_in_day] += 1
30
33
  auto_like
31
34
  else
32
- custom_puts "[+] ".cyan + "Maximum likes per day"
35
+ puts "[+] ".cyan + "Maximum likes per day".upcase
36
+ log("Maximum likes per day", "MODES")
33
37
  end
34
38
 
35
39
  if @maximums[:comments_in_day] != @maximums[:max_comments_per_day]
36
40
  @maximums[:comments_in_day] += 1
37
41
  auto_comment
38
42
  else
39
- custom_puts "[+] ".cyan + "Maximum comments per day"
43
+ puts "[+] ".cyan + "Maximum comments per day".upcase
44
+ log("Maximum comments per day", "MODES")
40
45
  end
41
46
  # custom_print "maximums = #{@maximums}"
42
47
 
@@ -48,14 +53,15 @@ module Modes
48
53
  end
49
54
  end
50
55
  when :clean_up
51
- custom_puts "[+] ".cyan + "Clean up mode is turned on"
56
+ puts "[+] ".cyan + "[Clean up] mode is turned on".upcase.yellow
57
+ log("[Clean up] mode is turned on", "MODES")
52
58
  @local_stroage[:followed_users].each do |user|
53
59
  unfollow(user)
54
60
  end
55
61
  when :default
56
- custom_print "[-] ".cyan + "Please choose a mode".red
62
+ custom_print "[-] ".cyan + "Please choose a mode".upcase.red
57
63
  else
58
- custom_print "[-] ".cyan + "Please choose a mode".red
64
+ custom_print "[-] ".cyan + "Please choose a mode".upcase.red
59
65
  end
60
66
  end
61
67
 
@@ -71,7 +77,7 @@ module Modes
71
77
  def auto_follow
72
78
  all_users = users
73
79
  id = 0
74
- custom_puts "[+] ".cyan + "#{all_users.size} users ready to follow"
80
+ puts "[+] ".cyan + "#{all_users.size} user is ready to follow".upcase
75
81
  # users.each do |user|
76
82
  while @maximums[:follows_in_day] < @maximums[:max_follows_per_day]
77
83
  begin
@@ -79,16 +85,16 @@ module Modes
79
85
  get_user_informations(all_users[id])
80
86
  # custom_print "user informations:".cyan
81
87
  # @informations.map {|key,val| custom_print "#{key}: #{val}"}
82
- custom_puts "[+] ".cyan + "Trying to follow a user [#{all_users[id]}]"
88
+ puts "[+] ".cyan + "Trying to follow user [#{all_users[id]}]"
83
89
  follow(@informations[:id])
84
- custom_puts "\n[+] ".cyan + "User followed!".green.bold
90
+ puts "[+] ".cyan + "User followed".upcase.green.bold
85
91
  @maximums[:follows_in_day] += 1
86
92
  id += 1
87
93
  # custom_print "development informations: ".cyan
88
94
  # custom_print "follows_in_day = #{@maximums[:follows_in_day]} || max_follows_per_day = #{@maximums[:max_follows_per_day]} || id = #{id}"
89
95
  fall_in_asleep
90
96
  rescue Exception => e
91
- puts "an error detected ... #{e} #{e.backtrace}\nignored"
97
+ puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
92
98
  id += 1
93
99
  retry
94
100
  end
@@ -99,29 +105,29 @@ module Modes
99
105
  def auto_unfollow
100
106
  # users.each do |user|
101
107
  followed_users = @local_stroage[:followed_users]
102
- custom_puts "[+] ".cyan + "#{followed_users.size} users ready to unfollow"
108
+ puts "[+] ".cyan + "#{followed_users.size} user is ready to unfollow".upcase
103
109
  id = 0
104
110
  while @maximums[:unfollows_in_day] < @maximums[:max_unfollows_per_day]
105
111
  if @local_stroage[:followed_users].size < @maximums[:max_unfollows_per_day]
106
- begin
107
- # get_user_informations(unfollowed_users[id])
108
- # custom_print "user informations:".cyan
109
- # @informations.map {|key,val| custom_print "#{key}: #{val}"}
110
- # custom_print "unfollowed_users[id] => #{unfollowed_users[id]}"
111
- custom_puts "[+] ".cyan + "Trying to unfollow a user [#{followed_users[id]}]"
112
- unfollow(followed_users[id])
113
- custom_puts "\n[+] ".cyan + "User unfollowed".bold.green
114
- @maximums[:unfollows_in_day] += 1
115
- id += 1
116
- # custom_print "unfollows_in_day = #{@maximums[:unfollows_in_day]} || max_unfollows_per_day = #{@maximums[:max_unfollows_per_day]} || id = #{id}"
117
- fall_in_asleep
118
- rescue Exception => e
119
- puts "an error detected ... #{e}\nignored"
120
- id += 1
121
- retry
122
- end
112
+ begin
113
+ # get_user_informations(unfollowed_users[id])
114
+ # custom_print "user informations:".cyan
115
+ # @informations.map {|key,val| custom_print "#{key}: #{val}"}
116
+ # custom_print "unfollowed_users[id] => #{unfollowed_users[id]}"
117
+ puts "[+] ".cyan + "Trying to unfollow user [#{followed_users[id]}]"
118
+ unfollow(followed_users[id])
119
+ puts "[+] ".cyan + "User unfollowed".upcase.bold.green
120
+ @maximums[:unfollows_in_day] += 1
121
+ id += 1
122
+ # custom_print "unfollows_in_day = #{@maximums[:unfollows_in_day]} || max_unfollows_per_day = #{@maximums[:max_unfollows_per_day]} || id = #{id}"
123
+ fall_in_asleep
124
+ rescue Exception => e
125
+ puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
126
+ id += 1
127
+ retry
128
+ end
123
129
  else
124
- custom_print "[+] ".cyan + "[unfollow per day] is bigger than [follow per day]"
130
+ custom_print "[+] ".cyan + "[unfollow per day] is much bigger than [follow per day]"
125
131
  exit
126
132
  end
127
133
  end
@@ -130,22 +136,22 @@ module Modes
130
136
  def auto_like
131
137
  # medias.each do |media|
132
138
  all_medias = medias
133
- custom_puts "[+] ".cyan + "#{all_medias.size} Medias ready to like"
139
+ puts "[+] ".cyan + "#{all_medias.size} Media is ready to like".upcase
134
140
  id = 0
135
141
  while @maximums[:likes_in_day] < @maximums[:max_likes_per_day]
136
142
  begin
137
143
  get_media_informations(all_medias[id])
138
144
  # custom_print "media informations:".cyan
139
145
  # @informations.map {|key,val| custom_print "#{key}: #{val}"}
140
- custom_puts "[+] ".cyan + "Trying to like a media[#{all_medias[id]}]"
146
+ puts "[+] ".cyan + "Trying to like media [#{all_medias[id]}]"
141
147
  like(@informations[:id])
142
- custom_puts "\n[+] ".cyan + "Media liked".green.bold
148
+ puts "[+] ".cyan + "Media liked".upcase.green.bold
143
149
  @maximums[:likes_in_day] += 1
144
150
  # custom_print "likes_in_day = #{@maximums[:likes_in_day]} || max_likes_per_day = #{@maximums[:max_likes_per_day]}"
145
151
  id += 1
146
152
  fall_in_asleep
147
153
  rescue Exception => e
148
- puts "an error detected ... #{e}\n#{e.backtrace.inspect}\nignored"
154
+ puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
149
155
  id += 1
150
156
  retry
151
157
  end
@@ -155,7 +161,7 @@ module Modes
155
161
  def auto_comment
156
162
  # medias.each do |media|
157
163
  all_medias = medias
158
- custom_puts "[+] ".cyan + "#{all_medias.size} Medias ready to send a comment"
164
+ puts "[+] ".cyan + "#{all_medias.size} Media is ready to send a comment".upcase
159
165
  id = 0
160
166
  while @maximums[:comments_in_day] < @maximums[:max_comments_per_day]
161
167
  begin
@@ -163,15 +169,15 @@ module Modes
163
169
  id += 1 if @informations[:comments_disabled]
164
170
  # custom_print "media informations:".cyan
165
171
  # @informations.map {|key,val| custom_print "#{key}: #{val}"}
166
- custom_puts "[+] ".cyan + "Trying to send a comment to media[#{all_medias[id]}]"
172
+ puts "[+] ".cyan + "Trying to send a comment to media [#{all_medias[id]}]"
167
173
  comment(@informations[:id], generate_a_comment)
168
- custom_puts "\n[+] ".cyan + "comment successfully has been sent".green.bold
174
+ puts "[+] ".cyan + "comment successfully has been sent".upcase.green.bold
169
175
  @maximums[:comments_in_day] += 1
170
176
  # custom_print "comments_in_day = #{@maximums[:comments_in_day]} || max_comments_per_day = #{@maximums[:max_comments_per_day]}"
171
177
  id += 1
172
178
  fall_in_asleep
173
179
  rescue Exception => e
174
- puts "an error detected ... #{e}\n#{e.backtrace.inspect}\nignored"
180
+ puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
175
181
  id += 1
176
182
  retry
177
183
  end
@@ -190,8 +196,8 @@ module Modes
190
196
 
191
197
  def check_date
192
198
  # custom_print "checking time ..."
193
- time = ((@next_day) - Time.new).to_i # => seconds elapsed ...
194
- # custom_print "next day = #{@next_day}"
199
+ time = ((@tomorrow) - Time.new).to_i # => seconds elapsed ...
200
+ # custom_print "next day = #{@tomorrow}"
195
201
  if time == 0
196
202
 
197
203
  custom_print "[+] ".cyan + "It's a new day"
@@ -204,8 +210,8 @@ module Modes
204
210
  @maximums[:likes_in_day] = 0
205
211
  @maximums[:comments_in_day] = 0
206
212
  # time = (((Time.new + 1.days).to_f - Time.new.to_f) * 24 * 60 * 60).to_i
207
- @next_day = Time.new + 1.days
208
- # custom_print "new next day = #{@next_day}"
213
+ @tomorrow = Time.new + 1.days
214
+ # custom_print "new next day = #{@tomorrow}"
209
215
  # custom_print "new maximums = #{@maximums}"
210
216
  # custom_print "new local stroage = #{@local_stroage}"
211
217
  # custom_print "="*10
@@ -214,14 +220,19 @@ module Modes
214
220
  end
215
221
 
216
222
  else
217
- custom_print "[+] ".cyan + "#{time} seconds remained"
223
+ empty_space = IO.console.winsize[1] - text.size
224
+ empty_space = 0 if empty_space < 0
225
+ print "\r[+] ".cyan + "#{time} seconds remained".upcase
226
+ $stdout.flush
227
+ print " " * empty_space
228
+ # IO.console.flush
218
229
  end
219
230
  # return true
220
231
  end
221
232
 
222
233
  def fall_in_asleep
223
234
  time = options[:wait_per_action]
224
- custom_puts "\n[+] ".cyan + "Waiting for #{time} seconds"
235
+ puts "[+] ".cyan + "Waiting for #{time} seconds".upcase
225
236
  sleep time
226
237
  end
227
238
 
@@ -1,4 +1,5 @@
1
1
  module Version
2
- VERSION = "0.1.38"
3
- # DESCRIPTION = ""
2
+ VERSION = "0.1.40"
3
+ SUMMARY = "Ruby instagram bot"
4
+ DESCRIPTION = "A instagram bot works without instagram api, only needs your username and password"
4
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instabot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.38
4
+ version: 0.1.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - eVanilla
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-31 00:00:00.000000000 Z
11
+ date: 2017-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler