UNPKG

squelch-client

Version:
44 lines (39 loc) 1.08 kB
// Generated by CoffeeScript 1.10.0 (function() { var Promise, getSender; getSender = require('../../util').getSender; Promise = require('bluebird'); module.exports = function() { return function(client) { client.part = function(channel, reason) { var channels; if (reason == null) { reason = ''; } if (reason !== '') { reason = ' :' + reason; } channels = [].concat(channel); if (channels.length === 0) { return; } return this.raw("PART " + (channels.join() + reason)); }; return client._.internalEmitter.on('raw', function(reply) { var chan, me, nick, reason; if (reply.command === 'PART') { nick = getSender(reply); chan = reply.params[0]; reason = reply.params[1]; me = nick === client.nick(); return client.emit('part', { chan: chan, nick: nick, reason: reason, me: me }); } }); }; }; }).call(this);