coffea
Version:
event based and extensible nodejs irc client library with multi-network support
28 lines (24 loc) • 592 B
JavaScript
/*jslint node: true*/
;
var utils = require('../utils');
/**
* plugin to reply to PINGs.
*
* @return {Function}
* @api public
*/
module.exports = function(){
return function (irc) {
irc.on('data', function (err, msg) {
var network = msg.network;
if ('PONG' === msg.command) {
utils.emit(irc, network, 'pong');
}
if ('PING' !== msg.command) {
return;
}
irc.write('PONG :' + msg.trailing);
utils.emit(irc, network, 'ping');
});
};
};