instabot 0.1.60 → 0.1.70

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e65c19805d01e7d5cf548a2e0ddbddb22c140d23
4
- data.tar.gz: fdfd65e986e357492c3fca461d8f88cb01a5b9e6
3
+ metadata.gz: dcce24b29e0626b0a5bd78169ddab9f35921bf1e
4
+ data.tar.gz: 1a8eb1ff3f0e3b9a61004703e56ad5b6d8be2a06
5
5
  SHA512:
6
- metadata.gz: 2ef72eecc7d4e9dbea93ee788be2ba6f8195afeae5dd1592fc9ce390b88b66162e836ab3164c9fc30be01d84a68c6a3ede9a7f0eea9c297cc4202502c213ca07
7
- data.tar.gz: 0ca74a86ac3ca1a7c2cb94bc589e035a6ab05bb03907ab682b97428a3c0edd77bf06edaed3e2b1953dfd9a6cea79ce74cd9653eae0d56e0c3c82734871cd3e37
6
+ metadata.gz: 83df48cbcb8673ba3270a59a1f0e497755b2a1c3b08bc5aa865d9a22c5864763b54dabc32da24779f5ab45c2dd83330ad4740efe2280dbfc37e755a66c3cee62
7
+ data.tar.gz: d1b8423befec9141b89e882c220efc27017b4800aac786bb3a0ab18e4e3dbdb166fc5cda561da10db75cd8dc9b991d845280264285cb57de9f6bc103ded8c935
data/lib/instabot.rb CHANGED
@@ -1,10 +1,10 @@
1
- require 'instabot/create_protocol'
2
- require 'instabot/version'
3
- require 'instabot/actions'
4
- require 'instabot/grabber'
5
- require 'instabot/banner'
6
- require 'instabot/logger'
7
- require 'instabot/config'
8
- require 'instabot/login'
9
- require 'instabot/modes'
10
- require 'instabot/core'
1
+ require_relative 'instabot/create_protocol'
2
+ require_relative 'instabot/version'
3
+ require_relative 'instabot/actions'
4
+ require_relative 'instabot/grabber'
5
+ require_relative 'instabot/banner'
6
+ require_relative 'instabot/logger'
7
+ require_relative 'instabot/config'
8
+ require_relative 'instabot/login'
9
+ require_relative 'instabot/modes'
10
+ require_relative 'instabot/core'
data/lib/instabot/core.rb CHANGED
@@ -19,7 +19,7 @@ class Instabot
19
19
  include Log
20
20
  include Protocol
21
21
 
22
- attr_accessor :users, :medias, :informations
22
+ attr_accessor :users, :medias, :media_information, :user_information
23
23
 
24
24
  def initialize(mode = :default)
25
25
  @login_mode = mode
@@ -2,7 +2,7 @@ module Protocol
2
2
  def create_mechanic
3
3
  @agent = Mechanize.new
4
4
  @agent.max_history = 2
5
- @agent.ca_file = './cacert.pem' # Because i'm using windows and... you know... ._.
5
+ # @agent.ca_file = './cacert.pem' # Because i use windows and... you know... ._.
6
6
  @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
7
7
  if options[:use_proxy]
8
8
  proxy = options[:proxy]
@@ -1,7 +1,9 @@
1
+ require 'active_support/core_ext/hash/indifferent_access'
2
+
1
3
  module Grabber
2
- def get_user_informations(user_id)
3
- puts '[+] '.cyan + "Trying to get user (#{user_id}) informations"
4
- log("Trying to get user (#{user_id}) informations", 'GRABBER')
4
+ def handle_user_information_data_by_user_id(user_id)
5
+ puts '[+] '.cyan + "Trying to get user (#{user_id}) information"
6
+ log("Trying to get user (#{user_id}) information", 'GRABBER')
5
7
  user_page = "https://www.instagram.com/web/friendships/#{user_id}/follow/"
6
8
  response = get_page(user_page)
7
9
  last_page = response.uri.to_s
@@ -9,25 +11,57 @@ module Grabber
9
11
  response = @agent.get("https://instagram.com/#{username}/?__a=1")
10
12
  data = parse_response(response.body)
11
13
 
12
- @informations = {
14
+ set_user_information(data)
15
+ end
16
+
17
+ def handle_user_information_data_by_user_name(username)
18
+ puts '[+] '.cyan + "Trying to get user (#{username}) information"
19
+ log("Trying to get user (#{username}) information", 'GRABBER')
20
+ response = @agent.get("https://instagram.com/#{username}/?__a=1")
21
+ data = parse_response(response.body)
22
+
23
+ set_user_information(data)
24
+ end
25
+
26
+ def handle_media_information_data(media_id)
27
+ puts '[+] '.cyan + "Trying to get media (#{media_id}) information"
28
+ log("Trying to get media (#{media_id}) information", 'GRABBER')
29
+ response = @agent.get("https://www.instagram.com/p/#{media_id}/?__a=1")
30
+ data = parse_response(response.body)
31
+
32
+ set_media_information(data)
33
+
34
+ unless @infinite_tags == true
35
+ tags = @media_information[:text].encode('UTF-8', invalid: :replace, undef: :replace, replace: '?').split(/\W+/)
36
+ id = 0
37
+ tags.each do |tag|
38
+ if tag == '_' || tag == '' || tag.nil?
39
+ tags.delete(tag)
40
+ else
41
+ id += 1
42
+ Config.options.tags << tag
43
+ end
44
+ end
45
+ puts '[+] '.cyan + '[' + id.to_s.yellow + '] New tags added'
46
+ end
47
+ end
48
+
49
+ def set_user_information(data)
50
+ @user_information = {
13
51
  followers: data.deep_find('followed_by')['count'],
14
52
  following: data.deep_find('follows')['count'],
15
53
  is_private: data.deep_find('is_private'),
16
54
  is_verified: data.deep_find('is_verified'),
17
55
  username: data.deep_find('username'),
18
- posts: data.deep_find('media')['count'],
56
+ media_count: data.deep_find('media')['count'],
57
+ medias: data.deep_find('media')['nodes'],
19
58
  full_name: data.deep_find('full_name'),
20
59
  id: data.deep_find('id')
21
- }
60
+ }.with_indifferent_access
22
61
  end
23
62
 
24
- def get_media_informations(media_id)
25
- puts '[+] '.cyan + "Trying to get media (#{media_id}) informations"
26
- log("Trying to get media (#{media_id}) informations", 'GRABBER')
27
- response = @agent.get("https://www.instagram.com/p/#{media_id}/?__a=1")
28
- data = parse_response(response.body)
29
-
30
- @informations = {
63
+ def set_media_information(data)
64
+ @media_information = {
31
65
  id: data.deep_find('id'),
32
66
  full_name: data.deep_find('full_name'),
33
67
  owner: data.deep_find('owner')['username'],
@@ -40,21 +74,7 @@ module Grabber
40
74
  is_verified: data.deep_find('is_verified'),
41
75
  requested_by_viewer: data.deep_find('requested_by_viewer'),
42
76
  text: data.deep_find('text')
43
- }
44
-
45
- unless @infinite_tags == true
46
- tags = @informations[:text].encode('UTF-8', invalid: :replace, undef: :replace, replace: '?').split(/\W+/)
47
- id = 0
48
- tags.each do |tag|
49
- if tag == '_' || tag == '' || tag.nil?
50
- tags.delete(tag)
51
- else
52
- id += 1
53
- Config.options.tags << tag
54
- end
55
- end
56
- puts '[+] '.cyan + '[' + id.to_s.yellow + '] New tags added'
57
- end
77
+ }.with_indifferent_access
58
78
  end
59
79
 
60
80
  def search(tags = [])
@@ -67,9 +67,9 @@ module Modes
67
67
  while @maximums[:follows_in_day] < @maximums[:max_follows_per_day]
68
68
  begin
69
69
  id += 1 if all_users[id].nil? || all_users[id] == []
70
- get_user_informations(all_users[id])
70
+ handle_user_information_data_by_user_id(all_users[id])
71
71
  puts '[+] '.cyan + "Trying to follow user [#{all_users[id]}]"
72
- follow(@informations[:id])
72
+ follow(@user_information[:id])
73
73
  puts '[+] '.cyan + 'User followed'.upcase.green.bold
74
74
  @maximums[:follows_in_day] += 1
75
75
  id += 1
@@ -113,9 +113,9 @@ module Modes
113
113
  id = 0
114
114
  while @maximums[:likes_in_day] < @maximums[:max_likes_per_day]
115
115
  begin
116
- get_media_informations(all_medias[id])
116
+ handle_media_information_data(all_medias[id])
117
117
  puts '[+] '.cyan + "Trying to like media [#{all_medias[id]}]"
118
- like(@informations[:id])
118
+ like(@media_information[:id])
119
119
  puts '[+] '.cyan + 'Media liked'.upcase.green.bold
120
120
  @maximums[:likes_in_day] += 1
121
121
  id += 1
@@ -134,15 +134,15 @@ module Modes
134
134
  id = 0
135
135
  while @maximums[:comments_in_day] < @maximums[:max_comments_per_day]
136
136
  begin
137
- get_media_informations(all_medias[id])
138
- if @informations[:comments_disabled]
137
+ handle_media_information_data(all_medias[id])
138
+ if @media_information[:comments_disabled]
139
139
  puts '[-]'.red + 'comments are disable' + "\t[IGNORING]".yellow
140
140
  id += 1
141
141
  next
142
142
  end
143
143
  generated_comment = generate_a_comment
144
144
  puts '[+] '.cyan + "Trying to send a comment[#{generated_comment}] to media[#{all_medias[id]}]"
145
- comment(@informations[:id], generated_comment)
145
+ comment(@media_information[:id], generated_comment)
146
146
  puts '[+] '.cyan + 'comment has been sent'.upcase.green.bold
147
147
  @maximums[:comments_in_day] += 1
148
148
  id += 1
@@ -208,4 +208,4 @@ module Modes
208
208
  likes_in_day_are_full? && follows_in_day_are_full? &&
209
209
  unfollows_in_day_are_full? && comments_in_day_are_full?
210
210
  end
211
- end
211
+ end
@@ -1,5 +1,5 @@
1
1
  module Version
2
- VERSION = '0.1.60'.freeze
2
+ VERSION = '0.1.70'.freeze
3
3
  SUMMARY = 'Ruby instagram bot'.freeze
4
4
  DESCRIPTION = 'An instagram bot works without instagram api, only needs your username and password'.freeze
5
5
  end
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.60
4
+ version: 0.1.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - eVanilla
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-14 00:00:00.000000000 Z
11
+ date: 2017-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler