ceiling_cat 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +3,9 @@ module CeilingCat
3
3
  class CallAndResponse < CeilingCat::Plugin::Base
4
4
  def handle
5
5
  if event.type == :chat
6
- if match = self.class.list.find{|car| body =~ Regexp.new(Regexp.escape(car[:call]),true) }
7
- reply match[:response]
6
+ if match = self.class.list.find{|car| body =~ Regexp.new(car[:call],true) }
7
+ response = [match[:response]].flatten # Support old responses which are strings, not arrays
8
+ reply response[Kernel.rand(response.size)]
8
9
  return nil
9
10
  end
10
11
  super
@@ -14,7 +15,7 @@ module CeilingCat
14
15
 
15
16
  def self.commands
16
17
  [{:command => "list calls", :description => "List current calls and their responses", :method => "list"},
17
- {:command => "add call", :description => "Add an response to display when a phrase is said, split by a | - '!add call I see what you did there... | You caught me!'", :method => "add"},
18
+ {:command => "add call", :description => "Add an response to display when a phrase is said, split by a | - '!add call I see what you did there... | You caught me! | Oh no I'm busted!'", :method => "add"},
18
19
  {:command => "remove call", :description => "Remove an call and response by call '!remove call I see what you did there...'", :method => "remove"}]
19
20
  end
20
21
 
@@ -35,20 +36,20 @@ module CeilingCat
35
36
  store["call_and_responses"] ||= []
36
37
  if store["call_and_responses"].size > 0
37
38
  messages << "Current Calls and Responses"
38
- messages += store["call_and_responses"].collect{|car| "-- #{car[:call]} | #{car[:response]}"}
39
+ messages += store["call_and_responses"].collect{|car| "-- #{car[:call]} | #{[car[:response]].flatten.join(" | ")}"} # Support old responses which are strings, not arrays
39
40
  else
40
- messages << "There are no call and respones set up yet! You should add one with '!add call When someone says this | I say this'"
41
+ messages << "There are no call and respones set up yet! You should add one with '!add call When someone says this | I say this | or this'"
41
42
  end
42
43
  reply messages
43
44
  end
44
45
 
45
46
  def add
46
47
  message = body_without_nick_or_command("add call")
47
- call, response = message.split("|")
48
- if self.class.add(:call => call.strip,:response => response.strip)
48
+ call, *response = message.split("|")
49
+ if self.class.add(:call => call.strip,:response => response.map(&:strip))
49
50
  reply "Call and Response added."
50
51
  else
51
- reply "Unable to add that call. A call and a response are required, split by a | - 'When someones says this | I say this'"
52
+ reply "Unable to add that call. A call and a response are required, split by a | - 'When someones says this | I say this | or this'"
52
53
  end
53
54
  end
54
55
 
@@ -1,3 +1,3 @@
1
1
  module CeilingCat
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ceiling_cat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Warren
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-04 00:00:00 Z
18
+ date: 2011-09-07 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: tinder
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  requirements: []
195
195
 
196
196
  rubyforge_project:
197
- rubygems_version: 1.8.8
197
+ rubygems_version: 1.8.7
198
198
  signing_key:
199
199
  specification_version: 3
200
200
  summary: Ceiling Cat is watching you chat. A Campfire chat bot.