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

Commit

Permalink
plus_one.coffee: fix script and make it respond to either +1 and thx
Browse files Browse the repository at this point in the history
  • Loading branch information
sevos committed Oct 16, 2012
1 parent aad8159 commit 87f13ab
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/scripts/plus_one.coffee
Expand Up @@ -7,10 +7,10 @@
module.exports = (robot) ->
robot.brain.data.achievements ||= {}

robot.hear /(.*): *\+1 for (.*)$/i, (msg) ->
receiver = msg.match[1]
robot.hear /(.*):? *(\+1|thx) for (.*)$/i, (msg) ->
receiver = msg.match[1].trim()
thanking = msg.message.user.name
reason = msg.match[2]
reason = msg.match[3]

if receiver == thanking
msg.send "hey, don't cheat!"
Expand All @@ -26,7 +26,7 @@ module.exports = (robot) ->

robot.respond /who thanks me??/i, (msg) ->
user = msg.message.user.name
response = "#{user}, #{robot.brain.data.achievements[user].length} time(s) someone thanked you:\n"
response = "#{user}, #{robot.brain.data.achievements[user].length} time(s) someone thanked you:\n"
for achievement in robot.brain.data.achievements[user]
response += "#{achievement.given_by} for #{achievement.reason}\n"
msg.send response
Expand All @@ -49,6 +49,3 @@ module.exports = (robot) ->

msg.send message

robot.hear /thx/i, (msg) ->
msg.send "#{msg.message.user.name}: hey, grant a plus!"

0 comments on commit 87f13ab

Please sign in to comment.