Only auto join actual channels

Fixes #450
This commit is contained in:
Pavel Djundik 2016-07-03 11:39:29 +03:00
parent 491b3e3d0e
commit f57328ef5b
4 changed files with 12 additions and 4 deletions

View File

@ -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(",");

View File

@ -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
}

View File

@ -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) {

View File

@ -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);