Skip to content

Commit

Permalink
Merge pull request #299 from martynsmith/jirwin/add-missing-newlines
Browse files Browse the repository at this point in the history
fix(style): Clean up various style issues in irc.js
  • Loading branch information
Chris Nehren committed Jan 12, 2015
2 parents b8a4c46 + 38d0646 commit 406119c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,14 @@ function Client(server, nick, opt) {

EventEmitter.call(this);
}

util.inherits(Client, EventEmitter);

Client.prototype.conn = null;
Client.prototype.prefixForMode = {};
Client.prototype.modeForPrefix = {};
Client.prototype.chans = {};
Client.prototype._whoisData = {};

Client.prototype.chanData = function(name, create) {
var key = name.toLowerCase();
if (create) {
Expand All @@ -632,6 +632,7 @@ Client.prototype.chanData = function(name, create) {

return this.chans[key];
};

Client.prototype.connect = function(retryCount, callback) {
if (typeof (retryCount) === 'function') {
callback = retryCount;
Expand Down Expand Up @@ -814,6 +815,7 @@ Client.prototype.disconnect = function(message, callback) {
}
self.conn.end();
};

Client.prototype.send = function(command) {
var args = Array.prototype.slice.call(arguments);

Expand All @@ -830,6 +832,7 @@ Client.prototype.send = function(command) {
this.conn.write(args.join(' ') + '\r\n');
}
};

Client.prototype.activateFloodProtection = function(interval) {

var cmdQueue = [],
Expand Down Expand Up @@ -880,6 +883,7 @@ Client.prototype.join = function(channel, callback) {
});
this.send.apply(this, ['JOIN'].concat(channel.split(' ')));
};

Client.prototype.part = function(channel, message, callback) {
if (typeof (message) === 'function') {
callback = message;
Expand All @@ -901,6 +905,7 @@ Client.prototype.part = function(channel, message, callback) {
this.send('PART', channel);
}
};

Client.prototype.action = function(channel, text) {
var self = this;
if (typeof text !== 'undefined') {
Expand All @@ -911,6 +916,7 @@ Client.prototype.action = function(channel, text) {
});
}
};

Client.prototype._splitLongLines = function(words, maxLength, destination) {
if (words.length < maxLength) {
destination.push(words);
Expand Down Expand Up @@ -938,12 +944,15 @@ Client.prototype._splitLongLines = function(words, maxLength, destination) {
destination.push(part);
return this._splitLongLines(words.substring(cutPos + 1, words.length), maxLength, destination);
};

Client.prototype.say = function(target, text) {
this._speak('PRIVMSG', target, text);
};

Client.prototype.notice = function(target, text) {
this._speak('NOTICE', target, text);
};

Client.prototype._speak = function(kind, target, text) {
var self = this;
var maxLength = this.maxLineLength - target.length;
Expand All @@ -961,6 +970,7 @@ Client.prototype._speak = function(kind, target, text) {
});
}
};

Client.prototype.whois = function(nick, callback) {
if (typeof callback === 'function') {
var callbackWrapper = function(info) {
Expand All @@ -973,23 +983,27 @@ Client.prototype.whois = function(nick, callback) {
}
this.send('WHOIS', nick);
};

Client.prototype.list = function() {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift('LIST');
this.send.apply(this, args);
};

Client.prototype._addWhoisData = function(nick, key, value, onlyIfExists) {
if (onlyIfExists && !this._whoisData[nick]) return;
this._whoisData[nick] = this._whoisData[nick] || {nick: nick};
this._whoisData[nick][key] = value;
};

Client.prototype._clearWhoisData = function(nick) {
// Ensure that at least the nick exists before trying to return
this._addWhoisData(nick, 'nick', nick);
var data = this._whoisData[nick];
delete this._whoisData[nick];
return data;
};

Client.prototype._handleCTCP = function(from, to, text, type, message) {
text = text.slice(1);
text = text.slice(0, text.indexOf('\u0001'));
Expand All @@ -1003,9 +1017,11 @@ Client.prototype._handleCTCP = function(from, to, text, type, message) {
if (parts[0] === 'PING' && type === 'privmsg' && parts.length > 1)
this.ctcp(from, 'notice', text);
};

Client.prototype.ctcp = function(to, type, text) {
return this[type === 'privmsg' ? 'say' : 'notice'](to, '\1' + text + '\1');
};

Client.prototype.convertEncoding = function(str) {
var self = this;

Expand Down

0 comments on commit 406119c

Please sign in to comment.