botinsta 0.1.2 → 0.1.3
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/example/example.rb +7 -2
- data/lib/botinsta.rb +22 -14
- data/lib/botinsta/class_methods.rb +2 -1
- data/lib/botinsta/data/media_data.rb +1 -1
- data/lib/botinsta/helpers.rb +10 -3
- data/lib/botinsta/modes.rb +2 -2
- data/lib/botinsta/pages.rb +1 -1
- data/lib/botinsta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35dc6b56dac3eb29498b327a357a0de793869e6b292a21f246ee7124be359826
|
4
|
+
data.tar.gz: 8ae761a8f914882f7dbceaeba56133f1e9f3896f0e72d0a4163cd7d23f4e9f77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb3716427be71e812ad14c3a4eaec24eabe2066f210aeff92a043e14577ed9279ed8ec223a1bdf454a23769f3ed98a88cf8572cb4d88bf4525a34824b98c91b5
|
7
|
+
data.tar.gz: cb5d9e1c63d95e601ef50e9cae053180e0c7a8f8f47a198c206ed07b44d41c45165e16e963e43ec722db2a8ba3210b673d563c6232cf7fd13df76d2e54e4345a
|
data/example/example.rb
CHANGED
@@ -3,10 +3,15 @@ require 'botinsta'
|
|
3
3
|
bot = Botinsta.new ({ username: 'YOUR_USERNAME',
|
4
4
|
password: 'YOUR_PASSWORD',
|
5
5
|
tags: ['photography','vsco','b&w'],
|
6
|
-
likes_per_tag: 60,
|
7
6
|
tag_blacklist: ['nsfw','sexy','hot'],
|
7
|
+
likes_per_tag: 60,
|
8
8
|
unfollows_per_run: 200,
|
9
|
-
follows_per_tag: 10
|
9
|
+
follows_per_tag: 10,
|
10
|
+
unfollow_threshold: { seconds: 0,
|
11
|
+
minutes: 0,
|
12
|
+
hours: 1,
|
13
|
+
days: 0
|
14
|
+
}
|
10
15
|
})
|
11
16
|
|
12
17
|
bot.start
|
data/lib/botinsta.rb
CHANGED
@@ -5,6 +5,8 @@ require 'mechanize'
|
|
5
5
|
require 'sequel'
|
6
6
|
require 'sqlite3'
|
7
7
|
require 'nokogiri'
|
8
|
+
require 'rb-readline'
|
9
|
+
require 'pry'
|
8
10
|
|
9
11
|
require_relative 'botinsta/class_methods'
|
10
12
|
|
@@ -14,26 +16,32 @@ class Botinsta
|
|
14
16
|
|
15
17
|
include ClassMethods
|
16
18
|
|
17
|
-
DEFAULT_PARAMETERS = { tags:
|
18
|
-
tag_blacklist:
|
19
|
-
user_blacklist:
|
20
|
-
likes_per_tag:
|
21
|
-
|
22
|
-
|
19
|
+
DEFAULT_PARAMETERS = { tags: %w[photography fotografia vsco],
|
20
|
+
tag_blacklist: %w[nsfw hot sexy],
|
21
|
+
user_blacklist: [],
|
22
|
+
likes_per_tag: 10,
|
23
|
+
follows_per_tag: 50,
|
24
|
+
unfollows_per_run: 200,
|
25
|
+
unfollow_threshold: { seconds: 0,
|
26
|
+
minutes: 0,
|
27
|
+
hours: 1,
|
28
|
+
days: 0
|
29
|
+
}
|
23
30
|
}.freeze
|
24
31
|
|
25
32
|
def initialize(**params)
|
26
33
|
|
27
34
|
params = DEFAULT_PARAMETERS.merge(params)
|
28
35
|
|
29
|
-
@username
|
30
|
-
@password
|
31
|
-
@tags
|
32
|
-
@tag_blacklist
|
33
|
-
@user_blacklist
|
34
|
-
@likes_per_tag
|
35
|
-
@follows_per_tag
|
36
|
-
@unfollows_per_run
|
36
|
+
@username = params[:username]
|
37
|
+
@password = params[:password]
|
38
|
+
@tags = params[:tags]
|
39
|
+
@tag_blacklist = params[:tag_blacklist]
|
40
|
+
@user_blacklist = params[:user_blacklist]
|
41
|
+
@likes_per_tag = params[:likes_per_tag]
|
42
|
+
@follows_per_tag = params[:follows_per_tag]
|
43
|
+
@unfollows_per_run = params[:unfollows_per_run]
|
44
|
+
@unfollow_threshold = params[:unfollow_threshold]
|
37
45
|
|
38
46
|
@total_likes = 0
|
39
47
|
@total_follows = 0
|
@@ -11,7 +11,7 @@ class MediaData
|
|
11
11
|
@is_video = data.deep_find('is_video')
|
12
12
|
@comments_disabled = data.deep_find('comments_disabled')
|
13
13
|
@text = data.deep_find('text')
|
14
|
-
@tags = @text.scan(/#[a-zA-Z0-9]+/)
|
14
|
+
@tags = @text.nil? ? [] : @text.scan(/#[a-zA-Z0-9]+/)
|
15
15
|
@shortcode = data.deep_find('shortcode')
|
16
16
|
|
17
17
|
end
|
data/lib/botinsta/helpers.rb
CHANGED
@@ -145,12 +145,19 @@ module Helpers
|
|
145
145
|
@table_follows.where(user_id: user_id).delete
|
146
146
|
end
|
147
147
|
|
148
|
-
# Calculates
|
148
|
+
# Calculates whether the given threshold is past or not to
|
149
|
+
# start unfollowing users from the database.
|
149
150
|
#
|
150
151
|
# @param last_time [Time] a Time instance, used with @last_follow_time.
|
151
152
|
# @return [Boolean] true if a day is past since
|
152
153
|
# the first follow entry in the database, false otherwise.
|
153
|
-
def
|
154
|
-
|
154
|
+
def unfollow_threshold_past?(last_time)
|
155
|
+
days = @unfollow_threshold[:days] ||= 0
|
156
|
+
hours = @unfollow_threshold[:hours] ||= 0
|
157
|
+
minutes = @unfollow_threshold[:minutes] ||= 0
|
158
|
+
seconds = @unfollow_threshold[:seconds] ||= 0
|
159
|
+
|
160
|
+
total_in_seconds = days * 86_400 + hours * 3600 + minutes * 60 + seconds
|
161
|
+
((Time.now - last_time) / total_in_seconds) >= 1
|
155
162
|
end
|
156
163
|
end
|
data/lib/botinsta/modes.rb
CHANGED
@@ -17,7 +17,7 @@ module Modes
|
|
17
17
|
get_first_page_data(tag)
|
18
18
|
is_first_page = false
|
19
19
|
break if @page.medias_empty?
|
20
|
-
elsif
|
20
|
+
elsif @page.next_page?
|
21
21
|
get_next_page_data(tag)
|
22
22
|
end
|
23
23
|
@page.medias.each do |media|
|
@@ -45,7 +45,7 @@ module Modes
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# Here is the code for unfollowing users
|
48
|
-
if !@table_follows.empty? &&
|
48
|
+
if !@table_follows.empty? && unfollow_threshold_past?(@last_follow_time) && @total_unfollows != @unfollows_per_run
|
49
49
|
if unfollow_user(@first_db_entry[:user_id])
|
50
50
|
@total_unfollows += 1
|
51
51
|
print_success_message(action: :unfollow, number: @total_unfollows,
|
data/lib/botinsta/pages.rb
CHANGED
@@ -50,7 +50,7 @@ module Pages
|
|
50
50
|
# @param (see #set_query_id)
|
51
51
|
def get_next_page_data(tag)
|
52
52
|
print_time_stamp
|
53
|
-
puts 'Getting the next page for the tag '.colorize(:
|
53
|
+
puts 'Getting the next page for the tag '.colorize(:blue) + "#{tag}"
|
54
54
|
next_page_link = "https://www.instagram.com/graphql/query/?query_hash=#{@query_id}&"\
|
55
55
|
"variables={\"tag_name\":\"#{tag}\"," \
|
56
56
|
"\"first\":10,\"after\":\"#{@page.end_cursor}\"}"
|
data/lib/botinsta/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: botinsta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- andreyuhai
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|