squelch-client
Version:
An IRC client for Node.js
47 lines (41 loc) • 1.4 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var Promise, getReplyCode, promiseForEvent;
Promise = require('bluebird');
promiseForEvent = require('../../util').promiseForEvent;
getReplyCode = require('../../replies').getReplyCode;
module.exports = function() {
return function(client) {
client.topic = function(channel, topic) {
if (topic != null) {
return client.raw("TOPIC " + channel + " :" + topic);
}
return client.raw("TOPIC " + channel);
};
return client._.internalEmitter.on('raw', function(reply) {
var chan;
if (reply.command === getReplyCode('RPL_NOTOPIC')) {
client.emit('topic', {
chan: reply.params[1],
topic: ''
});
}
if (reply.command === getReplyCode('RPL_TOPIC')) {
client.emit('topic', {
chan: reply.params[1],
topic: reply.params[2]
});
}
if (reply.command === getReplyCode('RPL_TOPIC_WHO_TIME')) {
chan = client._.channels[reply.params[1].toLowerCase()];
chan._.topicSetter = reply.params[2];
return chan._.topicTime = client.emit('topicwho', {
chan: reply.params[1],
hostmask: reply.params[2],
time: new Date(parseInt(reply.params[3]))
});
}
});
};
};
}).call(this);