stealth 0.9.4 → 0.9.5

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: a4af7e7416f2d060aa2f12b63ac3f94d256c6000
4
- data.tar.gz: 8958f75e6f6fedda6185b3558da250c94b9d6aeb
3
+ metadata.gz: f317db5c10b48f1bcc63be86f46c4a134b65cb5e
4
+ data.tar.gz: 060fd76828976b6d2548b34aca28b5c701e30b8d
5
5
  SHA512:
6
- metadata.gz: cd5de759d0da73005d9ccdb4a421365af1e4c33eb18ee69b6093b01747b9b6f73572c0d1eff67ad16d40afa247120c58f18bea9d56d4eefdcbef19be37a08995
7
- data.tar.gz: a9b5a1439ea011a42bdc34b08de36fd980f11211576c6d84a070dc0fb656cae199f38e10423996d45a0f943eae92a5b5cfa5a066b8d07c1fc34f42e248e208a0
6
+ metadata.gz: f297db3c34ae2ff00df6ce1d23253a83b8a4c74db1773fc26113baf54beb25d931bbc271eca8918706c966773deb4d6a059c4c44ea8b1744e1a21e6b05cca4eb
7
+ data.tar.gz: 16121b80352c65529cb71da25048130e8a3d8b2420be44ad261400db96a41b288f1cd2a71594eec62254b8910a19311318f576dcd0aaa1cf320396dbe688589f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.4
1
+ 0.9.5
@@ -145,7 +145,13 @@ module Stealth
145
145
  end
146
146
 
147
147
  def action_replies
148
- File.read(File.join(Stealth.root, 'bot', 'replies', replies_folder, "#{current_session.state_string}.yml"))
148
+ reply_file_path = File.join(Stealth.root, 'bot', 'replies', replies_folder, "#{current_session.state_string}.yml")
149
+
150
+ begin
151
+ File.read(reply_file_path)
152
+ rescue Errno::ENOENT
153
+ raise(Stealth::Errors::ReplyNotFound, "Could not find a reply in #{reply_file_path}.")
154
+ end
149
155
  end
150
156
 
151
157
  def update_session(flow:, state:)
@@ -28,5 +28,8 @@ module Stealth
28
28
  class InvalidStateTransition < Errors
29
29
  end
30
30
 
31
+ class ReplyNotFound < Errors
32
+ end
33
+
31
34
  end
32
35
  end
@@ -28,6 +28,31 @@ module Stealth
28
28
  Stealth::Logger.l(topic: "facebook", message: "Transmitting. Response: #{response.status}: #{response.body}")
29
29
  end
30
30
 
31
+ def self.fetch_profile(recipient_id:, fields: nil)
32
+ if fields.blank?
33
+ fields = [:first_name, :last_name, :profile_pic, :locale, :timezone, :gender, :is_payment_enabled, :last_ad_referral]
34
+ end
35
+
36
+ query_hash ={
37
+ fields: fields.join(','),
38
+ access_token: Stealth.config.facebook.page_access_token
39
+ }
40
+
41
+ uri = URI::HTTPS.build(
42
+ host: "graph.facebook.com",
43
+ path: "/v2.10/#{recipient_id}",
44
+ query: query_hash.to_query
45
+ )
46
+
47
+ response = Faraday.get(uri.to_s)
48
+ Stealth::Logger.l(topic: "facebook", message: "Requested user profile for #{recipient_id}. Response: #{response.status}: #{response.body}")
49
+
50
+ if response.status.in?(200..299)
51
+ MultiJson.load(response.body)
52
+ else
53
+ false
54
+ end
55
+ end
31
56
  end
32
57
 
33
58
  end
@@ -53,7 +53,7 @@ module Stealth
53
53
  def set(flow:, state:)
54
54
  @session = canonical_session_slug(flow: flow, state: state)
55
55
  flow
56
- $redis.set(user_id, canonical_session_slug(flow: flow, state: state))
56
+ $redis.set(user_id, session)
57
57
  end
58
58
 
59
59
  def present?
data/stealth.gemspec CHANGED
@@ -7,21 +7,22 @@ Gem::Specification.new do |s|
7
7
  s.summary = 'Ruby framework for conversational bots'
8
8
  s.description = 'Ruby framework for building conversational bots.'
9
9
  s.homepage = 'https://github.com/whoisblackops/stealth'
10
+ s.licenses = ['MIT']
10
11
  s.version = version
11
12
  s.author = 'Mauricio Gomes'
12
13
  s.email = 'mauricio@edge14.com'
13
14
 
14
- s.add_dependency 'sinatra', '~> 2.0.0'
15
- s.add_dependency 'puma', '~> 3.10.0'
15
+ s.add_dependency 'sinatra', '~> 2.0'
16
+ s.add_dependency 'puma', '~> 3.10'
16
17
  s.add_dependency 'thor', '~> 0.20'
17
18
  s.add_dependency 'multi_json', '~> 1.12'
18
19
  s.add_dependency 'faraday', '~> 0.13'
19
20
  s.add_dependency 'sidekiq', '~> 5.0'
20
21
  s.add_dependency 'activesupport', '~> 5.1'
21
22
 
22
- s.add_development_dependency 'rspec', '~> 3.6.0'
23
- s.add_development_dependency 'rspec_junit_formatter', '~> 0.3.0'
24
- s.add_development_dependency 'rack-test', '~> 0.7.0'
23
+ s.add_development_dependency 'rspec', '~> 3.6'
24
+ s.add_development_dependency 'rspec_junit_formatter', '~> 0.3'
25
+ s.add_development_dependency 'rack-test', '~> 0.7'
25
26
 
26
27
  s.files = `git ls-files`.split("\n")
27
28
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
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.9.4
4
+ version: 0.9.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: 2017-11-03 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: puma
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.10.0
33
+ version: '3.10'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.10.0
40
+ version: '3.10'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,42 +114,42 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 3.6.0
117
+ version: '3.6'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 3.6.0
124
+ version: '3.6'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec_junit_formatter
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.3.0
131
+ version: '0.3'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.3.0
138
+ version: '0.3'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rack-test
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.7.0
145
+ version: '0.7'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.7.0
152
+ version: '0.7'
153
153
  description: Ruby framework for building conversational bots.
154
154
  email: mauricio@edge14.com
155
155
  executables:
@@ -213,7 +213,8 @@ files:
213
213
  - spec/version_spec.rb
214
214
  - stealth.gemspec
215
215
  homepage: https://github.com/whoisblackops/stealth
216
- licenses: []
216
+ licenses:
217
+ - MIT
217
218
  metadata: {}
218
219
  post_install_message:
219
220
  rdoc_options: []