Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make flood protection timeout setting configurable. #84

Merged
merged 1 commit into from
Apr 14, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions docs/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Client
secure: false,
selfSigned: false,
floodProtection: false,
floodProtectionDelay: 1000,
stripColors: false
}

Expand All @@ -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
Expand Down Expand Up @@ -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
------
Expand Down
5 changes: 3 additions & 2 deletions lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function Client(server, nick, opt) {
secure: false,
selfSigned: false,
floodProtection: false,
floodProtectionDelay: 1000,
stripColors: false
};

Expand Down Expand Up @@ -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;
Expand Down