Skip to content

Commit

Permalink
refactor unflood improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pgolm committed Jul 1, 2013
1 parent d5ad864 commit 443f258
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/irc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @
Expand Down

0 comments on commit 443f258

Please sign in to comment.