Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #84 from lewinski/configure-flood-protection

Make flood protection timeout setting configurable.
  • Loading branch information...
commit afc39c3e0d32ab9b5831d3e14ebe3c40f9ddb967 2 parents 3b3c01f + c0f9bb0
@martynsmith authored
Showing with 14 additions and 4 deletions.
  1. +11 −2 docs/API.rst
  2. +3 −2 lib/irc.js
View
13 docs/API.rst
@@ -28,6 +28,7 @@ Client
selfSigned: false,
certExpired: false,
floodProtection: false,
+ floodProtectionDelay: 1000,
stripColors: false
}
@@ -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
@@ -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
------
View
5 lib/irc.js
@@ -47,6 +47,7 @@ function Client(server, nick, opt) {
selfSigned: false,
certExpired: false,
floodProtection: false,
+ floodProtectionDelay: 1000,
stripColors: false
};
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.