Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a regex to capture reasonToken #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added a regex to capture reasonToken
  • Loading branch information
ParthKolekar committed Aug 15, 2016
commit c487e1910842d61029883e7b3e5915ba98f71d1f
8 changes: 4 additions & 4 deletions src/plusplus.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ module.exports = (robot) ->
# the increment/decrement operator ++ or --
([-+]{2}|—)
# optional reason for the plusplus
(?:\s+(?:for|because|cause|cuz)\s+(.+))?
(?:\s+(?:(for|because|cause|cuz))\s+(.+))?
$ # end of line
///i, (msg) ->
# let's get our local vars in place
[dummy, name, operator, reason] = msg.match
[dummy, name, operator, reasonToken, reason] = msg.match
from = msg.message.user.name.toLowerCase()
room = msg.message.room

Expand Down Expand Up @@ -73,9 +73,9 @@ module.exports = (robot) ->
if score?
message = if reason?
if reasonScore == 1 or reasonScore == -1
"#{name} has #{score} points, #{reasonScore} of which is for #{reason}."
"#{name} has #{score} points, #{reasonScore} of which is #{reasonToken} #{reason}."
else
"#{name} has #{score} points, #{reasonScore} of which are for #{reason}."
"#{name} has #{score} points, #{reasonScore} of which are #{reasonToken} #{reason}."
else
if score == 1
"#{name} has #{score} point"
Expand Down