Correctly create new windows for private messages
This commit is contained in:
parent
b19e79c48f
commit
54526215a4
@ -23,16 +23,22 @@ module.exports = function(irc, network) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function handleMessage(data) {
|
function handleMessage(data) {
|
||||||
// First, try to find current target
|
// Server messages go to server window, no questions asked
|
||||||
var chan = _.find(network.channels, {name: data.target});
|
if (data.from_server) {
|
||||||
if (typeof chan === "undefined") {
|
chan = network.channels[0];
|
||||||
// If current target doesn't exist, try to find by nick
|
} else {
|
||||||
chan = _.find(network.channels, {name: data.nick});
|
var target = data.target;
|
||||||
// If neither target or nick channels exist, create one for the nick
|
|
||||||
|
// If the message is targeted at us, use sender as target instead
|
||||||
|
if (target.toLowerCase() === irc.user.nick.toLowerCase()) {
|
||||||
|
target = data.nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
var chan = _.find(network.channels, {name: target});
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
chan = new Chan({
|
chan = new Chan({
|
||||||
type: Chan.Type.QUERY,
|
type: Chan.Type.QUERY,
|
||||||
name: data.nick
|
name: target
|
||||||
});
|
});
|
||||||
network.channels.push(chan);
|
network.channels.push(chan);
|
||||||
client.emit("join", {
|
client.emit("join", {
|
||||||
@ -42,11 +48,6 @@ module.exports = function(irc, network) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server messages go to server window
|
|
||||||
if (data.from_server) {
|
|
||||||
chan = network.channels[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
var self = data.nick === irc.user.nick;
|
var self = data.nick === irc.user.nick;
|
||||||
|
|
||||||
// Self messages are never highlighted
|
// Self messages are never highlighted
|
||||||
|
Loading…
Reference in New Issue
Block a user