stealth 0.10.4 → 0.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -8
- data/VERSION +1 -1
- data/lib/stealth/cli.rb +22 -0
- data/lib/stealth/generators/builder.rb +37 -0
- data/lib/stealth/generators/builder/Gemfile +12 -0
- data/lib/stealth/generators/builder/bot/controllers/bot_controller.rb +11 -0
- data/lib/stealth/generators/builder/bot/controllers/catch_alls_controller.rb +22 -0
- data/lib/stealth/generators/builder/bot/controllers/goodbyes_controller.rb +7 -0
- data/lib/stealth/generators/builder/bot/controllers/hellos_controller.rb +7 -0
- data/lib/stealth/generators/builder/bot/flow_map.rb.tt +17 -0
- data/lib/stealth/generators/builder/bot/helpers/bot_helper.rb +2 -0
- data/lib/stealth/generators/builder/bot/replies/catch_alls/catch_all.yml +0 -0
- data/lib/stealth/generators/builder/bot/replies/goodbyes/say_goodbye.yml +0 -0
- data/lib/stealth/generators/builder/bot/replies/hellos/say_hello.yml +2 -0
- data/lib/stealth/generators/builder/config.ru +4 -0
- data/lib/stealth/generators/builder/config/boot.rb +6 -0
- data/lib/stealth/generators/builder/config/environment.rb +4 -0
- data/lib/stealth/generators/builder/config/initializers/.keep +0 -0
- data/lib/stealth/generators/builder/config/puma.rb +10 -0
- data/lib/stealth/generators/builder/config/services.yml +36 -0
- data/lib/stealth/generators/builder/config/sidekiq.yml +3 -0
- data/lib/stealth/generators/builder/readme.md +1 -0
- data/lib/stealth/generators/generate.rb +37 -0
- data/lib/stealth/generators/generate/flow/controllers/controller.tt +26 -0
- data/lib/stealth/generators/generate/flow/helpers/helper.tt +2 -0
- data/lib/stealth/generators/generate/flow/replies/ask_reply.tt +9 -0
- data/lib/stealth/generators/generate/flow/replies/say_no_reply.tt +2 -0
- data/lib/stealth/generators/generate/flow/replies/say_yes_reply.tt +2 -0
- metadata +27 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e7a98ce4d22d1d86114ca6afd49c33886796f54ce19e65b82389e9329aafc5c
|
4
|
+
data.tar.gz: baf1faa70c99ceaa7ab0e74380986546ee4dd87a24b56a4e836ce2409176ae2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5959cb310d89fee9fdfabc3ffcba9834ff37e506d7b0353d6212c09c7fdc8c6a7c106e47282e136b8cc07c6b350a142091c150ef127e41c70f20d16ba02932a
|
7
|
+
data.tar.gz: 41bd4e035073d704df2d68e9993e007a85f89fb11a8f9d469bc2a20b4eabb3d030ff87a9350a48f86882dfdce5dee2d1eeefbed74695e0603a189feb2ab7d2bf
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stealth (0.10.
|
4
|
+
stealth (0.10.3)
|
5
5
|
activesupport (~> 5.2.0.rc1)
|
6
6
|
multi_json (~> 1.12)
|
7
7
|
puma (~> 3.10)
|
@@ -20,16 +20,16 @@ GEM
|
|
20
20
|
concurrent-ruby (1.0.5)
|
21
21
|
connection_pool (2.2.1)
|
22
22
|
diff-lcs (1.3)
|
23
|
-
i18n (0.9.
|
23
|
+
i18n (0.9.5)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
25
|
minitest (5.11.3)
|
26
26
|
mock_redis (0.17.3)
|
27
27
|
multi_json (1.13.1)
|
28
|
-
mustermann (1.0.
|
28
|
+
mustermann (1.0.2)
|
29
29
|
oj (3.3.6)
|
30
30
|
puma (3.11.2)
|
31
31
|
rack (2.0.3)
|
32
|
-
rack-protection (2.0.
|
32
|
+
rack-protection (2.0.1)
|
33
33
|
rack
|
34
34
|
rack-test (0.7.0)
|
35
35
|
rack (>= 1.0, < 3)
|
@@ -49,15 +49,15 @@ GEM
|
|
49
49
|
rspec-support (3.6.0)
|
50
50
|
rspec_junit_formatter (0.3.0)
|
51
51
|
rspec-core (>= 2, < 4, != 2.12.0)
|
52
|
-
sidekiq (5.1.
|
52
|
+
sidekiq (5.1.1)
|
53
53
|
concurrent-ruby (~> 1.0)
|
54
54
|
connection_pool (~> 2.2, >= 2.2.0)
|
55
55
|
rack-protection (>= 1.5.0)
|
56
|
-
redis (>= 3.3.
|
57
|
-
sinatra (2.0.
|
56
|
+
redis (>= 3.3.5, < 5)
|
57
|
+
sinatra (2.0.1)
|
58
58
|
mustermann (~> 1.0)
|
59
59
|
rack (~> 2.0)
|
60
|
-
rack-protection (= 2.0.
|
60
|
+
rack-protection (= 2.0.1)
|
61
61
|
tilt (~> 2.0)
|
62
62
|
thor (0.20.0)
|
63
63
|
thread_safe (0.3.6)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.5
|
data/lib/stealth/cli.rb
CHANGED
@@ -4,11 +4,33 @@
|
|
4
4
|
require 'thor'
|
5
5
|
require 'stealth/cli_base'
|
6
6
|
require 'stealth/commands/console'
|
7
|
+
require 'stealth/generators/builder'
|
8
|
+
require 'stealth/generators/generate'
|
7
9
|
|
8
10
|
module Stealth
|
9
11
|
class Cli < Thor
|
10
12
|
extend CliBase
|
11
13
|
|
14
|
+
desc 'new', 'Creates a new Stealth bot'
|
15
|
+
long_desc <<-EOS
|
16
|
+
`stealth new <name>` creates a new Stealth both with the given name.
|
17
|
+
|
18
|
+
$ > stealth new new_bot
|
19
|
+
EOS
|
20
|
+
def new(name)
|
21
|
+
Stealth::Generators::Builder.start([name])
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'generate', 'Generates scaffold Stealth files'
|
25
|
+
long_desc <<-EOS
|
26
|
+
`stealth generate <generator> <name>` generates scaffold Stealth files
|
27
|
+
|
28
|
+
$ > stealth generate flow quote
|
29
|
+
EOS
|
30
|
+
def generate(generator, name)
|
31
|
+
Stealth::Generators::Generate.start([generator, name])
|
32
|
+
end
|
33
|
+
|
12
34
|
desc 'version', 'Prints stealth version'
|
13
35
|
long_desc <<-EOS
|
14
36
|
`stealth version` prints the version of the bundled stealth gem.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'thor/group'
|
2
|
+
|
3
|
+
module Stealth
|
4
|
+
module Generators
|
5
|
+
class Builder < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
argument :name
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
File.dirname(__FILE__) + "/builder"
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_bot_directory
|
15
|
+
empty_directory(name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_bot_structure
|
19
|
+
# Bot Directory
|
20
|
+
directory('bot', "#{name}/bot")
|
21
|
+
|
22
|
+
# Config Directory
|
23
|
+
directory('config', "#{name}/config")
|
24
|
+
|
25
|
+
# Miscellaneous Files
|
26
|
+
copy_file "config.ru", "#{name}/config.ru"
|
27
|
+
copy_file "Gemfile", "#{name}/Gemfile"
|
28
|
+
copy_file "readme.md", "#{name}/readme.md"
|
29
|
+
end
|
30
|
+
|
31
|
+
def change_directory_bundle
|
32
|
+
puts run("cd #{name} && bundle install")
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
ruby '2.5.0'
|
4
|
+
|
5
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
6
|
+
gem 'stealth', '~> 0.10.0'
|
7
|
+
|
8
|
+
# Uncomment to enable the Stealth Facebook Driver
|
9
|
+
# gem 'stealth-facebook'
|
10
|
+
|
11
|
+
# Uncomment to enable the Stealth Twilio SMS Driver
|
12
|
+
# gem 'stealth-twilio'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CatchAllsController < BotController
|
2
|
+
|
3
|
+
def level1
|
4
|
+
send_replies
|
5
|
+
|
6
|
+
if previous_session_specifies_fails_to?
|
7
|
+
step_to flow: previous_session.flow_string, state: previous_state.to_s
|
8
|
+
else
|
9
|
+
step_to session: previous_session - 2.states
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def previous_session_specifies_fails_to?
|
15
|
+
previous_state.present?
|
16
|
+
end
|
17
|
+
|
18
|
+
def previous_state
|
19
|
+
previous_session.flow.current_state.fails_to
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
threads_count = ENV.fetch("STEALTH_MAX_THREADS") { 5 }.to_i
|
2
|
+
threads threads_count, threads_count
|
3
|
+
|
4
|
+
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
|
5
|
+
#
|
6
|
+
port ENV.fetch("PORT") { 3000 }
|
7
|
+
|
8
|
+
# Specifies the `environment` that Puma will run in.
|
9
|
+
#
|
10
|
+
environment ENV.fetch("STEALTH_ENV") { "development" }
|
@@ -0,0 +1,36 @@
|
|
1
|
+
default: &default
|
2
|
+
# ==========================================
|
3
|
+
# ===== Example Facebook Service Setup =====
|
4
|
+
# ==========================================
|
5
|
+
# facebook:
|
6
|
+
# verify_token: XXXFACEBOOK_VERIFY_TOKENXXX
|
7
|
+
# page_access_token: XXXFACEBOOK_ACCESS_TOKENXXX
|
8
|
+
# setup:
|
9
|
+
# greeting: # Greetings are broken up by locale
|
10
|
+
# - locale: default
|
11
|
+
# text: "Welcome to the Stealth bot 🤖"
|
12
|
+
# persistent_menu:
|
13
|
+
# - type: payload
|
14
|
+
# text: Main Menu
|
15
|
+
# payload: main_menu
|
16
|
+
# - type: url
|
17
|
+
# text: Visit our website
|
18
|
+
# url: https://example.com
|
19
|
+
# - type: call
|
20
|
+
# text: Call us
|
21
|
+
# payload: "+4155330000"
|
22
|
+
#
|
23
|
+
# ===========================================
|
24
|
+
# ======== Example SMS Service Setup ========
|
25
|
+
# ===========================================
|
26
|
+
# twilio:
|
27
|
+
# account_sid: XXXTWILIO_ACCOUNT_SIDXXX
|
28
|
+
# auth_token: XXXTWILIO_AUTH_TOKENXXX
|
29
|
+
# from_phone: +14155330000
|
30
|
+
|
31
|
+
production:
|
32
|
+
<<: *default
|
33
|
+
development:
|
34
|
+
<<: *default
|
35
|
+
test:
|
36
|
+
<<: *default
|
@@ -0,0 +1 @@
|
|
1
|
+
# Stealth Bot Framework
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'thor/group'
|
2
|
+
|
3
|
+
module Stealth
|
4
|
+
module Generators
|
5
|
+
class Generate < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
argument :generator
|
9
|
+
argument :name
|
10
|
+
|
11
|
+
def self.source_root
|
12
|
+
File.dirname(__FILE__) + "/generate/flow"
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_controller
|
16
|
+
template('controllers/controller.tt', "controllers/#{name.pluralize}_controller.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_replies
|
20
|
+
# Sample Ask Reply
|
21
|
+
template('replies/ask_reply.tt', "replies/#{name.pluralize}/ask_example.yml")
|
22
|
+
# Sample Say Replies
|
23
|
+
template('replies/say_yes_reply.tt', "replies/#{name.pluralize}/say_yes_example.yml")
|
24
|
+
template('replies/say_no_reply.tt', "replies/#{name.pluralize}/say_no_example.yml")
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_helper
|
28
|
+
template('helpers/helper.tt', "helpers/#{name}_helper.rb")
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit_flow_map
|
32
|
+
# TODO
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class <%= name.camelize.pluralize %>Controller < BotController
|
2
|
+
|
3
|
+
def ask_example
|
4
|
+
send_replies
|
5
|
+
update_session_to_next
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_example
|
9
|
+
if current_message.message == 'Yes'
|
10
|
+
step_to state: 'say_yes_example'
|
11
|
+
elsif current_message.message == 'No'
|
12
|
+
step_to state: 'say_no_example'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def say_yes_example
|
17
|
+
send_replies
|
18
|
+
update_session_to state: 'ask_example'
|
19
|
+
end
|
20
|
+
|
21
|
+
def say_no_example
|
22
|
+
send_replies
|
23
|
+
update_session_to state: 'ask_example'
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stealth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mauricio Gomes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -183,6 +183,31 @@ files:
|
|
183
183
|
- lib/stealth/flow/core_ext.rb
|
184
184
|
- lib/stealth/flow/specification.rb
|
185
185
|
- lib/stealth/flow/state.rb
|
186
|
+
- lib/stealth/generators/builder.rb
|
187
|
+
- lib/stealth/generators/builder/Gemfile
|
188
|
+
- lib/stealth/generators/builder/bot/controllers/bot_controller.rb
|
189
|
+
- lib/stealth/generators/builder/bot/controllers/catch_alls_controller.rb
|
190
|
+
- lib/stealth/generators/builder/bot/controllers/goodbyes_controller.rb
|
191
|
+
- lib/stealth/generators/builder/bot/controllers/hellos_controller.rb
|
192
|
+
- lib/stealth/generators/builder/bot/flow_map.rb.tt
|
193
|
+
- lib/stealth/generators/builder/bot/helpers/bot_helper.rb
|
194
|
+
- lib/stealth/generators/builder/bot/replies/catch_alls/catch_all.yml
|
195
|
+
- lib/stealth/generators/builder/bot/replies/goodbyes/say_goodbye.yml
|
196
|
+
- lib/stealth/generators/builder/bot/replies/hellos/say_hello.yml
|
197
|
+
- lib/stealth/generators/builder/config.ru
|
198
|
+
- lib/stealth/generators/builder/config/boot.rb
|
199
|
+
- lib/stealth/generators/builder/config/environment.rb
|
200
|
+
- lib/stealth/generators/builder/config/initializers/.keep
|
201
|
+
- lib/stealth/generators/builder/config/puma.rb
|
202
|
+
- lib/stealth/generators/builder/config/services.yml
|
203
|
+
- lib/stealth/generators/builder/config/sidekiq.yml
|
204
|
+
- lib/stealth/generators/builder/readme.md
|
205
|
+
- lib/stealth/generators/generate.rb
|
206
|
+
- lib/stealth/generators/generate/flow/controllers/controller.tt
|
207
|
+
- lib/stealth/generators/generate/flow/helpers/helper.tt
|
208
|
+
- lib/stealth/generators/generate/flow/replies/ask_reply.tt
|
209
|
+
- lib/stealth/generators/generate/flow/replies/say_no_reply.tt
|
210
|
+
- lib/stealth/generators/generate/flow/replies/say_yes_reply.tt
|
186
211
|
- lib/stealth/jobs.rb
|
187
212
|
- lib/stealth/logger.rb
|
188
213
|
- lib/stealth/reply.rb
|