botbase-module-conversation 0.1.0 → 0.1.1

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: 8d005c23c51d8e6f3ba761e6e8881c8d6f71a776
4
- data.tar.gz: f863b3723552bee5ae56828d59986214074044c6
3
+ metadata.gz: 58c5a7e0e92a26c17b8cc3a67ec03438b9dd9243
4
+ data.tar.gz: aa756f08fa8a8fbd1cd4187993e277388252c565
5
5
  SHA512:
6
- metadata.gz: 74afc40363e091f8a68b067e5f0a72a7aa9ce3918e55fb43a0a51ec7bb022a042248a75a30d1f540d6972b94e961064c7867c72dbe0685e4b7e02da93958072e
7
- data.tar.gz: dbba3f5836ada48b5cc47dda85bd3c2e5419e2d9d0e88329a8cc739992a0f495670d07f2044b5044c5941e7dbd36277d01c42cce38d14ea42ec09b4c735716ce
6
+ metadata.gz: b4a1b69a481e570575a4c0f6ef65c255a96c005297c2159d4f56a996736c22cb6c3febb0806ddf826e25965900c7f9e1d212a32a4bff0904d0a460d79891eda1
7
+ data.tar.gz: 19d3cbc7d8013da1bb69224da8900b5a4808abdd415b61318d36deec8512ccbec0848c8042dca5f976ab7fe980a12f89b428fdc7dcb6134e12a07337f50870ae
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -19,19 +19,9 @@ class BotBaseModuleConversation
19
19
 
20
20
  a = run(default_package, default_job)
21
21
 
22
- header = a.shift
22
+ @doc = Rexle.new("<conversations></conversations>")
23
23
 
24
- a2 = a.inject([]) do |r, x|
25
- r << {conversation: {user: x[0], bot: x[-1]}}
26
- end
27
-
28
- a3 = RexleBuilder.new({converstions: a2}).to_a
29
- doc = Rexle.new(a3[3])
30
- doc.root.attributes['id'] = header.first
31
-
32
- @phrases = doc.root.xpath('//conversation').map do |e|
33
- %w(user bot).map {|x| e.text x}
34
- end
24
+ add_phrases(a)
35
25
 
36
26
  end
37
27
 
@@ -44,6 +34,12 @@ class BotBaseModuleConversation
44
34
  package, job = found.last.split
45
35
  h = said.match(/#{found.first}/).named_captures
46
36
  r = run(package, job)
37
+
38
+ if r.is_a? String then
39
+ r
40
+ elsif r.is_a? Array then
41
+ add_phrases(r)
42
+ end
47
43
  else
48
44
  # do or say nothing
49
45
  ''
@@ -53,8 +49,31 @@ class BotBaseModuleConversation
53
49
 
54
50
  private
55
51
 
52
+ def add_phrases(a)
53
+
54
+ header = a.shift
55
+ id, answer = header
56
+
57
+ @doc.root.delete "conversations[@id='#{id}']"
58
+
59
+ a2 = a.inject([]) do |r, x|
60
+ r << {conversation: {user: x[0], bot: x[-1]}}
61
+ end
62
+
63
+ a3 = RexleBuilder.new({converstions: a2}).to_a
64
+ doc = Rexle.new(a3[3])
65
+ doc.root.attributes['id'] = id
66
+ @doc.root.add_element doc.root
67
+
68
+ @phrases = @doc.root.xpath('//conversation').map do |e|
69
+ %w(user bot).map {|x| e.text x}
70
+ end
71
+
72
+ answer
73
+ end
74
+
56
75
  def run(package, job, args=[])
57
76
  @rsc.send(package.to_sym).method(job.to_sym).call(*args)
58
77
  end
59
78
 
60
- end
79
+ 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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file