lita-onewheel-karma 1.0.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/onewheel_karma.rb +15 -6
- data/lita-onewheel-karma.gemspec +1 -1
- data/spec/lita/handlers/onewheel_karma_spec.rb +13 -0
- 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: ec98c100fa2a65e5b145f46a23c5fad1423f1706
|
4
|
+
data.tar.gz: 60767f33f515f36418d497da4d3931a1537dfcac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8fe93a052bfc0cb8c106956e93485890178da3b6d6b49fe8de8753475451abaa3b971ddd254b0b6e34e87d7317e3dd4491871748955f63915ca0e42ff5cc286
|
7
|
+
data.tar.gz: 5e66253d6142e5914a3fe52b185e563765a892474f8e0578e50db1199dbd3715f102d3af0a061005c76fad469bd3d707772af5721ee49a16a4d0a121dbc3a72f
|
@@ -11,6 +11,8 @@ module Lita
|
|
11
11
|
help: {'object+=n:' => 'Add n karma to [object].'}
|
12
12
|
route /([^\s]+)-=\s*([-\d]+)/, :remove_arbitrary_karma,
|
13
13
|
help: {'object-=n:' => 'Remove n karma from [object].'}
|
14
|
+
route /karma\s+(.*)$/, :display_karma, command: true,
|
15
|
+
help: {'karma what' => 'Display karma for what.'}
|
14
16
|
|
15
17
|
def add_one_karma(response)
|
16
18
|
karma_object = response.matches[0][0]
|
@@ -45,18 +47,21 @@ module Lita
|
|
45
47
|
response.reply reply_with_karma(karma_object, karma)
|
46
48
|
end
|
47
49
|
|
50
|
+
def display_karma(response)
|
51
|
+
karma_object = response.matches[0][0]
|
52
|
+
karma = find_karma karma_object
|
53
|
+
response.reply reply_with_karma(karma_object, karma)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Helpers
|
57
|
+
|
48
58
|
def reply_with_karma(karma_object, karma)
|
49
|
-
# if karma >= 0
|
50
59
|
"#{karma_object} has #{karma} karma!"
|
51
|
-
# else
|
52
|
-
# "#{karma_object} has #{RomanNumerals.to_roman(karma * -1)}💩 karma!"
|
53
|
-
# "#{karma_object} has #{RomanNumerals.to_roman(karma * -1)}💩 karma!"
|
54
|
-
# end
|
55
60
|
end
|
56
61
|
|
57
62
|
# Find the karma object from redis and increment appropriately.
|
58
63
|
def find_and_set_karma(karma_object, increment_value = 1, multiply = false)
|
59
|
-
karma =
|
64
|
+
karma = find_karma(karma_object)
|
60
65
|
|
61
66
|
if multiply
|
62
67
|
karma *= increment_value.to_i
|
@@ -68,6 +73,10 @@ module Lita
|
|
68
73
|
karma
|
69
74
|
end
|
70
75
|
|
76
|
+
def find_karma(karma_object)
|
77
|
+
redis.get(karma_object).to_i
|
78
|
+
end
|
79
|
+
|
71
80
|
end
|
72
81
|
|
73
82
|
Lita.register_handler(OnewheelKarma)
|
data/lita-onewheel-karma.gemspec
CHANGED
@@ -134,4 +134,17 @@ describe Lita::Handlers::OnewheelKarma, lita_handler: true do
|
|
134
134
|
send_message 'a ++'
|
135
135
|
expect(replies.last).to eq nil
|
136
136
|
end
|
137
|
+
|
138
|
+
it 'will list for an item' do
|
139
|
+
send_message 'dooby++'
|
140
|
+
send_message 'dooby++'
|
141
|
+
send_command 'karma dooby'
|
142
|
+
expect(replies.count).to eq(3)
|
143
|
+
expect(replies.last).to eq('dooby has 2 karma!')
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'will not just karma' do
|
147
|
+
send_command 'karma'
|
148
|
+
expect(replies.last).to eq nil
|
149
|
+
end
|
137
150
|
end
|