Permalink
Browse files

Make flood protection timeout setting configurable.

  • Loading branch information...
1 parent 02593ba commit c0f9bb0140e14187bd53a10913ebf2914f57f0b4 @lewinski lewinski committed Feb 3, 2012
Showing with 14 additions and 4 deletions.
  1. +11 −2 docs/API.rst
  2. +3 −2 lib/irc.js
View
@@ -27,6 +27,7 @@ Client
secure: false,
selfSigned: false,
floodProtection: false,
+ floodProtectionDelay: 1000,
stripColors: false
}
@@ -39,6 +40,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
@@ -129,11 +133,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
------
View
@@ -46,6 +46,7 @@ function Client(server, nick, opt) {
secure: false,
selfSigned: false,
floodProtection: false,
+ floodProtectionDelay: 1000,
stripColors: false
};
@@ -598,10 +599,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;

0 comments on commit c0f9bb0

Please sign in to comment.