squelch-client
Version:
An IRC client for Node.js
56 lines (52 loc) • 1.54 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var getSender;
getSender = require('../../util').getSender;
module.exports = function() {
return function(client) {
client.notice = function(target, msg) {
var i, len, line, ref, results;
if (this.opt.autoSplitMessage) {
ref = this.splitText("NOTICE " + target, msg);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
line = ref[i];
this.raw("NOTICE " + target + " :" + line);
if (this.opt.triggerEventsForOwnMessages) {
results.push(this.emit('notice', {
from: this.nick(),
to: target,
msg: line
}));
} else {
results.push(void 0);
}
}
return results;
} else {
this.raw("NOTICE " + target + " :" + msg);
if (this.opt.triggerEventsForOwnMessages) {
return this.emit('notice', {
from: this.nick(),
to: target,
msg: msg
});
}
}
};
return client._.internalEmitter.on('raw', function(reply) {
var from, msg, to;
if (reply.command === 'NOTICE') {
from = getSender(reply);
to = reply.params[0];
msg = reply.params[1];
return client.emit('notice', {
from: from,
to: to,
msg: msg
});
}
});
};
};
}).call(this);