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 +4 -4
- data/lib/instabot/actions.rb +9 -9
- data/lib/instabot/banner.rb +1 -1
- data/lib/instabot/config.rb +4 -3
- data/lib/instabot/core.rb +30 -28
- data/lib/instabot/create_protocol.rb +15 -6
- data/lib/instabot/grabber.rb +42 -35
- data/lib/instabot/logger.rb +21 -8
- data/lib/instabot/login.rb +42 -19
- data/lib/instabot/modes.rb +59 -48
- data/lib/instabot/version.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cbe88bf15a913c67baae5177edc8e64c0b2ff808
|
|
4
|
+
data.tar.gz: 04129dcc66f800d63900113e90722545a14f6dd9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78380ca16e71a5a68f4f367d8d6dd87c3adf364cd4f3bcfe982bb5b3b707ca67d74b161ed22fc9d049fbaa6339aa18d701bb85c0c07b182783fe6c5cd97129ae
|
|
7
|
+
data.tar.gz: b0c3f60e4b097964cc08522c2bca74100b7c9a7d1f61269b0e99c97735f9662ec924e492b6f96b8da58b4b637e3060eee4044d61294ece22b5d23b8b5b3cc8df
|
data/lib/instabot/actions.rb
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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
|
|
40
|
-
log("trying to send a comment to media[#{media_id}]")
|
|
41
|
-
check_login_status(
|
|
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)
|
data/lib/instabot/banner.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Banner
|
|
|
11
11
|
╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝
|
|
12
12
|
|
|
13
13
|
BANNER
|
|
14
|
-
puts "
|
|
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
|
|
data/lib/instabot/config.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Config
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
class Configuration
|
|
13
|
-
attr_accessor :username, :password, :tags, :
|
|
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
|
-
:
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
130
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
data/lib/instabot/grabber.rb
CHANGED
|
@@ -2,23 +2,27 @@ module Grabber
|
|
|
2
2
|
|
|
3
3
|
def get_user_informations(user_id)
|
|
4
4
|
# puts "=".cyan*10
|
|
5
|
-
begin
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
119
|
-
|
|
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
|
|
data/lib/instabot/logger.rb
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
module Log
|
|
2
2
|
|
|
3
3
|
def check_log_files
|
|
4
|
-
|
|
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
|
|
10
|
-
|
|
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.
|
|
21
|
-
|
|
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
|
|
50
|
+
puts "please choose a type"
|
|
38
51
|
else
|
|
39
|
-
puts "please
|
|
52
|
+
puts "please choose a type"
|
|
40
53
|
end
|
|
41
54
|
end
|
|
42
55
|
|
data/lib/instabot/login.rb
CHANGED
|
@@ -8,48 +8,71 @@ module Login
|
|
|
8
8
|
username = options[:username]
|
|
9
9
|
password = options[:password]
|
|
10
10
|
end
|
|
11
|
-
log("
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
29
|
+
log("successfully logged in","LOGIN")
|
|
30
|
+
puts "[+] ".cyan + "Successfully logged in".green.bold
|
|
22
31
|
else
|
|
23
32
|
@login_status = false
|
|
24
|
-
|
|
25
|
-
|
|
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("
|
|
41
|
+
log("an error detected: #{e.class} #{e} #{e.backtrace}","LOGIN")
|
|
30
42
|
@login_status = false
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
data/lib/instabot/modes.rb
CHANGED
|
@@ -3,40 +3,45 @@ module Modes
|
|
|
3
3
|
def mode(mode=:default)
|
|
4
4
|
case mode
|
|
5
5
|
when :infinite
|
|
6
|
-
|
|
6
|
+
puts "[+] ".cyan + "[Auto] mode is turned on".yellow
|
|
7
|
+
log("[Auto] mode is turned on", "MODES")
|
|
7
8
|
search(options[:tags])
|
|
8
|
-
@
|
|
9
|
-
|
|
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
|
-
#
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
88
|
+
puts "[+] ".cyan + "Trying to follow user [#{all_users[id]}]"
|
|
83
89
|
follow(@informations[:id])
|
|
84
|
-
|
|
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
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
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
|
-
|
|
146
|
+
puts "[+] ".cyan + "Trying to like media [#{all_medias[id]}]"
|
|
141
147
|
like(@informations[:id])
|
|
142
|
-
|
|
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
|
-
|
|
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
|
-
|
|
172
|
+
puts "[+] ".cyan + "Trying to send a comment to media [#{all_medias[id]}]"
|
|
167
173
|
comment(@informations[:id], generate_a_comment)
|
|
168
|
-
|
|
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 = ((@
|
|
194
|
-
# custom_print "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
|
-
@
|
|
208
|
-
# custom_print "new 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
|
-
|
|
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
|
-
|
|
235
|
+
puts "[+] ".cyan + "Waiting for #{time} seconds".upcase
|
|
225
236
|
sleep time
|
|
226
237
|
end
|
|
227
238
|
|
data/lib/instabot/version.rb
CHANGED
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.
|
|
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-
|
|
11
|
+
date: 2017-12-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|