Skip to content

Commit

Permalink
Merge pull request martynsmith#84 from lewinski/configure-flood-prote…
Browse files Browse the repository at this point in the history
…ction

Make flood protection timeout setting configurable.
  • Loading branch information
martynsmith committed Apr 14, 2012
2 parents 3b3c01f + c0f9bb0 commit afc39c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions docs/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Client
selfSigned: false,
certExpired: false,
floodProtection: false,
floodProtectionDelay: 1000,
stripColors: false
}

Expand All @@ -41,6 +42,9 @@ Client
`Client.activateFloodProtection()` to activate flood protection after
instantiating the client.

`floodProtectionDelay` sets the amount of time that the client will wait
between sending subsequent messages when `floodProtection` is enabled.

`stripColors` removes mirc colors (0x03 followed by one or two ascii
numbers for foreground,background) and ircII "effect" codes (0x02
bold, 0x1f underline, 0x16 reverse, 0x0f reset) from the entire
Expand Down Expand Up @@ -131,11 +135,16 @@ Client
:param string message: Optional message to send when disconnecting.
:param function callback: Optional callback

.. js:function:: Client.activateFloodProtection()
.. js:function:: Client.activateFloodProtection(interval)

Activates flood protection "after the fact". You can also use
`floodProtection` while instantiating the Client to enable flood
protection.
protection, and `floodProtectionDelay` to set the default message
interval.

:param integer interval: Optional configuration for amount of time
to wait between messages. Takes value from client configuration
if unspecified.

Events
------
Expand Down
5 changes: 3 additions & 2 deletions lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Client(server, nick, opt) {
selfSigned: false,
certExpired: false,
floodProtection: false,
floodProtectionDelay: 1000,
stripColors: false
};

Expand Down Expand Up @@ -603,10 +604,10 @@ Client.prototype.send = function(command) { // {{{
this.conn.write(command + " " + args.join(" ") + "\r\n");
}
}; // }}}
Client.prototype.activateFloodProtection = function() { // {{{
Client.prototype.activateFloodProtection = function(interval) { // {{{

var cmdQueue = [],
safeInterval = 1000,
safeInterval = interval || this.opt.floodProtectionDelay,
self = this,
origSend = this.send,
dequeue;
Expand Down

0 comments on commit afc39c3

Please sign in to comment.