botbase-module-conversation 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -3
- data/lib/botbase-module-conversation.rb +35 -6
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8e722a09208c107d7b529ccd946eee40fad20b5
|
4
|
+
data.tar.gz: 3233c4afb74edde3eda28e0809dce9cbdce89787
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d68545eccce97a8d3fccbe1081f78ac8c866e96c1e2fbadbe841f172029c1617b0bfa6c038ddf3e2d225ff7bdc6ca2bad8b87cffa11193204ab1074778230ea
|
7
|
+
data.tar.gz: 482c5b8c04fbfff8e3329619b9c6966bb4b8706c62acb83ff7050d6ebc8ca7c0e5154910a385f5ba96cc6aea33cc45bf30821457fa48eefaf0c9d968406dd627
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
<���#�t%B�M�Q�;�6��j��6�G�����'��
|
2
|
+
T�"F~:�#�G��t����ȉ+�]]{��Ѣ�c�Mhu^eR喨��[���d���EE%o�(3����}��@!�UUV����\�@�p+����˕A:dQK/t�=>� \�J��dX͐T�s��p�=��C��q����9dT���#��~�u��A�3�����&���e��� ������81��ݣK���n�\�H
|
3
|
+
�H�- `T�
|
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
require 'rsc'
|
9
|
+
require 'json'
|
9
10
|
require 'rexle-builder'
|
10
11
|
|
11
12
|
|
@@ -33,20 +34,41 @@ class BotBaseModuleConversation
|
|
33
34
|
|
34
35
|
if @bot.log then
|
35
36
|
@bot.log.info "BotBaseModuleConversation/query:" +
|
36
|
-
" found %s in response to %s" % [found
|
37
|
+
" found %s in response to %s" % [found.inspect, said]
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
+
_, rsc_command, context_tags = found
|
41
|
+
package, job = rsc_command.split
|
40
42
|
|
41
43
|
h = said.match(/#{found.first}/i).named_captures
|
42
44
|
r = run(package, job, h)
|
43
45
|
|
44
|
-
|
46
|
+
a, tags = [], []
|
47
|
+
|
48
|
+
a << if r.is_a? String then
|
45
49
|
r
|
50
|
+
elsif r.is_a? Hash then
|
51
|
+
|
52
|
+
if r[:msg] then
|
53
|
+
tags.concat r[:tags].split
|
54
|
+
r[:msg]
|
55
|
+
else
|
56
|
+
r
|
57
|
+
end
|
58
|
+
|
46
59
|
elsif r.is_a? Array then
|
47
|
-
add_phrases(r)
|
60
|
+
add_phrases(r)
|
48
61
|
end
|
49
62
|
|
63
|
+
tags.concat context_tags.split if context_tags
|
64
|
+
a << tags
|
65
|
+
|
66
|
+
if @bot.log then
|
67
|
+
@bot.log.info "BotBaseModuleConversation/query/result:" +
|
68
|
+
" result %s in response to %s" % [a.to_json, said]
|
69
|
+
end
|
70
|
+
a.first
|
71
|
+
|
50
72
|
else
|
51
73
|
no_match_found()
|
52
74
|
end
|
@@ -70,7 +92,7 @@ class BotBaseModuleConversation
|
|
70
92
|
@doc.root.delete "conversations[@id='#{id}']"
|
71
93
|
|
72
94
|
a2 = a.inject([]) do |r, x|
|
73
|
-
r << {conversation: {user: x[0], bot: x[
|
95
|
+
r << {conversation: {user: x[0], bot: x[1], tags: x[2]}}
|
74
96
|
end
|
75
97
|
|
76
98
|
a3 = RexleBuilder.new({converstions: a2}).to_a
|
@@ -79,14 +101,21 @@ class BotBaseModuleConversation
|
|
79
101
|
@doc.root.add_element doc.root
|
80
102
|
|
81
103
|
@phrases = @doc.root.xpath('//conversation').map do |e|
|
82
|
-
%w(user bot).map {|x| e.text x}
|
104
|
+
%w(user bot tags).map {|x| e.text x}
|
83
105
|
end
|
84
106
|
|
85
107
|
answer
|
86
108
|
end
|
87
109
|
|
88
110
|
def run(package, job, h={})
|
111
|
+
|
112
|
+
if @bot.log then
|
113
|
+
@bot.log.info "BotBaseModuleConversation/run: " +
|
114
|
+
"package: %s, method: %s, args: %s" % [package, job, h.inspect]
|
115
|
+
end
|
116
|
+
|
89
117
|
@rsc.send(package.to_sym).method(job.to_sym).call(h)
|
118
|
+
|
90
119
|
end
|
91
120
|
|
92
121
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: botbase-module-conversation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
aNO/RQYUa1Pqx9RMIGgZIeQPtuaxxfqQ6uiq/S5GWoIKIDOmES69g981bASbOtYs
|
32
32
|
geN7Uzk3bTsKxA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-
|
34
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rsc
|
metadata.gz.sig
CHANGED
Binary file
|