tjplurk 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tjplurk/robot/topic.rb +1 -1
- data/lib/tjplurk/robot.rb +1 -1
- data/lib/tjplurk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed5c8e407dba438c266218b7145eaefec56b988d
|
4
|
+
data.tar.gz: 16408798defee0268fd122763f89ac4964866a34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60ce05e5d87862588fafd9cb4d1bd9fe35a5a6b836a62d6f46c59e191ca19e4ba16876ba08f4aa780f876819946da69b7b71af07ddcd3618ab4b0d8e03078a99
|
7
|
+
data.tar.gz: 6ae2da4ad297ad9e49aa2006f50a16a61e846fbfe14a6f17d6d98f3649ed1c81ee672626e41df50044fd1a8d8b02cc94b4b80cc7a9d159db86471e13476e0dc8
|
data/lib/tjplurk/robot/topic.rb
CHANGED
@@ -8,7 +8,7 @@ module Tjplurk
|
|
8
8
|
class << self
|
9
9
|
def load yaml
|
10
10
|
YAML.load(yaml).map do |attributes|
|
11
|
-
topic = self.new name: attributes['name'], pattern:
|
11
|
+
topic = self.new name: attributes['name'], pattern: attributes['pattern']
|
12
12
|
topic.responses = attributes['responses'].map{|res| Response.new(topic: topic, content: res)}
|
13
13
|
topic
|
14
14
|
end
|
data/lib/tjplurk/robot.rb
CHANGED
@@ -5,7 +5,7 @@ module Tjplurk
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def respond input
|
8
|
-
if matched = @topics.select{|topic| topic.pattern.match(input) }.sample
|
8
|
+
if matched = @topics.each{|topic| topic.pattern = Regexp.new(topic.pattern) if topic.pattern.is_a? String}.select{|topic| topic.pattern.match(input) }.sample
|
9
9
|
response = matched.responses.sample.content
|
10
10
|
input.gsub!(matched.pattern, response)
|
11
11
|
end
|
data/lib/tjplurk/version.rb
CHANGED