From f57328ef5ba30aaa413421c4d6f798bcb49b6ab0 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 3 Jul 2016 11:39:29 +0300 Subject: [PATCH] Only auto join actual channels Fixes #450 --- src/models/network.js | 2 +- src/plugins/inputs/invite.js | 4 +++- src/plugins/inputs/part.js | 5 +++-- src/plugins/irc-events/connection.js | 5 +++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/models/network.js b/src/models/network.js index 9e8ce9a8..209cfefc 100644 --- a/src/models/network.js +++ b/src/models/network.js @@ -74,7 +74,7 @@ Network.prototype.export = function() { ]); network.join = _.map( - _.filter(this.channels, {type: "channel"}), + _.filter(this.channels, {type: Chan.Type.CHANNEL}), "name" ).join(","); diff --git a/src/plugins/inputs/invite.js b/src/plugins/inputs/invite.js index 8eefcbac..d4543ee3 100644 --- a/src/plugins/inputs/invite.js +++ b/src/plugins/inputs/invite.js @@ -1,3 +1,5 @@ +var Chan = require("../../models/chan"); + exports.commands = ["invite"]; exports.input = function(network, chan, cmd, args) { @@ -5,7 +7,7 @@ exports.input = function(network, chan, cmd, args) { if (args.length === 2) { irc.raw("INVITE", args[0], args[1]); // Channel provided in the command - } else if (args.length === 1 && chan.type === "channel") { + } else if (args.length === 1 && chan.type === Chan.Type.CHANNEL) { irc.raw("INVITE", args[0], chan.name); // Current channel } diff --git a/src/plugins/inputs/part.js b/src/plugins/inputs/part.js index 66f626d8..5a480b3f 100644 --- a/src/plugins/inputs/part.js +++ b/src/plugins/inputs/part.js @@ -1,11 +1,12 @@ var _ = require("lodash"); var Msg = require("../../models/msg"); +var Chan = require("../../models/chan"); exports.commands = ["close", "leave", "part"]; exports.allowDisconnected = true; exports.input = function(network, chan, cmd, args) { - if (chan.type === "lobby") { + if (chan.type === Chan.Type.LOBBY) { chan.pushMessage(this, new Msg({ type: Msg.Type.ERROR, text: "You can not part from networks, use /quit instead." @@ -18,7 +19,7 @@ exports.input = function(network, chan, cmd, args) { chan: chan.id }); - if (chan.type === "channel") { + if (chan.type === Chan.Type.CHANNEL) { this.save(); if (network.irc) { diff --git a/src/plugins/irc-events/connection.js b/src/plugins/irc-events/connection.js index db84632c..60ba682b 100644 --- a/src/plugins/irc-events/connection.js +++ b/src/plugins/irc-events/connection.js @@ -1,6 +1,7 @@ var _ = require("lodash"); var identd = require("../../identd"); var Msg = require("../../models/msg"); +var Chan = require("../../models/chan"); module.exports = function(irc, network) { var client = this; @@ -32,6 +33,10 @@ module.exports = function(irc, network) { } network.channels.forEach(function(chan) { + if (chan.type !== Chan.Type.CHANNEL) { + return; + } + setTimeout(function() { network.irc.join(chan.name); }, delay);