Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Hacky fix for missing quit messages when spam control was ON

  • Loading branch information...
commit fb63a19afbced3309037d4ca8a9abe8f8696a487 1 parent c60b696
@valscion authored
Showing with 21 additions and 12 deletions.
  1. +21 −12 lib/irc.js
View
33 lib/irc.js
@@ -461,6 +461,7 @@ Client.prototype.prefixForMode = {};
Client.prototype.modeForPrefix = {};
Client.prototype.chans = {};
Client.prototype._whoisData = {};
+Client.prototype.queueEmpty = true;
Client.prototype.chanData = function( name, create ) { // {{{
var key = name.toLowerCase();
if ( create ) {
@@ -587,26 +588,31 @@ Client.prototype.disconnect = function ( message, callback ) { // {{{
}
message = message || "node-irc says goodbye";
var self = this;
- if ( self.conn.readyState == 'open' ) {
+ if ( self.conn.writable ) {
+ self.conn.removeAllListeners('close');
self.send( "QUIT", message );
}
- self.conn.requestedDisconnect = true;
if (typeof(callback) === 'function') {
self.conn.once('end', callback);
}
- self.conn.end();
+ var intv = setInterval(function () {
+ if (self.queueEmpty) {
+ self.conn.requestedDisconnect = true;
+ self.conn.end();
+ clearInterval(intv);
+ }
+ }, 100);
}; // }}}
Client.prototype.send = function(command) { // {{{
- var args = Array.prototype.slice.call(arguments);
+ var args = [];
+ for ( var k in arguments )
+ args.push(arguments[k]);
+ args[args.length-1] = ":" + args[args.length-1];
// Remove the command
args.shift();
- if ( args[args.length-1].match(/\s/) ) {
- args[args.length-1] = ":" + args[args.length-1];
- }
-
- if ( this.opt.debug )
+ if ( this.opt.debug && ! this.conn.requestedDisconnect )
util.log('SEND: ' + command + " " + args.join(" "));
if ( ! this.conn.requestedDisconnect ) {
@@ -624,6 +630,7 @@ Client.prototype.activateFloodProtection = function(interval) { // {{{
// Wrapper for the original function. Just put everything to on central
// queue.
this.send = function() {
+ self.queueEmpty = false;
cmdQueue.push(arguments);
};
@@ -631,6 +638,8 @@ Client.prototype.activateFloodProtection = function(interval) { // {{{
var args = cmdQueue.shift();
if (args) {
origSend.apply(self, args);
+ } else {
+ self.queueEmpty = true;
}
};
@@ -781,9 +790,9 @@ function parseMessage(line, stripColors) { // {{{
// Parse parameters
if ( line.indexOf(':') != -1 ) {
- match = line.match(/(.*)(?:^:|\s+:)(.*)/);
- middle = match[1].trimRight();
- trailing = match[2];
+ var index = line.indexOf(':');
+ middle = line.substr(0, index).replace(/ +$/, "");
+ trailing = line.substr(index+1);
}
else {
middle = line;
Please sign in to comment.
Something went wrong with that request. Please try again.