Add limits#1
Conversation
|
I only saw 20 come through for what it's worth... 👍 |
|
If he would have used the correct syntax it would have been catastrophic. I'm proactively blocking his intent. |
|
👍 Someone in an IRC channel I'm in tried to do 2000. It crashed after ~700. |
|
Would love a limit! Otherwise I've just bee disabling the script or replacing with: # Description:
# Pugme is the most important thing in your life
#
# Dependencies:
# None
#
# Configuration:
# HUBOT_PUGME_MAX - The most pugs you can bomb. Default: 20
#
# Commands:
# hubot pug me - Receive a pug
# hubot pug bomb N - get N pugs
module.exports = (robot) ->
max = (process.env.HUBOT_PUGME_MAX * 1) or 20
robot.respond /pug me/i, (msg) ->
msg.http("http://pugme.herokuapp.com/random")
.get() (err, res, body) ->
msg.send JSON.parse(body).pug
robot.respond /pug bomb( (\d+))?/i, (msg) ->
count = msg.match[2] || 5
count = max if count > max
msg.http("http://pugme.herokuapp.com/bomb?count=" + count)
.get() (err, res, body) ->
msg.send pug for pug in JSON.parse(body).pugs
robot.respond /how many pugs are there/i, (msg) ->
msg.http("http://pugme.herokuapp.com/count")
.get() (err, res, body) ->
msg.send "There are #{JSON.parse(body).pug_count} pugs."I like the idea of some pugs still making it through when someone tries inserting a crazy number. Note slack boots you right around a bomb of 17 pugs with: |
|
Sorry I missed this, wasn't watching the repo. If we are adding a limit, we may as well have a reasonable one, like 5 or 10, rather than unlimited. |
|
👍 is there any reason to not merge this? Does it need a test or anything? We would love to set a limit for our hubot |
|
@technicalpickles is this something you are planning on pulling in? We have just ran into the same issue with a couple of our bots. Thanks! |
|
I agree with a reasonable limit to start off with. :) |
- Due to this: https://gitter.im/cake-build/cake?at=56410e2d8b872257348e17ef - If/when this PR gets accepted: hubot-archive/hubot-pugme#1 - We can think about adding this back in
- Due to this: https://gitter.im/cake-build/cake?at=56410e2d8b872257348e17ef - If/when this PR gets accepted: hubot-archive/hubot-pugme#1 - We can think about adding this back in
- Due to this: https://gitter.im/cake-build/cake?at=56410e2d8b872257348e17ef - If/when this PR gets accepted: hubot-archive/hubot-pugme#1 - We can think about adding this back in
|
As a pug, NOOOOOOOOOOOOOOOOOOOOOO!!!! :(( |
There was a problem hiding this comment.
I found recently you can parseInt an undefined and get NaN back, and that's considered falsy. That means you can parseInt(process.env.HUBOT_PUGBOMB_MAX) or -1.
I'm looking for a reasonable default to the limit, rather than unlimited by default. |
|
5 is what I normally use.
|
|
@technicalpickles said... Surely, any arbirtrary number, is better than having it be unlimited!?! I would also suggest something like 5 as the default, and perhaps provide the ability to configure this via an environment variable. |

After Ryan said "hubot pug bomb 400', none of us can have nice things anymore. Default behavior is unchanged, but add HUBOT_PUGBOMB_MAX=[number] to keep Ryan from breaking Slack again.