Skip to content

Commit

Permalink
Simpler karma.
Browse files Browse the repository at this point in the history
  • Loading branch information
bear454 committed May 1, 2012
1 parent 46a2a20 commit dba3cac
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions scripts/karma.coffee
@@ -1,5 +1,5 @@
# Increment and decrement karma based on + and -
#
#

Sys = require "sys"

Expand All @@ -11,7 +11,7 @@ module.exports = (robot) ->
output = Sys.inspect(robot.brain.data.karma)
msg.send(output)

robot.hear /^([\w\.-]+)(\+\+|\-\-)$/i, (msg) ->
robot.hear /^(.+)(\+\+|\-\-)$/i, (msg) ->
object = msg.match[1]
action = msg.match[2]
if object
Expand All @@ -20,10 +20,6 @@ module.exports = (robot) ->
karma = (robot, msg, object, action) ->
if typeof(robot.brain.data.karma) is 'undefined'
robot.brain.data.karma = {}
if object == 'adrianpike'
action = '++'
if object == 'coffeescript'
action = '--'
if typeof(robot.brain.data.karma[object]) != 'undefined'
old_val = robot.brain.data.karma[object]
else
Expand All @@ -34,4 +30,4 @@ karma = (robot, msg, object, action) ->
new_val = old_val - 1
robot.brain.data.karma[object] = new_val
msg.send object + "'s karma is now " + new_val
return
return

0 comments on commit dba3cac

Please sign in to comment.