cinch-cooldown 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +20 -1
- data/README.md +1 -1
- data/cinch-cooldown.gemspec +10 -11
- data/lib/cinch/cooldown/version.rb +1 -1
- data/lib/cinch/plugin/cooldowns.rb +2 -3
- data/lib/cinch/plugin/hooks.rb +3 -2
- data/spec/cinch-cooldown_spec.rb +22 -22
- metadata +37 -40
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: 98b072029f3902df8be334e446530cbdcd58c5e4
|
|
4
|
+
data.tar.gz: 69a12eaa5e1a0f7b8b66f8e3a8bae6bb187f0f90
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 564dea1e24dec252b267ef6f9c9027b864cba5b8ae3d1bc51a1f679c54f950d81b3469755e10489e99bea240a8cebe54e90eafd57ebc561a0e96c82d8cac48ff
|
|
7
|
+
data.tar.gz: e1da9ffc614f9b6ac83b0002f23d73b4c9913d82b8fdc4e13a701bb40430dee3b7ae01689b63abf428bac3ec2cd28616c69c1f3b81dbadd3cf29871f97eab55a
|
data/.travis.yml
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
+
env:
|
|
3
|
+
global:
|
|
4
|
+
- "JRUBY_OPTS=-Xcext.enabled=true"
|
|
2
5
|
rvm:
|
|
3
|
-
- 1.
|
|
6
|
+
- 2.1.0
|
|
7
|
+
- 2.0.0
|
|
4
8
|
- 1.9.3
|
|
9
|
+
- 1.9.2
|
|
10
|
+
- 1.8.7
|
|
11
|
+
- jruby-18mode
|
|
12
|
+
- jruby-19mode
|
|
13
|
+
- ruby-head
|
|
14
|
+
- jruby-head
|
|
15
|
+
- ree
|
|
16
|
+
matrix:
|
|
17
|
+
allow_failures:
|
|
18
|
+
- rvm: 1.8.7
|
|
19
|
+
- rvm: ree
|
|
20
|
+
- rvm: jruby-18mode
|
|
21
|
+
- rvm: jruby-19mode
|
|
22
|
+
- rvm: jruby-head
|
|
23
|
+
fast_finish: true
|
data/README.md
CHANGED
|
@@ -37,7 +37,7 @@ that the user timer will be greater than the global timer.
|
|
|
37
37
|
:user => 20 } }
|
|
38
38
|
|
|
39
39
|
2. If you are using this with my plugins, things should just work. However if you want to use
|
|
40
|
-
this with your own plugins,
|
|
40
|
+
this with your own plugins, you need to add a `require cinch/cooldown` to the top of said
|
|
41
41
|
plugin, and an `enforce_cooldown` to the plugin after the `include Cinch::Plugin` line.
|
|
42
42
|
|
|
43
43
|
## Contributing
|
data/cinch-cooldown.gemspec
CHANGED
|
@@ -8,21 +8,20 @@ Gem::Specification.new do |gem|
|
|
|
8
8
|
gem.version = Cinch::Cooldowns::VERSION
|
|
9
9
|
gem.authors = ['Brian Haberer']
|
|
10
10
|
gem.email = ['bhaberer@gmail.com']
|
|
11
|
-
gem.description = %q
|
|
12
|
-
gem.summary = %q
|
|
11
|
+
gem.description = %q(This gem allows you to set a shared timer across plugins that are configured to respect it.)
|
|
12
|
+
gem.summary = %q(Global Cooldown tracker for Cinch Plugins)
|
|
13
13
|
gem.homepage = 'https://github.com/bhaberer/cinch-cooldown'
|
|
14
14
|
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
|
16
|
-
gem.executables = gem.files.grep(
|
|
17
|
-
gem.test_files = gem.files.grep(
|
|
16
|
+
gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
|
|
17
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
|
18
18
|
gem.require_paths = ['lib']
|
|
19
19
|
gem.license = 'MIT'
|
|
20
20
|
|
|
21
|
-
gem.add_development_dependency
|
|
22
|
-
gem.add_development_dependency
|
|
23
|
-
gem.add_development_dependency
|
|
24
|
-
gem.add_development_dependency
|
|
25
|
-
|
|
26
|
-
gem.add_dependency
|
|
27
|
-
gem.add_dependency 'cinch', '~> 2.0.12'
|
|
21
|
+
gem.add_development_dependency 'rake', '~> 10'
|
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
|
23
|
+
gem.add_development_dependency 'coveralls', '~> 0.7'
|
|
24
|
+
gem.add_development_dependency 'cinch-test', '~> 0.0', '>= 0.0.2'
|
|
25
|
+
gem.add_dependency 'cinch', '~> 2'
|
|
26
|
+
gem.add_dependency 'time-lord', '~> 1.0', '>= 1.0.1'
|
|
28
27
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
module Cinch
|
|
3
3
|
module Plugin
|
|
4
|
+
# Class for managing the cooldown objects.
|
|
4
5
|
module Cooldowns
|
|
5
6
|
include Cinch::Plugin
|
|
6
7
|
|
|
@@ -92,9 +93,7 @@ module Cinch
|
|
|
92
93
|
def self.clean_expired_cooldowns(channel)
|
|
93
94
|
return unless @cooldowns.key?(channel)
|
|
94
95
|
@cooldowns[channel].each_pair do |key, cooldown|
|
|
95
|
-
if cooldown.cooled_down?
|
|
96
|
-
@cooldowns[channel].delete(key)
|
|
97
|
-
end
|
|
96
|
+
@cooldowns[channel].delete(key) if cooldown.cooled_down?
|
|
98
97
|
end
|
|
99
98
|
end
|
|
100
99
|
|
data/lib/cinch/plugin/hooks.rb
CHANGED
|
@@ -5,8 +5,9 @@ module Cinch
|
|
|
5
5
|
# Add the pre hook to all messages triggered
|
|
6
6
|
module ClassMethods
|
|
7
7
|
def enforce_cooldown
|
|
8
|
-
hook(:pre,
|
|
9
|
-
|
|
8
|
+
hook(:pre,
|
|
9
|
+
for: [:match],
|
|
10
|
+
method: ->(m) { Cooldowns.finished?(m, shared[:cooldown], @bot) })
|
|
10
11
|
end
|
|
11
12
|
end
|
|
12
13
|
end
|
data/spec/cinch-cooldown_spec.rb
CHANGED
|
@@ -34,39 +34,39 @@ describe Cinch::Cooldowns do
|
|
|
34
34
|
it 'should not trigger cooldowns on private messages' do
|
|
35
35
|
bot = bot_for_cooldowns(10)
|
|
36
36
|
get_replies(make_message(bot, "!thing"))
|
|
37
|
-
get_replies(make_message(bot, "!thing")).first.text
|
|
38
|
-
|
|
37
|
+
expect(get_replies(make_message(bot, "!thing")).first.text)
|
|
38
|
+
.to match('OMG')
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it 'should allow plugins to mandate a global cooldown between responses in channel' do
|
|
42
42
|
bot = bot_for_cooldowns(10)
|
|
43
43
|
get_replies(make_message(bot, "!thing", channel: '#foo'))
|
|
44
|
-
get_replies(make_message(bot, "!thing", channel: '#foo')).first.text
|
|
45
|
-
|
|
44
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo')).first.text)
|
|
45
|
+
.to match(/Sorry, cooldown is in effect: \d+ seconds from now before/)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it 'should allow plugins allow responses after the global cooldown' do
|
|
49
49
|
bot = bot_for_cooldowns(5, 5)
|
|
50
50
|
get_replies(make_message(bot, "!thing", channel: '#foo'))
|
|
51
51
|
sleep 7
|
|
52
|
-
get_replies(make_message(bot, "!thing", channel: '#foo')).first.text
|
|
53
|
-
|
|
52
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo')).first.text)
|
|
53
|
+
.to eq('OMG')
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
it 'should allow plugins to mandate a minimum time between responses in channel' do
|
|
57
57
|
bot = bot_for_cooldowns(5, 10)
|
|
58
58
|
get_replies(make_message(bot, "!thing", channel: '#foo'))
|
|
59
59
|
sleep 7
|
|
60
|
-
get_replies(make_message(bot, "!thing", channel: '#foo')).first.text
|
|
61
|
-
|
|
60
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo')).first.text)
|
|
61
|
+
.to match(/Sorry, cooldown is in effect: \d+ seconds from now before you can use/)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it 'should allow plugins to mandate a minimum time between responses in channel' do
|
|
65
65
|
bot = bot_for_cooldowns(5, 10)
|
|
66
66
|
get_replies(make_message(bot, "!thing", channel: '#foo'))
|
|
67
67
|
sleep 12
|
|
68
|
-
get_replies(make_message(bot, "!thing", channel: '#foo')).first.text
|
|
69
|
-
|
|
68
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo')).first.text)
|
|
69
|
+
.to eq('OMG')
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it 'should aplugins to mandate a minimum time between responses in channel' do
|
|
@@ -76,30 +76,30 @@ describe Cinch::Cooldowns do
|
|
|
76
76
|
sleep 6
|
|
77
77
|
get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'george'))
|
|
78
78
|
sleep 5
|
|
79
|
-
get_replies(make_message(bot, "!thing", channel: '#foo')).first.text
|
|
80
|
-
|
|
79
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo')).first.text)
|
|
80
|
+
.to eq('OMG')
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it 'should not trigger if the config for the current channel does not exist' do
|
|
84
84
|
bot = bot_for_cooldowns(5, 10)
|
|
85
85
|
get_replies(make_message(bot, "!thing", channel: '#bar'))
|
|
86
|
-
get_replies(make_message(bot, "!thing", channel: '#bar')).first.text
|
|
87
|
-
|
|
86
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#bar')).first.text)
|
|
87
|
+
.to eq('OMG')
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it 'should trigger for other users if the global cooldown is finished' do
|
|
91
91
|
bot = bot_for_cooldowns(0, 20)
|
|
92
|
-
get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'test1')).first.text
|
|
93
|
-
|
|
92
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'test1')).first.text)
|
|
93
|
+
.to eq('OMG')
|
|
94
94
|
sleep 1
|
|
95
|
-
get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'test2')).first.text
|
|
96
|
-
|
|
95
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'test2')).first.text)
|
|
96
|
+
.to eq('OMG')
|
|
97
97
|
end
|
|
98
98
|
it 'should trigger for other users if the global cooldown is finished' do
|
|
99
99
|
bot = bot_for_cooldowns(10, 20)
|
|
100
|
-
get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'test1')).first.text
|
|
101
|
-
|
|
102
|
-
get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'test2')).first.text
|
|
103
|
-
|
|
100
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'test1')).first.text)
|
|
101
|
+
.to eq('OMG')
|
|
102
|
+
expect(get_replies(make_message(bot, "!thing", channel: '#foo', nick: 'test2')).first.text)
|
|
103
|
+
.not_to eq('OMG')
|
|
104
104
|
end
|
|
105
105
|
end
|
metadata
CHANGED
|
@@ -1,112 +1,111 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cinch-cooldown
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.1.5
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Brian Haberer
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date: 2014-
|
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: rake
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - ~>
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '
|
|
19
|
+
version: '10'
|
|
22
20
|
type: :development
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - ~>
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '
|
|
26
|
+
version: '10'
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: rspec
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
|
-
- -
|
|
31
|
+
- - ~>
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: '
|
|
33
|
+
version: '3'
|
|
38
34
|
type: :development
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
|
-
- -
|
|
38
|
+
- - ~>
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '
|
|
40
|
+
version: '3'
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
|
47
42
|
name: coveralls
|
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
44
|
requirements:
|
|
51
|
-
- -
|
|
45
|
+
- - ~>
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0'
|
|
47
|
+
version: '0.7'
|
|
54
48
|
type: :development
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
51
|
requirements:
|
|
59
|
-
- -
|
|
52
|
+
- - ~>
|
|
60
53
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
54
|
+
version: '0.7'
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
|
63
56
|
name: cinch-test
|
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
|
65
|
-
none: false
|
|
66
58
|
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0.0'
|
|
67
62
|
- - ! '>='
|
|
68
63
|
- !ruby/object:Gem::Version
|
|
69
|
-
version:
|
|
64
|
+
version: 0.0.2
|
|
70
65
|
type: :development
|
|
71
66
|
prerelease: false
|
|
72
67
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
-
none: false
|
|
74
68
|
requirements:
|
|
69
|
+
- - ~>
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '0.0'
|
|
75
72
|
- - ! '>='
|
|
76
73
|
- !ruby/object:Gem::Version
|
|
77
|
-
version:
|
|
74
|
+
version: 0.0.2
|
|
78
75
|
- !ruby/object:Gem::Dependency
|
|
79
|
-
name:
|
|
76
|
+
name: cinch
|
|
80
77
|
requirement: !ruby/object:Gem::Requirement
|
|
81
|
-
none: false
|
|
82
78
|
requirements:
|
|
83
79
|
- - ~>
|
|
84
80
|
- !ruby/object:Gem::Version
|
|
85
|
-
version:
|
|
81
|
+
version: '2'
|
|
86
82
|
type: :runtime
|
|
87
83
|
prerelease: false
|
|
88
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
-
none: false
|
|
90
85
|
requirements:
|
|
91
86
|
- - ~>
|
|
92
87
|
- !ruby/object:Gem::Version
|
|
93
|
-
version:
|
|
88
|
+
version: '2'
|
|
94
89
|
- !ruby/object:Gem::Dependency
|
|
95
|
-
name:
|
|
90
|
+
name: time-lord
|
|
96
91
|
requirement: !ruby/object:Gem::Requirement
|
|
97
|
-
none: false
|
|
98
92
|
requirements:
|
|
99
93
|
- - ~>
|
|
100
94
|
- !ruby/object:Gem::Version
|
|
101
|
-
version:
|
|
95
|
+
version: '1.0'
|
|
96
|
+
- - ! '>='
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: 1.0.1
|
|
102
99
|
type: :runtime
|
|
103
100
|
prerelease: false
|
|
104
101
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
-
none: false
|
|
106
102
|
requirements:
|
|
107
103
|
- - ~>
|
|
108
104
|
- !ruby/object:Gem::Version
|
|
109
|
-
version:
|
|
105
|
+
version: '1.0'
|
|
106
|
+
- - ! '>='
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: 1.0.1
|
|
110
109
|
description: This gem allows you to set a shared timer across plugins that are configured
|
|
111
110
|
to respect it.
|
|
112
111
|
email:
|
|
@@ -132,29 +131,27 @@ files:
|
|
|
132
131
|
homepage: https://github.com/bhaberer/cinch-cooldown
|
|
133
132
|
licenses:
|
|
134
133
|
- MIT
|
|
134
|
+
metadata: {}
|
|
135
135
|
post_install_message:
|
|
136
136
|
rdoc_options: []
|
|
137
137
|
require_paths:
|
|
138
138
|
- lib
|
|
139
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
|
-
none: false
|
|
141
140
|
requirements:
|
|
142
141
|
- - ! '>='
|
|
143
142
|
- !ruby/object:Gem::Version
|
|
144
143
|
version: '0'
|
|
145
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
|
-
none: false
|
|
147
145
|
requirements:
|
|
148
146
|
- - ! '>='
|
|
149
147
|
- !ruby/object:Gem::Version
|
|
150
148
|
version: '0'
|
|
151
149
|
requirements: []
|
|
152
150
|
rubyforge_project:
|
|
153
|
-
rubygems_version:
|
|
151
|
+
rubygems_version: 2.2.2
|
|
154
152
|
signing_key:
|
|
155
|
-
specification_version:
|
|
153
|
+
specification_version: 4
|
|
156
154
|
summary: Global Cooldown tracker for Cinch Plugins
|
|
157
155
|
test_files:
|
|
158
156
|
- spec/cinch-cooldown_spec.rb
|
|
159
157
|
- spec/spec_helper.rb
|
|
160
|
-
has_rdoc:
|