instabot 0.1.40 → 0.1.52
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/instabot/modes.rb
CHANGED
@@ -1,253 +1,209 @@
|
|
1
1
|
module Modes
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
@maximums[:likes_in_day] = 0
|
211
|
-
@maximums[:comments_in_day] = 0
|
212
|
-
# time = (((Time.new + 1.days).to_f - Time.new.to_f) * 24 * 60 * 60).to_i
|
213
|
-
@tomorrow = Time.new + 1.days
|
214
|
-
# custom_print "new next day = #{@tomorrow}"
|
215
|
-
# custom_print "new maximums = #{@maximums}"
|
216
|
-
# custom_print "new local stroage = #{@local_stroage}"
|
217
|
-
# custom_print "="*10
|
218
|
-
unless @infinite_tags == true
|
219
|
-
search(options[:tags])
|
220
|
-
end
|
221
|
-
|
222
|
-
else
|
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
|
229
|
-
end
|
230
|
-
# return true
|
231
|
-
end
|
232
|
-
|
233
|
-
def fall_in_asleep
|
234
|
-
time = options[:wait_per_action]
|
235
|
-
puts "[+] ".cyan + "Waiting for #{time} seconds".upcase
|
236
|
-
sleep time
|
237
|
-
end
|
238
|
-
|
239
|
-
def maximums_are_full?
|
240
|
-
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]
|
241
|
-
return true
|
242
|
-
else
|
243
|
-
return false
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
end
|
2
|
+
def mode(mode = :default)
|
3
|
+
case mode
|
4
|
+
when :infinite
|
5
|
+
puts '[+] '.cyan + '[Auto] mode is turned on'.yellow
|
6
|
+
log('[Auto] mode is turned on', 'MODES')
|
7
|
+
search(options[:tags])
|
8
|
+
@tomorrow = Time.new + 1.days
|
9
|
+
loop do
|
10
|
+
if !maximums_are_full?
|
11
|
+
if !follows_in_day_are_full?
|
12
|
+
@maximums[:follows_in_day] += 1
|
13
|
+
auto_follow
|
14
|
+
else
|
15
|
+
puts '[+] '.cyan + 'Maximum follows per day'.upcase
|
16
|
+
log('Maximum follows per day', 'MODES')
|
17
|
+
end
|
18
|
+
|
19
|
+
if !unfollows_in_day_are_full?
|
20
|
+
@maximums[:unfollows_in_day] += 1
|
21
|
+
auto_unfollow
|
22
|
+
else
|
23
|
+
puts '[+] '.cyan + 'Maximum unfollows per day'.upcase
|
24
|
+
log('Maximum unfollows per day', 'MODES')
|
25
|
+
end
|
26
|
+
|
27
|
+
if !likes_in_day_are_full?
|
28
|
+
@maximums[:likes_in_day] += 1
|
29
|
+
auto_like
|
30
|
+
else
|
31
|
+
puts '[+] '.cyan + 'Maximum likes per day'.upcase
|
32
|
+
log('Maximum likes per day', 'MODES')
|
33
|
+
end
|
34
|
+
|
35
|
+
if !comments_in_day_are_full?
|
36
|
+
@maximums[:comments_in_day] += 1
|
37
|
+
auto_comment
|
38
|
+
else
|
39
|
+
puts '[+] '.cyan + 'Maximum comments per day'.upcase
|
40
|
+
log('Maximum comments per day', 'MODES')
|
41
|
+
end
|
42
|
+
else
|
43
|
+
check_date
|
44
|
+
sleep 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
when :clean_up
|
48
|
+
puts '[+] '.cyan + '[Clean up] mode is turned on'.upcase.yellow
|
49
|
+
log('[Clean up] mode is turned on', 'MODES')
|
50
|
+
@local_stroage[:followed_users].each do |user|
|
51
|
+
unfollow(user)
|
52
|
+
end
|
53
|
+
when :default
|
54
|
+
puts '[-] '.cyan + 'Please choose a mode'.upcase.red
|
55
|
+
else
|
56
|
+
puts '[-] '.cyan + 'Please choose a mode'.upcase.red
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def auto_follow
|
61
|
+
all_users = users
|
62
|
+
id = 0
|
63
|
+
puts '[+] '.cyan + "#{all_users.size} user is ready to follow".upcase
|
64
|
+
while @maximums[:follows_in_day] < @maximums[:max_follows_per_day]
|
65
|
+
begin
|
66
|
+
id += 1 if all_users[id].nil? || all_users[id] == []
|
67
|
+
get_user_informations(all_users[id])
|
68
|
+
puts '[+] '.cyan + "Trying to follow user [#{all_users[id]}]"
|
69
|
+
follow(@informations[:id])
|
70
|
+
puts '[+] '.cyan + 'User followed'.upcase.green.bold
|
71
|
+
@maximums[:follows_in_day] += 1
|
72
|
+
id += 1
|
73
|
+
fall_in_asleep
|
74
|
+
rescue Exception => e
|
75
|
+
puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
|
76
|
+
id += 1
|
77
|
+
retry
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def auto_unfollow
|
83
|
+
followed_users = @local_stroage[:followed_users]
|
84
|
+
puts '[+] '.cyan + "#{followed_users.size} user is ready to unfollow".upcase
|
85
|
+
id = 0
|
86
|
+
while @maximums[:unfollows_in_day] < @maximums[:max_unfollows_per_day]
|
87
|
+
if @local_stroage[:followed_users].size < @maximums[:max_unfollows_per_day]
|
88
|
+
begin
|
89
|
+
puts '[+] '.cyan + "Trying to unfollow user [#{followed_users[id]}]"
|
90
|
+
unfollow(followed_users[id])
|
91
|
+
puts '[+] '.cyan + 'User unfollowed'.upcase.bold.green
|
92
|
+
@maximums[:unfollows_in_day] += 1
|
93
|
+
id += 1
|
94
|
+
fall_in_asleep
|
95
|
+
rescue Exception => e
|
96
|
+
puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
|
97
|
+
id += 1
|
98
|
+
retry
|
99
|
+
end
|
100
|
+
else
|
101
|
+
puts '[+] '.cyan + '[unfollow per day] is much bigger than [follow per day]'
|
102
|
+
exit
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def auto_like
|
108
|
+
all_medias = medias
|
109
|
+
puts '[+] '.cyan + "#{all_medias.size} Media is ready to like".upcase
|
110
|
+
id = 0
|
111
|
+
while @maximums[:likes_in_day] < @maximums[:max_likes_per_day]
|
112
|
+
begin
|
113
|
+
get_media_informations(all_medias[id])
|
114
|
+
puts '[+] '.cyan + "Trying to like media [#{all_medias[id]}]"
|
115
|
+
like(@informations[:id])
|
116
|
+
puts '[+] '.cyan + 'Media liked'.upcase.green.bold
|
117
|
+
@maximums[:likes_in_day] += 1
|
118
|
+
id += 1
|
119
|
+
fall_in_asleep
|
120
|
+
rescue Exception => e
|
121
|
+
puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
|
122
|
+
id += 1
|
123
|
+
retry
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def auto_comment
|
129
|
+
all_medias = medias
|
130
|
+
puts '[+] '.cyan + "#{all_medias.size} Media is ready to send a comment".upcase
|
131
|
+
id = 0
|
132
|
+
while @maximums[:comments_in_day] < @maximums[:max_comments_per_day]
|
133
|
+
begin
|
134
|
+
get_media_informations(all_medias[id])
|
135
|
+
id += 1 if @informations[:comments_disabled]
|
136
|
+
puts '[+] '.cyan + "Trying to send a comment to media [#{all_medias[id]}]"
|
137
|
+
comment(@informations[:id], generate_a_comment)
|
138
|
+
puts '[+] '.cyan + 'comment successfully has been sent'.upcase.green.bold
|
139
|
+
@maximums[:comments_in_day] += 1
|
140
|
+
id += 1
|
141
|
+
fall_in_asleep
|
142
|
+
rescue Exception => e
|
143
|
+
puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
|
144
|
+
id += 1
|
145
|
+
retry
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def generate_a_comment
|
151
|
+
comments = options[:comments]
|
152
|
+
first = comments[0].sample
|
153
|
+
second = comments[1].sample
|
154
|
+
third = comments[2].sample
|
155
|
+
fourth = comments[3].sample
|
156
|
+
fifth = comments[4].sample
|
157
|
+
"#{first} #{second} #{third} #{fourth}#{fifth}"
|
158
|
+
end
|
159
|
+
|
160
|
+
def check_date
|
161
|
+
time = (@tomorrow - Time.new).to_i # => seconds elapsed ...
|
162
|
+
if time.zero?
|
163
|
+
puts '[+] '.cyan + "It's a new day"
|
164
|
+
@local_stroage[:followed_users] = []
|
165
|
+
@local_stroage[:unfollowed_users] = []
|
166
|
+
@local_stroage[:liked_medias] = []
|
167
|
+
@local_stroage[:commented_medias] = []
|
168
|
+
@maximums[:follows_in_day] = 0
|
169
|
+
@maximums[:unfollows_in_day] = 0
|
170
|
+
@maximums[:likes_in_day] = 0
|
171
|
+
@maximums[:comments_in_day] = 0
|
172
|
+
@tomorrow = Time.new + 1.days
|
173
|
+
search(options[:tags]) unless @infinite_tags == true
|
174
|
+
else
|
175
|
+
empty_space = IO.console.winsize[1] - text.size
|
176
|
+
empty_space = 0 if empty_space < 0
|
177
|
+
print "\r[+] ".cyan + "#{time} seconds remained".upcase
|
178
|
+
$stdout.flush
|
179
|
+
print ' ' * empty_space
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def fall_in_asleep
|
184
|
+
time = options[:wait_per_action]
|
185
|
+
puts '[+] '.cyan + "Waiting for #{time} seconds".upcase
|
186
|
+
sleep time
|
187
|
+
end
|
188
|
+
|
189
|
+
def likes_in_day_are_full?
|
190
|
+
@maximums[:likes_in_day] == @maximums[:max_likes_per_day]
|
191
|
+
end
|
192
|
+
|
193
|
+
def follows_in_day_are_full?
|
194
|
+
@maximums[:follows_in_day] == @maximums[:max_follows_per_day]
|
195
|
+
end
|
196
|
+
|
197
|
+
def unfollows_in_day_are_full?
|
198
|
+
@maximums[:unfollows_in_day] == @maximums[:max_unfollows_per_day]
|
199
|
+
end
|
200
|
+
|
201
|
+
def comments_in_day_are_full?
|
202
|
+
@maximums[:comments_in_day] == @maximums[:max_comments_per_day]
|
203
|
+
end
|
204
|
+
|
205
|
+
def maximums_are_full?
|
206
|
+
likes_in_day_are_full? && follows_in_day_are_full? &&
|
207
|
+
unfollows_in_day_are_full? && comments_in_day_are_full?
|
208
|
+
end
|
209
|
+
end
|