Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit 63061ca

Browse files
author
Pete Nicholls
committed
A way to empty a thing of its karma
1 parent 0fdc77d commit 63061ca

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/scripts/karma.coffee

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#
33
# <thing>++ - give thing some karma
44
# <thing>-- - take away some of thing's karma
5-
# karma <thing> - check thing's karma, if <thing> is ommitted get top and bottom 3
5+
# karma <thing> - check thing's karma, if <thing> is omitted get top and bottom 3
6+
# karma empty <thing> - empty a thing's karma
67
class Karma
78

89
constructor: (@robot) ->
@@ -19,7 +20,11 @@ class Karma
1920
@robot.brain.on 'loaded', =>
2021
if @robot.brain.data.karma
2122
@cache = @robot.brain.data.karma
22-
23+
24+
kill: (thing) ->
25+
delete @cache[thing]
26+
@robot.brain.data.karma = @cache
27+
2328
increment: (thing) ->
2429
@cache[thing] ?= 0
2530
@cache[thing] += 1
@@ -62,6 +67,11 @@ module.exports = (robot) ->
6267
karma.decrement subject
6368
msg.send "#{subject} #{karma.decrementResponse()} (Karma: #{karma.get(subject)})"
6469

70+
robot.respond /karma empty ?(\S+[^-\s])$/i, (msg) ->
71+
subject = msg.match[1].toLowerCase()
72+
karma.kill subject
73+
msg.send "#{subject} has had its karma scattered to the winds."
74+
6575
robot.respond /karma ?(\S+[^-\s])?$/i, (msg) ->
6676
if msg.match[1]
6777
match = msg.match[1].toLowerCase()

0 commit comments

Comments
 (0)