Merge pull request #34 from xPaw/fix-closing-channel

Fix #30: Close channel on the client as soon as close event is registered
This commit is contained in:
Jérémie Astori 2016-02-18 23:23:36 -05:00
commit 172c8d534a

View File

@ -4,17 +4,15 @@ module.exports = function(network, chan, cmd, args) {
if (cmd !== "part" && cmd !== "leave" && cmd !== "close") { if (cmd !== "part" && cmd !== "leave" && cmd !== "close") {
return; return;
} }
var client = this; if (chan.type !== "query") {
if (chan.type === "query") {
network.channels = _.without(network.channels, chan);
client.emit("part", {
chan: chan.id
});
} else {
var irc = network.irc; var irc = network.irc;
if (args.length === 0) { if (args.length === 0) {
args.push(chan.name); args.push(chan.name);
} }
irc.part(args); irc.part(args);
} }
network.channels = _.without(network.channels, chan);
this.emit("part", {
chan: chan.id
});
}; };