Skip to content

Commit

Permalink
Prevent users from giving themselves karma, optionally post no gif
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Donohue <[email protected]>
  • Loading branch information
Donohue committed Nov 18, 2015
1 parent ab89643 commit 9e677a6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/example.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ module.exports = (robot) ->
plusplus_minusminus_re = /@([a-z0-9_\-\.]+)[\+\-]{2,}/ig

robot.hear plusplus_minusminus_re, (msg) ->
sending_user = msg.message.user.name
res = ''
while (match = plusplus_re.exec(msg.message))
user = match[1].replace(/\-+$/g, '')
count = (robot.brain.get(user) or 0) + 1
robot.brain.set user, count
res += "@#{user}++ [woot! now at #{count}]\n"
if user != sending_user
count = (robot.brain.get(user) or 0) + 1
robot.brain.set user, count
res += "@#{user}++ [woot! now at #{count}]\n"
else if process.env.KARMABOT_NO_GIF
res += process.env.KARMABOT_NO_GIF
while (match = minusminus_re.exec(msg.message))
user = match[1].replace(/\-+$/g, '')
count = (robot.brain.get(user) or 0) - 1
Expand Down

0 comments on commit 9e677a6

Please sign in to comment.