pampa_workers 1.1.4 → 1.1.10

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mybotprocess.rb +37 -2
  3. data/lib/myprocess.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb2b708bea8e27a1b9f9f83b2ebd0180a6d6f234
4
- data.tar.gz: e23a4ba37bc84f7b3e739f6586cc2c314b960f3a
3
+ metadata.gz: ff32f498a9f417bca1cd87cf09b5a834d6682d02
4
+ data.tar.gz: e078e98d93b15003592bd75c63615ae04cc97add
5
5
  SHA512:
6
- metadata.gz: 473e0f770d687e33990ae09e9a39ba80abb60f7a5ec91c80e500ec68bdae9d5bda12763b82fce38fb60e8cb25e9ba40f7dd59de9e3e32e15b3b4c1183a05f8ba
7
- data.tar.gz: 7ffd2a7e5b2e157b3f6c97a2b9ca71d2d1beb47cd2d3706cc127e06386f90e2db9c7159a1ffe0e891eb1e7ed0642597ac5e383cdd9dd686cf2f7b43c8ada9c35
6
+ metadata.gz: 495dd61d71142f0c760624819b78693647b4251c870fab166694cb1c55f1a8b8debdda627a08aa1c9513b131bd51b9d1deff9cd8fd89af20b12e44f55d2be589
7
+ data.tar.gz: be9351da878c5670bdf8836ec79781395225a23dc6d632b6312d67084ff7eaa6d2c5c07f095013b03b8cd6f260e9bb312cde3d622d10bdccec103d99e63c16b7
@@ -2,7 +2,7 @@ module BlackStack
2
2
 
3
3
  # clase de base para todos los bots ejecuten acciones con una cuenta de LinkedIn, Facebook, Twitter, etc.
4
4
  class MyBotProcess < BlackStack::MyRemoteProcess
5
- attr_accessor :username, :login_verifications, :run_once
5
+ attr_accessor :username, :login_verifications, :run_once, :cookies_robot
6
6
 
7
7
  # constructor
8
8
  def initialize(
@@ -18,7 +18,7 @@ module BlackStack
18
18
  self.worker_name = "#{the_worker_name}"
19
19
  self.division_name = the_division_name
20
20
  self.minimum_enlapsed_seconds = the_minimum_enlapsed_seconds
21
-
21
+
22
22
  # algunas clases como CreateLnUserProcess o RepairLnUserProcess, trabajan unicamente con el username especificado en este atributo, llamando al access point get_lnuser_by_username.
23
23
  # si este atributo es nil, entonces la clase pide un lnuser a la division, llamando al access point get_lnuser.
24
24
  self.username = nil
@@ -32,6 +32,9 @@ module BlackStack
32
32
  # si este proceso se corre de forma supevisada, se desa correr el procesamiento una unica vez.
33
33
  # cuando se activa este flag, generalmente se setea el atributo self.username tambien.
34
34
  self.run_once = false
35
+
36
+ # preguntar al servidor si el lnuser debe calentar el browser visitando sitios al azar para recolectar cookies
37
+ self.cookies_robot = true
35
38
  end
36
39
 
37
40
  # returns a hash with the parameters of a lnuser
@@ -101,7 +104,39 @@ module BlackStack
101
104
 
102
105
  return lnuser
103
106
  end # getLnUser()
107
+
108
+ #
109
+ def notifyInbox(lnuser, conv)
110
+ conv[:chats].each { |chat|
111
+ # armo URL de notificacion
112
+ # se usa URI.encode para codificar caracteres no-ascii en los mensajes
113
+ url =
114
+ "#{BlackStack::Pampa::api_protocol}://#{self.ws_url}:#{self.ws_port}/api1.3/pampa/scrape.inbox/notify_lnchat.json?" +
115
+ "api_key=#{BlackStack::Pampa::api_key}&" +
116
+ "profile_code=#{URI.escape(conv[:profile_code])}&" +
117
+ "profile_name=#{URI.escape(conv[:profile_name])}&" +
118
+ "profile_headline=#{URI.escape(conv[:profile_headline])}&" +
119
+ "first=#{URI.escape(conv[:first])}&" +
120
+ "position=#{chat[:position].to_s}&" +
121
+ "uid=#{lnuser['id']}&" +
122
+ "sender_name=#{URI.escape(chat[:sender_name])}&" +
123
+ "body=#{URI.escape(chat[:body])}&"
124
+ puts ""
125
+ puts "url:#{url}:."
126
+ puts ""
127
+ # HELP: File.open('./output3.txt', 'a') { |file| file.write(url + "\r\n") }
104
128
 
129
+ # push the chat
130
+ uri = URI.parse(url.to_s)
131
+ req = Net::HTTP::Get.new(uri.to_s)
132
+ res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|
133
+ http.request(req)
134
+ }
135
+ parsed = JSON.parse(res.body)
136
+ raise "error uploading chat: #{parsed['status']}" if parsed['status'] != 'success'
137
+ } # conv[:chats].each
138
+ end
139
+
105
140
  #
106
141
  def notifyLnUserUrl(id_lnuser, profile_url)
107
142
  nTries = 0
@@ -199,7 +199,7 @@ module BlackStack
199
199
  # se notifica al dispatcher de la division
200
200
  def notify()
201
201
  if (self.ws_url==nil || self.ws_port==nil)
202
- raise "Cannot notify. Worker has not parameters."
202
+ raise "Cannot notify. Worker not exists, or it has not parameters, or it is belong another client. Check your api_key, and check the name of the worker."
203
203
  end
204
204
 
205
205
  # me notifico a la division. obtengo trabajo
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pampa_workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2020-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket