From 443f25857a1062687fb793d74ee7735ce2c76b96 Mon Sep 17 00:00:00 2001 From: Peter Golm Date: Mon, 1 Jul 2013 10:22:00 +0200 Subject: [PATCH] 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 = @