nextbot 1.1.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 70e9fbd4ee4362ea15d63134821b67174eb820f5
4
+ data.tar.gz: fc2d361323b2053a0aee057c0f81ddb216a24b5b
5
+ SHA512:
6
+ metadata.gz: a0271020486fa8ddb7f6e1d7570d2e495f082c9b8de936d225f65aef6a765ae9391406e9651d960e54645bde12766ade239c9c5b98bd56188fa4dbadd484580f
7
+ data.tar.gz: 469f425bdd7625daf0a308e2a07d7220243bbeb837dd009a9f4a5088b3f5aa365c9ef40ba6b0a10f40d8db3f2a64a551ac17a3f97534ab20acacf0ec9c8cd047
@@ -0,0 +1,60 @@
1
+ module BlackStack
2
+ module NextBot
3
+ # This is the base model class.
4
+ # From this class will inherit two classes:
5
+ #
6
+ # => The "local" (or persistance class) that
7
+ # => will load, update and create records in
8
+ # => the database.
9
+ #
10
+ # => The "remote" (or API class) that will
11
+ # => be receive the data from an API call.
12
+ #
13
+ class BaseCommand
14
+ TYPE_START = 100 # start browser. params: username
15
+ TYPE_LOGIN = 110 # login to account. param: social_media (LinkedIn, Facebook, Twitter)
16
+ TYPE_GOTO = 120 # param: url
17
+ #TYPE_FIND = 1
18
+ #TYPE_MOUSE = 2
19
+ #TYPE_WRITE = 3
20
+ #TYPE_DELAY = 4
21
+ #TYPE_CALL = 5
22
+ #TYPE_IF = 6
23
+ #TYPE_EXISTS = 7
24
+ #TYPE_EACH = 8
25
+ TYPE_CLOSE = 999 # close browser. params: n/a
26
+
27
+ def self.types()
28
+ [
29
+ TYPE_START,
30
+ TYPE_LOGIN,
31
+ TYPE_GOTO,
32
+ #TYPE_FIND,
33
+ #TYPE_MOUSE,
34
+ #TYPE_WRITE,
35
+ #TYPE_DELAY,
36
+ #TYPE_CALL,
37
+ #TYPE_IF,
38
+ #TYPE_EXISTS,
39
+ #TYPE_EACH,
40
+ TYPE_CLOSE,
41
+ ]
42
+ end # self.types
43
+
44
+ def self.typeDescription(n)
45
+ return "goto" if n == TYPE_START
46
+ return "login" if n == TYPE_LOGIN
47
+ return "goto" if n == TYPE_GOTO
48
+ #return "find" if n == TYPE_FIND
49
+ #return "mouse" if n == TYPE_MOUSE
50
+ #return "write" if n == TYPE_WRITE
51
+ #return "delay" if n == TYPE_DELAY
52
+ #return "call" if n == TYPE_CALL
53
+ #return "if" if n == TYPE_IF
54
+ #return "exists" if n == TYPE_EXISTS
55
+ #return "each" if n == TYPE_EACH
56
+ return "close" if n == TYPE_CLOSE
57
+ end # self.typeDescription
58
+ end # class BaseCommand
59
+ end # module NextBot
60
+ end # module BlackStack
@@ -0,0 +1,57 @@
1
+ require_relative './basestep'
2
+
3
+ module BlackStack
4
+ module NextBot
5
+
6
+ # The "local" (or persistance class) that
7
+ # will load, update and create records in
8
+ # the database.
9
+ class Command < Sequel::Model(:nbcommand)
10
+ include BaseCommand
11
+ Command.dataset = Command.dataset.disable_insert_output
12
+
13
+ # load the next command to be performed by a certain worker.
14
+ def self.load_next(id_worker)
15
+ row = DB[
16
+ "SELECT c.id
17
+ FROM nbcommand c WITH (NOLOCK)
18
+ WHERE c.id_worker = '#{id_worker}'
19
+ AND c.run_end_time IS NULL
20
+ ORDER BY c.create_time ASC"
21
+ ].first
22
+ return nil if row.nil?
23
+ return BlackStack::NextBot::Command.where(:id => row[:id]).first if !row.nil?
24
+ end # def load_next
25
+
26
+ # update the start time of the command.
27
+ def start()
28
+ self.run_start_time = now()
29
+ self.save
30
+ end
31
+
32
+ # update the end time, success flag and error description of the command.
33
+ def end(success=true, error_description=nil)
34
+ self.run_end_time = now()
35
+ self.run_success = success
36
+ self.run_error_description = error_description
37
+ self.save
38
+ end
39
+
40
+ # return a hash descriptor of this object,
41
+ # in order to send it to a remote process
42
+ # as a response to an API call.
43
+ def to_hash()
44
+ ret = {}
45
+ ret[:id] = self.id.to_guid
46
+ ret[:id_worker] = self.id_worker.to_guid
47
+ ret[:type] = self.type
48
+ ret[:param_start_username] = self.param_start_username
49
+ ret[:param_login_id_domain] = self.param_login_id_domain.nil? ? nil : self.param_login_id_domain.to_guid
50
+ ret[:param_goto_url] = self.param_goto_url
51
+ return ret
52
+ end
53
+
54
+ end # class Command
55
+
56
+ end # module NextBot
57
+ end # module BlackStack
@@ -0,0 +1,15 @@
1
+ module BlackStack
2
+ module NextBot
3
+ # The "remote" (or API class) that will
4
+ # be receive the data from an API call.
5
+ class BaseRemoteObject
6
+ attr_accessor :descriptor
7
+ # Attributes initialization from a hash descritor.
8
+ # This base method will map the "h" parameter to the "descriptor" attribute,
9
+ # => in order to keep a copy of it.
10
+ def build(h)
11
+ self.descriptor = h.clone
12
+ end
13
+ end # class BaseRemoteObject
14
+ end # module NextBot
15
+ end # module BlackStack
@@ -0,0 +1,200 @@
1
+ require_relative './remotebaseobject'
2
+ require_relative './basecommand'
3
+
4
+ module BlackStack
5
+ module NextBot
6
+ # The "remote" (or API class) that will
7
+ # be receive the data from an API call.
8
+ class RemoteCommand < RemoteNightBotobject
9
+ include BaseCommand
10
+
11
+ # :browser: is the browser where the bot will operate.
12
+ attr_accessor :browser
13
+
14
+ # :id is the ID of the record in the "routine" table.
15
+ # :params is an array of RemoteParam objects.
16
+ # :steps is an array of RemoteSteps objects.
17
+ attr_accessor :id, :id_worker, :type, :param_start_username, :param_login_id_domain, :param_goto_url
18
+
19
+ # generate all the hierarchy of the bot (routines, steps,
20
+ # => params) from a hash descriptor.
21
+ def build(h)
22
+ super(h)
23
+ self.id = h[:id]
24
+ self.id_worker = h[:id_worker]
25
+ self.type = h[:type]
26
+ # start command params
27
+ self.param_start_username = h[:param_start_username]
28
+ # login command params
29
+ self.param_login_id_domain = h[:param_login_id_domain]
30
+ # goto command params
31
+ self.param_goto_url = h[:param_goto_url]
32
+ # TODO: map here all the other attributes of the record in the "command" table,
33
+ # regarding every one of the possible "type" of steps.
34
+ end
35
+
36
+ # based on the "type" attribute, create an instance of the
37
+ # => regarding child class, to invoke the "run" method of
38
+ # => such child class.
39
+ def create_child()
40
+ return RemoteStepStart.new(self.browser).build(self.descritor) if self.type == TYPE_START
41
+ return RemoteStepLogin.new(self.browser).build(self.descritor) if self.type == TYPE_LOGIN
42
+ return RemoteStepGoto.new(self.browser).build(self.descritor) if self.type == TYPE_GOTO
43
+ #return RemoteStepFind.new(self.browser).build(self.descritor) if self.type == TYPE_FIND
44
+ #return RemoteStepMouse.new(self.browser).build(self.descritor) if self.type == TYPE_MOUSE
45
+ #return RemoteStepWrite.new(self.browser).build(self.descritor) if self.type == TYPE_WRITE
46
+ #return RemoteStepDelay.new(self.browser).build(self.descritor) if self.type == TYPE_DELAY
47
+ #return RemoteStepCall.new(self.browser).build(self.descritor) if self.type == TYPE_CALL
48
+ #return RemoteStepIf.new(self.browser).build(self.descritor) if self.type == TYPE_IF
49
+ #return RemoteStepExists.new(self.browser).build(self.descritor) if self.type == TYPE_EXISTS
50
+ #return RemoteStepEach.new(self.browser).build(self.descritor) if self.type == TYPE_EACH
51
+ return RemoteStepClose.new(self.browser).build(self.descritor) if self.type == TYPE_CLOSE
52
+ end
53
+
54
+ # browser: is a browser created from the BrowserFactory class.
55
+ def initialize(the_browser=nil)
56
+ self.browser = the_browser
57
+ end
58
+
59
+ # run the specified operation for this "type" of "step"
60
+ def run()
61
+ raise 'This is an abstract method. Each child of the RemoteStep class will code its own "run" method.'
62
+ end
63
+ end # class RemoteStep
64
+
65
+
66
+ ##################################################################################
67
+ ### RemoteStepStart
68
+ ##################################################################################
69
+ class RemoteStepStart < RemoteStep
70
+ # run the specified operation for this "type" of "step"
71
+ def run()
72
+ # TODO: Code Me!
73
+ end
74
+ end # RemoteStepGoto
75
+
76
+
77
+ ##################################################################################
78
+ ### RemoteStepLogin
79
+ ### TODO: deprecate this, and replace for a procedure, once the project is full done.
80
+ ##################################################################################
81
+ class RemoteStepLogin < RemoteStep
82
+ # run the specified operation for this "type" of "step"
83
+ def run()
84
+ # TODO: Code Me!
85
+ end
86
+ end # RemoteStepGoto
87
+
88
+
89
+ ##################################################################################
90
+ ### RemoteStepGoto
91
+ ##################################################################################
92
+ class RemoteStepGoto < RemoteStep
93
+ # run the specified operation for this "type" of "step"
94
+ def run()
95
+ # TODO: Code Me!
96
+ end
97
+ end # RemoteStepGoto
98
+
99
+ # TODO: develop these steps
100
+ =begin
101
+ ##################################################################################
102
+ ### RemoteStepFind
103
+ ##################################################################################
104
+ class RemoteStepFind < RemoteStep
105
+ # run the specified operation for this "type" of "step"
106
+ def run()
107
+ # TODO: Code Me!
108
+ end
109
+ end # RemoteStepFind
110
+
111
+
112
+ ##################################################################################
113
+ ### RemoteStepMouse
114
+ ##################################################################################
115
+ class RemoteStepMouse < RemoteStep
116
+ # run the specified operation for this "type" of "step"
117
+ def run()
118
+ # TODO: Code Me!
119
+ end
120
+ end # RemoteStepMouse
121
+
122
+
123
+ ##################################################################################
124
+ ### RemoteStepWrite
125
+ ##################################################################################
126
+ class RemoteStepWrite < RemoteStep
127
+ # run the specified operation for this "type" of "step"
128
+ def run()
129
+ # TODO: Code Me!
130
+ end
131
+ end # RemoteStepWrite
132
+
133
+
134
+ ##################################################################################
135
+ ### RemoteStepDelay
136
+ ##################################################################################
137
+ class RemoteStepDelay < RemoteStep
138
+ # run the specified operation for this "type" of "step"
139
+ def run()
140
+ # TODO: Code Me!
141
+ end
142
+ end # RemoteStepDelay
143
+
144
+
145
+ ##################################################################################
146
+ ### RemoteStepCall
147
+ ##################################################################################
148
+ class RemoteStepCall < RemoteStep
149
+ # run the specified operation for this "type" of "step"
150
+ def run()
151
+ # TODO: Code Me!
152
+ end
153
+ end # RemoteStepCall
154
+
155
+
156
+ ##################################################################################
157
+ ### RemoteStepIf
158
+ ##################################################################################
159
+ class RemoteStepIf < RemoteStep
160
+ # run the specified operation for this "type" of "step"
161
+ def run()
162
+ # TODO: Code Me!
163
+ end
164
+ end # RemoteStepIf
165
+
166
+
167
+ ##################################################################################
168
+ ### RemoteStepExists
169
+ ##################################################################################
170
+ class RemoteStepExists < RemoteStep
171
+ # run the specified operation for this "type" of "step"
172
+ def run()
173
+ # TODO: Code Me!
174
+ end
175
+ end # RemoteStepExists
176
+
177
+
178
+ ##################################################################################
179
+ ### RemoteStepEach
180
+ ##################################################################################
181
+ class RemoteStepEach < RemoteStep
182
+ # run the specified operation for this "type" of "step"
183
+ def run()
184
+ # TODO: Code Me!
185
+ end
186
+ end # RemoteStepEach
187
+ =end
188
+
189
+ ##################################################################################
190
+ ### RemoteStepClose
191
+ ##################################################################################
192
+ class RemoteStepClose < RemoteStep
193
+ # run the specified operation for this "type" of "step"
194
+ def run()
195
+ # TODO: Code Me!
196
+ end
197
+ end # RemoteStepGoto
198
+
199
+ end # module NextBot
200
+ end # module BlackStack
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nextbot
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Leandro Daniel Sardi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: stealth_browser_automation
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.19
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.1.19
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 1.1.19
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.19
33
+ description: 'THIS GEM IS STILL IN DEVELOPMENT STAGE. Find documentation here: https://github.com/leandrosardi/nextbot.'
34
+ email: leandro.sardi@expandedventure.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - lib/basecommand.rb
40
+ - lib/localcommand.rb
41
+ - lib/remotebaseobject.rb
42
+ - lib/remotecommand.rb
43
+ homepage: https://rubygems.org/gems/simple_cloud_logging
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.4.5.1
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: THIS GEM IS STILL IN DEVELOPMENT STAGE. Easy library to write log files in
67
+ the cloud, watch them anywhere, and enbed the log in any website. The remote-logging
68
+ feature is still being written.
69
+ test_files: []