hubot-pugme
hubot-pugme copied to clipboard
Add limits
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.
I only saw 20 come through for what it's worth...
:+1:
If he would have used the correct syntax it would have been catastrophic. I'm proactively blocking his intent.
:+1: 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:
ERROR Received error {"code":-1,"msg":"slow down, too many messages..."}
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.
:+1: 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. :)
As a pug, NOOOOOOOOOOOOOOOOOOOOOO!!!! :((

is there any reason to not merge this?
I'm looking for a reasonable default to the limit, rather than unlimited by default.
5 is what I normally use. On Fri, Jan 8, 2016 at 7:51 PM Josh Nichols [email protected] wrote:
is there any reason to not merge this?
I'm looking for a reasonable default to the limit, rather than unlimited by default.
— Reply to this email directly or view it on GitHub https://github.com/hubot-scripts/hubot-pugme/pull/1#issuecomment-170171317 .
Brendan Gaulin
@technicalpickles said... I'm looking for a reasonable default to the limit, rather than unlimited by default.
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.