Skip to content

Commit

Permalink
New unflood options, per nandub#77.
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed May 13, 2013
1 parent 979ed77 commit cd1434e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/irc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IrcBot extends Adapter

unless target
return console.log "ERROR: Not sure who to send to. envelope=", envelope

for str in strings
@bot.say target, str

Expand Down Expand Up @@ -85,6 +85,15 @@ class IrcBot extends Adapter
else if not process.env.HUBOT_IRC_SERVER
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

unfloodProtectionDelay: (unflood) ->
switch @unfloodProtection(unflood)
when true then 1000
when false then 0
else parseInt(unflood / 60)

run: ->
self = @

Expand All @@ -102,7 +111,7 @@ class IrcBot extends Adapter
connectCommand: process.env.HUBOT_IRC_CONNECT_COMMAND
fakessl: process.env.HUBOT_IRC_SERVER_FAKE_SSL?
certExpired: process.env.HUBOT_IRC_SERVER_CERT_EXPIRED?
unflood: process.env.HUBOT_IRC_UNFLOOD?
unflood: process.env.HUBOT_IRC_UNFLOOD
debug: process.env.HUBOT_IRC_DEBUG?
usessl: process.env.HUBOT_IRC_USESSL?
userName: process.env.HUBOT_IRC_USERNAME
Expand All @@ -117,7 +126,8 @@ class IrcBot extends Adapter
secure: options.usessl
selfSigned: options.fakessl
certExpired: options.certExpired
floodProtection: options.unflood
floodProtection: @unfloodProtection(options.unflood),
floodProtectionDelay: @unfloodProtectionDelay(options.unflood),

client_options['channels'] = options.rooms unless options.nickpass

Expand Down Expand Up @@ -176,7 +186,7 @@ class IrcBot extends Adapter

bot.addListener 'pm', (nick, message) ->
console.log('Got private message from %s: %s', nick, message)

if process.env.HUBOT_IRC_PRIVATE
return

Expand All @@ -201,7 +211,7 @@ class IrcBot extends Adapter

bot.addListener 'invite', (channel, from) ->
console.log('%s invite you to join %s', from, channel)

if not process.env.HUBOT_IRC_PRIVATE
bot.join channel

Expand Down

0 comments on commit cd1434e

Please sign in to comment.