Skip to content

Commit

Permalink
Add killjoy message to the response when > MAX_POINTS
Browse files Browse the repository at this point in the history
Just like `Buzzkill Mode TM` from the Hipchat karma bot, this prints out
a message explaining the 5 (or MAX_POINTS) limit if someone is giving
(or taking away) more karma.

closes jetpackworkflow#4 the rest of the way
  • Loading branch information
diachini committed Feb 9, 2019
1 parent 3aa124c commit 15160d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ API
* `'taco tuesday'++` - add a point to 'taco tuesday'
* `++` - add a point to the most previously voted-on thing
* `thing++ for stuff` - keep track of why you gave thing points
* `thing+++++++` - adding more than `HUBOT_PLUSPLUS_MAX_POINTS` points will be capped at the max and a `HUBOT_PLUSPLUS_KILLJOY_MESSAGE` will be appended to the updated score.
* `thing--` - remove a point from `thing`
* `--` - remove a point from the most previously voted-on thing
* `thing-- for stuff` - keep track of why you removed thing points
Expand Down
3 changes: 3 additions & 0 deletions src/mega-plusplus.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = (robot) ->
reasonsKeyword = process.env.HUBOT_PLUSPLUS_REASONS or 'raisins'
maxPoints = process.env.HUBOT_PLUSPLUS_MAX_POINTS or 5
reasonConjunctions = process.env.HUBOT_PLUSPLUS_CONJUNCTIONS or 'for|because|cause|cuz|as'
killjoyMessage = process.env.HUBOT_PLUSPLUS_KILLJOY_MESSAGE or 'Killjoy Mode™ has enforced a maximum change of ' + maxPoints + ' points'

# sweet regex bro
robot.hear ///
Expand Down Expand Up @@ -101,6 +102,8 @@ module.exports = (robot) ->
"#{name} has #{score} points"


if requestedMagnitude > maxPoints
message = message + " (" + killjoyMessage + ")."
msg.send message

robot.emit "plus-one", {
Expand Down

0 comments on commit 15160d4

Please sign in to comment.