Fix creating duplicate query windows when our nick is not known

This commit is contained in:
Pavel Djundik 2016-03-08 12:13:36 +02:00 committed by Maxime Poulin
parent 9ab71b2588
commit 627b698221

View File

@ -23,22 +23,23 @@ module.exports = function(irc, network) {
}); });
function handleMessage(data) { function handleMessage(data) {
var target = data.target; // First, try to find current target
if (target.toLowerCase() === irc.user.nick.toLowerCase()) { var chan = _.find(network.channels, {name: data.target});
target = data.nick;
}
var chan = _.find(network.channels, {name: target});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ // If current target doesn't exist, try to find by nick
type: Chan.Type.QUERY, chan = _.find(network.channels, {name: data.nick});
name: data.nick // If neither target or nick channels exist, create one for the nick
}); if (typeof chan === "undefined") {
network.channels.push(chan); chan = new Chan({
client.emit("join", { type: Chan.Type.QUERY,
network: network.id, name: data.nick
chan: chan });
}); network.channels.push(chan);
client.emit("join", {
network: network.id,
chan: chan
});
}
} }
var self = data.nick === irc.user.nick; var self = data.nick === irc.user.nick;