diff --git a/lib/irc.js b/lib/irc.js index eddd4a17..de1ca9b2 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -611,7 +611,6 @@ function Client(server, nick, opt) { EventEmitter.call(this); } - util.inherits(Client, EventEmitter); Client.prototype.conn = null; @@ -619,6 +618,7 @@ Client.prototype.prefixForMode = {}; Client.prototype.modeForPrefix = {}; Client.prototype.chans = {}; Client.prototype._whoisData = {}; + Client.prototype.chanData = function(name, create) { var key = name.toLowerCase(); if (create) { @@ -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; @@ -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); @@ -830,6 +832,7 @@ Client.prototype.send = function(command) { this.conn.write(args.join(' ') + '\r\n'); } }; + Client.prototype.activateFloodProtection = function(interval) { var cmdQueue = [], @@ -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; @@ -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') { @@ -911,6 +916,7 @@ Client.prototype.action = function(channel, text) { }); } }; + Client.prototype._splitLongLines = function(words, maxLength, destination) { if (words.length < maxLength) { destination.push(words); @@ -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; @@ -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) { @@ -973,16 +983,19 @@ 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); @@ -990,6 +1003,7 @@ Client.prototype._clearWhoisData = function(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')); @@ -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;