hubot-pugme icon indicating copy to clipboard operation
hubot-pugme copied to clipboard

Add limits

Open hildjj opened this issue 10 years ago • 13 comments
trafficstars

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.

hildjj avatar Jan 09 '15 03:01 hildjj

I only saw 20 come through for what it's worth...

:+1:

devinreams avatar Jan 09 '15 04:01 devinreams

If he would have used the correct syntax it would have been catastrophic. I'm proactively blocking his intent.

hildjj avatar Jan 09 '15 04:01 hildjj

:+1: Someone in an IRC channel I'm in tried to do 2000. It crashed after ~700.

J3RN avatar Apr 08 '15 20:04 J3RN

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..."}

KyleJamesWalker avatar May 01 '15 03:05 KyleJamesWalker

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.

technicalpickles avatar Jun 06 '15 00:06 technicalpickles

:+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

brgaulin avatar Oct 21 '15 15:10 brgaulin

@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!

gep13 avatar Nov 09 '15 21:11 gep13

I agree with a reasonable limit to start off with. :)

ferventcoder avatar Nov 09 '15 22:11 ferventcoder

As a pug, NOOOOOOOOOOOOOOOOOOOOOO!!!! :((

hmemcpy avatar Nov 10 '15 09:11 hmemcpy

image

hmemcpy avatar Nov 10 '15 09:11 hmemcpy

is there any reason to not merge this?

I'm looking for a reasonable default to the limit, rather than unlimited by default.

technicalpickles avatar Jan 09 '16 00:01 technicalpickles

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

brgaulin avatar Jan 09 '16 00:01 brgaulin

@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.

gep13 avatar Jan 09 '16 14:01 gep13