tjplurk 1.3.1 → 1.4.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: 6f4406635401d4c778fabff6aefb16e4271f7296
4
- data.tar.gz: 478b256b282b39fa9101e05bc30f411692f9c210
3
+ metadata.gz: 707143e8c90ef4f7f6136e6a0266cb0316bb916e
4
+ data.tar.gz: a2888e488c17c2e394a5481ba27e3268533f8396
5
5
  SHA512:
6
- metadata.gz: 01a0e0435df71e22b2a84373cec99e01aa95862f8af083ccd2e908912dbc847d872b814ca550f4e7278b5c69c94382d52a27b62504f6552ae0e6e22176aacb1c
7
- data.tar.gz: e77e39523c65679c0a1af70e027f7b8fb6745662c830cb9530209f7087508cec3c4ed0f2310b4a55a63e6bf6d63a2f5b78aed44e39492e19ba9dd97b3cab8bff
6
+ metadata.gz: 6b32dd6bb0b5658f25f1b7106cf7fa8ba96c4aeee610c017af205af8ccf4239320fcf20403920dc061184bb83c61a1e7b01539a7fbd22fb9ca565ba6a5d417c8
7
+ data.tar.gz: 32296a7dd987ab9cd51574c1ffd4b7f1414046117f08dac83006a2a8d53e72534dcfe7796f819469a701d6c76bd9cc152bb7f733e7eca2a07a61af13e391e707
@@ -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: attributes['pattern']
11
+ topic = self.new name: attributes['name'], pattern: Regexp.new(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
@@ -4,9 +4,10 @@ module Tjplurk
4
4
  @topics = topics
5
5
  end
6
6
 
7
- def respond s
8
- if matched = @topics.select{|category| Regexp.new(category.pattern).match(s) }.sample
9
- matched.responses.sample.content
7
+ def respond input
8
+ if matched = @topics.select{|topic| topic.pattern.match(input) }.sample
9
+ response = matched.responses.sample.content
10
+ input.gsub!(matched.pattern, response)
10
11
  end
11
12
  end
12
13
  end
@@ -1,3 +1,3 @@
1
1
  module Tjplurk
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tjplurk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Jian