instabot 0.1.40 → 0.1.52

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,253 +1,209 @@
1
1
  module Modes
2
-
3
- def mode(mode=:default)
4
- case mode
5
- when :infinite
6
- puts "[+] ".cyan + "[Auto] mode is turned on".yellow
7
- log("[Auto] mode is turned on", "MODES")
8
- search(options[:tags])
9
- @tomorrow = Time.new + 1.days
10
- @today = Time.new
11
- while true
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]
13
- if !maximums_are_full?
14
- # puts "[+] " + "".red
15
- if @maximums[:follows_in_day] != @maximums[:max_follows_per_day]
16
- @maximums[:follows_in_day] += 1
17
- auto_follow
18
- else
19
- puts "[+] ".cyan + "Maximum follows per day".upcase
20
- log("Maximum follows per day", "MODES")
21
- end
22
-
23
- if @maximums[:unfollows_in_day] != @maximums[:max_unfollows_per_day]
24
- @maximums[:unfollows_in_day] += 1
25
- auto_unfollow
26
- else
27
- puts "[+] ".cyan + "Maximum unfollows per day".upcase
28
- log("Maximum unfollows per day", "MODES")
29
- end
30
-
31
- if @maximums[:likes_in_day] != @maximums[:max_likes_per_day]
32
- @maximums[:likes_in_day] += 1
33
- auto_like
34
- else
35
- puts "[+] ".cyan + "Maximum likes per day".upcase
36
- log("Maximum likes per day", "MODES")
37
- end
38
-
39
- if @maximums[:comments_in_day] != @maximums[:max_comments_per_day]
40
- @maximums[:comments_in_day] += 1
41
- auto_comment
42
- else
43
- puts "[+] ".cyan + "Maximum comments per day".upcase
44
- log("Maximum comments per day", "MODES")
45
- end
46
- # custom_print "maximums = #{@maximums}"
47
-
48
- # exit
49
- else
50
- # custom_print "in check date ... "
51
- check_date
52
- sleep 1
53
- end
54
- end
55
- when :clean_up
56
- puts "[+] ".cyan + "[Clean up] mode is turned on".upcase.yellow
57
- log("[Clean up] mode is turned on", "MODES")
58
- @local_stroage[:followed_users].each do |user|
59
- unfollow(user)
60
- end
61
- when :default
62
- custom_print "[-] ".cyan + "Please choose a mode".upcase.red
63
- else
64
- custom_print "[-] ".cyan + "Please choose a mode".upcase.red
65
- end
66
- end
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
- def auto_follow
78
- all_users = users
79
- id = 0
80
- puts "[+] ".cyan + "#{all_users.size} user is ready to follow".upcase
81
- # users.each do |user|
82
- while @maximums[:follows_in_day] < @maximums[:max_follows_per_day]
83
- begin
84
- id += 1 if all_users[id].nil? || all_users[id] == []
85
- get_user_informations(all_users[id])
86
- # custom_print "user informations:".cyan
87
- # @informations.map {|key,val| custom_print "#{key}: #{val}"}
88
- puts "[+] ".cyan + "Trying to follow user [#{all_users[id]}]"
89
- follow(@informations[:id])
90
- puts "[+] ".cyan + "User followed".upcase.green.bold
91
- @maximums[:follows_in_day] += 1
92
- id += 1
93
- # custom_print "development informations: ".cyan
94
- # custom_print "follows_in_day = #{@maximums[:follows_in_day]} || max_follows_per_day = #{@maximums[:max_follows_per_day]} || id = #{id}"
95
- fall_in_asleep
96
- rescue Exception => e
97
- puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
98
- id += 1
99
- retry
100
- end
101
- end
102
- # end
103
- end
104
-
105
- def auto_unfollow
106
- # users.each do |user|
107
- followed_users = @local_stroage[:followed_users]
108
- puts "[+] ".cyan + "#{followed_users.size} user is ready to unfollow".upcase
109
- id = 0
110
- while @maximums[:unfollows_in_day] < @maximums[:max_unfollows_per_day]
111
- if @local_stroage[:followed_users].size < @maximums[:max_unfollows_per_day]
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
129
- else
130
- custom_print "[+] ".cyan + "[unfollow per day] is much bigger than [follow per day]"
131
- exit
132
- end
133
- end
134
- end
135
-
136
- def auto_like
137
- # medias.each do |media|
138
- all_medias = medias
139
- puts "[+] ".cyan + "#{all_medias.size} Media is ready to like".upcase
140
- id = 0
141
- while @maximums[:likes_in_day] < @maximums[:max_likes_per_day]
142
- begin
143
- get_media_informations(all_medias[id])
144
- # custom_print "media informations:".cyan
145
- # @informations.map {|key,val| custom_print "#{key}: #{val}"}
146
- puts "[+] ".cyan + "Trying to like media [#{all_medias[id]}]"
147
- like(@informations[:id])
148
- puts "[+] ".cyan + "Media liked".upcase.green.bold
149
- @maximums[:likes_in_day] += 1
150
- # custom_print "likes_in_day = #{@maximums[:likes_in_day]} || max_likes_per_day = #{@maximums[:max_likes_per_day]}"
151
- id += 1
152
- fall_in_asleep
153
- rescue Exception => e
154
- puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
155
- id += 1
156
- retry
157
- end
158
- end
159
- end
160
-
161
- def auto_comment
162
- # medias.each do |media|
163
- all_medias = medias
164
- puts "[+] ".cyan + "#{all_medias.size} Media is ready to send a comment".upcase
165
- id = 0
166
- while @maximums[:comments_in_day] < @maximums[:max_comments_per_day]
167
- begin
168
- get_media_informations(all_medias[id])
169
- id += 1 if @informations[:comments_disabled]
170
- # custom_print "media informations:".cyan
171
- # @informations.map {|key,val| custom_print "#{key}: #{val}"}
172
- puts "[+] ".cyan + "Trying to send a comment to media [#{all_medias[id]}]"
173
- comment(@informations[:id], generate_a_comment)
174
- puts "[+] ".cyan + "comment successfully has been sent".upcase.green.bold
175
- @maximums[:comments_in_day] += 1
176
- # custom_print "comments_in_day = #{@maximums[:comments_in_day]} || max_comments_per_day = #{@maximums[:max_comments_per_day]}"
177
- id += 1
178
- fall_in_asleep
179
- rescue Exception => e
180
- puts "an error detected ... #{e.class} #{e.message}\n#{e.backtrace.inspect}\nignored"
181
- id += 1
182
- retry
183
- end
184
- end
185
- end
186
-
187
- def generate_a_comment
188
- comments = options[:comments]
189
- first = comments[0].sample
190
- second = comments[1].sample
191
- third = comments[2].sample
192
- fourth = comments[3].sample
193
- fifth = comments[4].sample
194
- return "#{first} #{second} #{third} #{fourth}#{fifth}"
195
- end
196
-
197
- def check_date
198
- # custom_print "checking time ..."
199
- time = ((@tomorrow) - Time.new).to_i # => seconds elapsed ...
200
- # custom_print "next day = #{@tomorrow}"
201
- if time == 0
202
-
203
- custom_print "[+] ".cyan + "It's a new day"
204
- @local_stroage[:followed_users] = []
205
- @local_stroage[:unfollowed_users] = []
206
- @local_stroage[:liked_medias] = []
207
- @local_stroage[:commented_medias] = []
208
- @maximums[:follows_in_day] = 0
209
- @maximums[:unfollows_in_day] = 0
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