alexa_utteranceresponder 0.1.2 → 0.2.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +4 -2
- data.tar.gz.sig +0 -0
- data/lib/alexa_utteranceresponder.rb +54 -9
- metadata +16 -16
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7e2b3e32e4ecb1beee2ddcd23b83107ce68dbff96cf5f2b4c90f04672a88b26
|
4
|
+
data.tar.gz: cf01e0f9c144efc72ccd44800d41534463cc46b4135446788a2f0343f79530d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9c2d08973e1bef53c65451a083df94e179820cac58c758a420a047e0a818347f329cdd77f7adb516af82a4412468fe10bd1a21a75a581ceae775e5f3b607aaa
|
7
|
+
data.tar.gz: e41a3a2c70ae551e2cd7333074ba9d8ed734bd2338c593ee3d0079f1722fe1b55c71a5e8d7e562b5d356c778bbec94918e52edecd7ed1a6c1c2cf039700b0631
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
s�
|
2
|
+
�6������L���=
|
3
|
+
��2t���;�ߴ�D������nC���`� �!G���N����aw�J������(�illK�56�h��ȃ�Y�`�v�Fu�b50~� �=����@N�zA��p����y�ũ� ��u�B37I�w��ڊ�:b5ʾ4K���}z����r�=YBW�bD�>,�6+%= �l���oQ��_fL�����H�&�_kEw��d|���}p����&��u-���Vz�n�u,�ϴ����G�=�
|
4
|
+
��U���а��m���Y�__�A�7 w�f�k1ȧ��Քv@���&�%UP��|5�S��\�U���
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -16,25 +16,53 @@ class AlexaUtteranceResponder
|
|
16
16
|
attr_reader :invocation
|
17
17
|
attr_accessor :deviceid
|
18
18
|
|
19
|
-
def initialize(modelmds=[],
|
19
|
+
def initialize(modelmds=[], reg: nil, debug: false,
|
20
|
+
userid: nil, deviceid: nil)
|
20
21
|
|
21
|
-
@debug, @userid, @deviceid = debug, userid, deviceid
|
22
|
+
@reg, @debug, @userid, @deviceid = reg, debug, userid, deviceid
|
22
23
|
|
23
24
|
@models = modelmds.inject({}) do |r,x|
|
24
25
|
|
25
26
|
amb = AlexaModelBuilder.new(x)
|
26
27
|
r.merge(amb.invocation || amb.name => amb)
|
27
28
|
|
28
|
-
end
|
29
|
+
end
|
30
|
+
|
29
31
|
|
30
32
|
end
|
31
33
|
|
32
|
-
def ask(s, deviceid: @deviceid, &blk)
|
34
|
+
def ask(s, userid: @userid, deviceid: @deviceid, &blk)
|
33
35
|
|
34
36
|
puts
|
35
37
|
puts ' debugger: s: ' + s.inspect if @debug
|
36
38
|
|
37
|
-
|
39
|
+
active = if @reg then
|
40
|
+
|
41
|
+
puts 'reg available'.info if @debug
|
42
|
+
|
43
|
+
e = @reg.get_key 'hkey_apps/alexa/accounts'
|
44
|
+
euserid = e.xpath('*/id').find {|x| x.text.to_s == userid}
|
45
|
+
puts 'euserid: ' + euserid.text.inspect if @debug
|
46
|
+
|
47
|
+
if euserid then
|
48
|
+
|
49
|
+
eactive = euserid.parent.text('active')
|
50
|
+
puts 'eactive: ' + eactive.to_s.inspect if @debug
|
51
|
+
|
52
|
+
if eactive then
|
53
|
+
eactive.to_s.split
|
54
|
+
else
|
55
|
+
user = euserid.parent.name
|
56
|
+
@reg.set_key "hkey_apps/alexa/accounts/#{user}/active", @models.keys.join(' ')
|
57
|
+
@models.keys
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
else
|
62
|
+
@models.keys
|
63
|
+
end
|
64
|
+
|
65
|
+
invocations = active.map {|invocation| invocation.gsub(/ /,'\s') }\
|
38
66
|
.join('|')
|
39
67
|
puts 'invocations: ' + invocations.inspect if @debug
|
40
68
|
|
@@ -48,7 +76,7 @@ class AlexaUtteranceResponder
|
|
48
76
|
r2 = s.downcase.gsub(/,/,'').match(regex)
|
49
77
|
|
50
78
|
puts ' debugger: r2: ' + r2.inspect if @debug
|
51
|
-
puts
|
79
|
+
puts
|
52
80
|
|
53
81
|
model_id = if r2 then
|
54
82
|
return respond() if r2[:action] == 'open'
|
@@ -58,13 +86,16 @@ class AlexaUtteranceResponder
|
|
58
86
|
puts 'searching all utterances'.info if @debug
|
59
87
|
puts ('s: ' + s.inspect).debug if @debug
|
60
88
|
|
89
|
+
|
61
90
|
# attempt to find the request from utterances in all skills
|
62
|
-
|
91
|
+
active.detect do |name|
|
92
|
+
|
93
|
+
model = @models[name]
|
63
94
|
puts 'utterances: ' + model.utterances.map(&:downcase).inspect if @debug
|
64
95
|
model.utterances.map(&:downcase).include? s
|
96
|
+
|
65
97
|
end
|
66
|
-
|
67
|
-
id, _ = found[0] if found
|
98
|
+
|
68
99
|
end
|
69
100
|
|
70
101
|
return "hmmm, I don't know that one." unless model_id
|
@@ -85,5 +116,19 @@ class AlexaUtteranceResponder
|
|
85
116
|
r ? r : "I'm sorry I didn't understand what you said"
|
86
117
|
|
87
118
|
end
|
119
|
+
|
120
|
+
def sample_utterances()
|
121
|
+
|
122
|
+
@models.to_a.sample(3).map do |key, model|
|
123
|
+
|
124
|
+
if model.invocation then
|
125
|
+
"tell %s, %s" % [key.capitalize, model.utterances.sample.capitalize]
|
126
|
+
else
|
127
|
+
"%s" % [model.utterances.sample]
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
88
133
|
|
89
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexa_utteranceresponder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,48 +35,48 @@ cert_chain:
|
|
35
35
|
et+EBeqz/UE1cHo1UQJ46zhnSgmyJAzu7CkkRXvmAL/vpbmZMsnwwMHlqzNFUj3Y
|
36
36
|
B0fryIJrom9l8P6WHMK+0kWS
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-12-
|
38
|
+
date: 2019-12-25 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: askio
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0.1'
|
47
44
|
- - ">="
|
48
45
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
46
|
+
version: 0.2.0
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.2'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - "~>"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '0.1'
|
57
54
|
- - ">="
|
58
55
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.
|
56
|
+
version: 0.2.0
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.2'
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: alexa_modelbuilder
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 0.5.0
|
67
64
|
- - "~>"
|
68
65
|
- !ruby/object:Gem::Version
|
69
66
|
version: '0.5'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.5.2
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 0.5.0
|
77
74
|
- - "~>"
|
78
75
|
- !ruby/object:Gem::Version
|
79
76
|
version: '0.5'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.5.2
|
80
80
|
description:
|
81
81
|
email: james@jamesrobertson.eu
|
82
82
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|