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
|
# File 'lib/botinsta/modes.rb', line 8
def tag_based_mode
@tags.each do |tag|
like_count = 0; follow_count = 0
is_first_page = true
print_tag_message tag
until like_count == @likes_per_tag && follow_count == @follows_per_tag
if is_first_page
set_query_id(tag)
get_first_page_data(tag)
is_first_page = false
break if @page.medias_empty?
elsif @page.next_page?
get_next_page_data(tag)
end
@page.medias.each do |media|
media.extend Hashie::Extensions::DeepFind
@media = MediaData.new(media)
next if @media.blacklisted_tag?(@tag_blacklist)
if like_count != @likes_per_tag
if like_if_not_in_db(@media)
like_count += 1
else
print_error_message(action: :like, data: @media.id)
end
end
if follow_count != @follows_per_tag
if get_user_page_data(@media.owner) && follow_if_not_in_db(@user)
follow_count += 1
refresh_db_related if follow_count == 1
else
print_error_message(action: :follow, data: @user.username)
end
end
if !@table_follows.empty? && unfollow_threshold_past?(@last_follow_time) && @total_unfollows != @unfollows_per_run
if unfollow_user(@first_db_entry[:user_id])
@total_unfollows += 1
print_success_message(action: :unfollow, number: @total_unfollows,
data: @first_db_entry[:username])
delete_from_db(@first_db_entry[:user_id])
refresh_db_related
else
false
end
end
break if like_count == @likes_per_tag && follow_count == @follows_per_tag
end
end
end
rescue Interrupt
logout
exit
end
|