Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

plus_one.coffee: fix script and make it respond to either +1 and thx

  • Loading branch information...
commit 87f13ab59994e4b18ff6caf229b687fa36d1f810 1 parent aad8159
@sevos sevos authored
Showing with 4 additions and 7 deletions.
  1. +4 −7 src/scripts/plus_one.coffee
View
11 src/scripts/plus_one.coffee
@@ -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!"
@@ -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
@@ -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!"
-
Please sign in to comment.
Something went wrong with that request. Please try again.