lita-karma 0.0.2 → 0.0.3
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 +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/lita/handlers/karma.rb +16 -0
- data/lita-karma.gemspec +1 -1
- data/spec/lita/handlers/karma_spec.rb +9 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bde948c2cf3b2c372b3cad86e784ba89fd8bf7b
|
4
|
+
data.tar.gz: f52907190d12603f369272c9c4ca113188a2270d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d81fd849e16e9f627ad271e253ac473e40094caf44b3ed535d1c245ba3ae6213424947bc8375b678e8967a844b109b3639ea7f7d05a5a2150ff6c26a719e4af
|
7
|
+
data.tar.gz: 093d8d92a400eed65a35ffaa84f0f3ef3515da74aedfeae3b6129243d92c00b18b4bb83a25ee632ae71bd37cc3df21b9fad08e9b5041e14fab7826d4d0fd9c5d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.0.3 (June 23, 2013)
|
4
|
+
|
5
|
+
* Added command help.
|
6
|
+
* When a user attempts to modify a term and is rate limited, Lita no longer also displays the term's current karma.
|
7
|
+
|
8
|
+
## 0.0.2 (June 22, 2013)
|
9
|
+
|
10
|
+
* Added term linking.
|
11
|
+
* Added `karma modified` command.
|
12
|
+
* Added rate limiting via `config.handlers.karma.cooldown`.
|
13
|
+
|
14
|
+
## 0.0.1 (June 15, 2003)
|
15
|
+
|
16
|
+
Initial release.
|
data/lib/lita/handlers/karma.rb
CHANGED
@@ -3,6 +3,21 @@ require "lita"
|
|
3
3
|
module Lita
|
4
4
|
module Handlers
|
5
5
|
class Karma < Handler
|
6
|
+
def self.help
|
7
|
+
name = Lita.config.robot.mention_name || Lita.config.robot.name
|
8
|
+
|
9
|
+
{
|
10
|
+
"TERM++" => "Increments TERM by one.",
|
11
|
+
"TERM--" => "Decrements TERM by one.",
|
12
|
+
"TERM~~" => "Shows the current karma of TERM.",
|
13
|
+
"#{name}: karma best [N]" => "Lists the top N terms by karma. N defaults to 5.",
|
14
|
+
"#{name}: karma worst [N]" => "Lists the bottom N terms by karma. N defaults to 5.",
|
15
|
+
"#{name}: karma modified TERM" => "Lists the names of users who have upvoted or downvoted TERM.",
|
16
|
+
"#{name}: TERM1 += TERM2" => "Links TERM2 to TERM1. TERM1's karma will then be displayed as the sum of its own and TERM2's karma.",
|
17
|
+
"#{name}: TERM1 -= TERM2" => "Unlinks TERM2 from TERM1. TERM1's karma will no longer be displayed as the sum of its own and TERM2's karma.",
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
6
21
|
route %r{([^\s]{2,})\+\+}, to: :increment
|
7
22
|
route %r{([^\s]{2,})\-\-}, to: :decrement
|
8
23
|
route %r{([^\s]{2,})~~}, to: :check
|
@@ -106,6 +121,7 @@ module Lita
|
|
106
121
|
"You cannot modify #{term} for another #{ttl} second"
|
107
122
|
cooldown_message << (ttl == 1 ? "." : "s.")
|
108
123
|
reply cooldown_message
|
124
|
+
return
|
109
125
|
else
|
110
126
|
redis.zincrby("terms", delta, term)
|
111
127
|
redis.sadd("modified:#{term}", user.id)
|
data/lita-karma.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-karma"
|
3
|
-
spec.version = "0.0.
|
3
|
+
spec.version = "0.0.3"
|
4
4
|
spec.authors = ["Jimmy Cuadra"]
|
5
5
|
spec.email = ["jimmy@jimmycuadra.com"]
|
6
6
|
spec.description = %q{A Lita handler for tracking karma points for arbitrary terms.}
|
@@ -13,6 +13,12 @@ describe Lita::Handlers::Karma, lita: true do
|
|
13
13
|
it { routes("#{robot.name}: foo += bar").to(:link) }
|
14
14
|
it { routes("#{robot.name}: foo -= bar").to(:unlink) }
|
15
15
|
|
16
|
+
describe ".help" do
|
17
|
+
it "returns a hash of command help" do
|
18
|
+
expect(described_class.help).to be_a(Hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
16
22
|
describe "#increment" do
|
17
23
|
it "increases the term's score by one and says the new score" do
|
18
24
|
expect_reply("foo: 1")
|
@@ -34,6 +40,7 @@ describe Lita::Handlers::Karma, lita: true do
|
|
34
40
|
Lita.config.handlers.karma.cooldown = 10
|
35
41
|
send_test_message("foo++")
|
36
42
|
expect_reply(/cannot modify foo/)
|
43
|
+
expect_no_reply(/foo:/)
|
37
44
|
send_test_message("foo++")
|
38
45
|
end
|
39
46
|
end
|
@@ -59,6 +66,7 @@ describe Lita::Handlers::Karma, lita: true do
|
|
59
66
|
Lita.config.handlers.karma.cooldown = 10
|
60
67
|
send_test_message("foo--")
|
61
68
|
expect_reply(/cannot modify foo/)
|
69
|
+
expect_no_reply(/foo:/)
|
62
70
|
send_test_message("foo--")
|
63
71
|
end
|
64
72
|
end
|
@@ -136,7 +144,7 @@ MSG
|
|
136
144
|
send_test_message("foo++ bar++ baz++")
|
137
145
|
send_test_message("#{robot.name}: foo += bar")
|
138
146
|
send_test_message("#{robot.name}: foo += baz")
|
139
|
-
expect_reply(
|
147
|
+
expect_reply(/foo: 3 \(1\), linked to: ba[rz]: 1, ba[rz]: 1/)
|
140
148
|
send_test_message("foo~~")
|
141
149
|
end
|
142
150
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-karma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Cuadra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- .gitignore
|
105
105
|
- .travis.yml
|
106
|
+
- CHANGELOG.md
|
106
107
|
- Gemfile
|
107
108
|
- README.md
|
108
109
|
- Rakefile
|