From d5ad864c60ee286c1434883fe1e65fa38e257909 Mon Sep 17 00:00:00 2001 From: Peter Golm Date: Fri, 28 Jun 2013 17:42:50 +0200 Subject: [PATCH 1/2] fix unflood options parse --- src/irc.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/irc.coffee b/src/irc.coffee index ea56bba..c5b6efb 100644 --- a/src/irc.coffee +++ b/src/irc.coffee @@ -96,13 +96,12 @@ class IrcBot extends Adapter throw new Error("HUBOT_IRC_SERVER is not defined: try: export HUBOT_IRC_SERVER='irc.myserver.com'") unfloodProtection: (unflood) -> - if unflood? then unflood else unflood == null + if unflood? and (unflood == 'true' or !isNaN(parseInt(unflood))) then true else false unfloodProtectionDelay: (unflood) -> switch @unfloodProtection(unflood) - when true then 1000 + when true then (if !isNaN(parseInt(unflood)) then parseInt(unflood) else 1000) when false then 0 - else parseInt(unflood / 60) run: -> self = @ From 443f25857a1062687fb793d74ee7735ce2c76b96 Mon Sep 17 00:00:00 2001 From: Peter Golm Date: Mon, 1 Jul 2013 10:22:00 +0200 Subject: [PATCH 2/2] refactor unflood improvements --- src/irc.coffee | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/irc.coffee b/src/irc.coffee index c5b6efb..c0370e9 100644 --- a/src/irc.coffee +++ b/src/irc.coffee @@ -96,12 +96,16 @@ class IrcBot extends Adapter throw new Error("HUBOT_IRC_SERVER is not defined: try: export HUBOT_IRC_SERVER='irc.myserver.com'") unfloodProtection: (unflood) -> - if unflood? and (unflood == 'true' or !isNaN(parseInt(unflood))) then true else false + unflood == 'true' or !isNaN(parseInt(unflood)) unfloodProtectionDelay: (unflood) -> - switch @unfloodProtection(unflood) - when true then (if !isNaN(parseInt(unflood)) then parseInt(unflood) else 1000) - when false then 0 + unfloodProtection = @unfloodProtection(unflood) + unfloodValue = parseInt(unflood) or 1000 + + if unfloodProtection + unfloodValue + else + 0 run: -> self = @