From 5091939aa4b59a9c095b76b14cbde337f41969c0 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 20 Jun 2018 21:01:45 +0300 Subject: [PATCH] Add support for WHOWAS Fixes #2050 Co-Authored-By: jay2k1 --- client/views/actions/whois.tpl | 6 ++++- src/plugins/irc-events/whois.js | 42 ++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/client/views/actions/whois.tpl b/client/views/actions/whois.tpl index c19d4a6b..8f54dec9 100644 --- a/client/views/actions/whois.tpl +++ b/client/views/actions/whois.tpl @@ -1,4 +1,8 @@ -

{{> ../user_name nick=whois.nick}}

+

+ {{> ../user_name nick=whois.nick}} + {{#if whois.whowas}} is offline, last information:{{/if}} +

+
{{#if whois.account}}
Logged in as:
diff --git a/src/plugins/irc-events/whois.js b/src/plugins/irc-events/whois.js index ef6128be..54d6f954 100644 --- a/src/plugins/irc-events/whois.js +++ b/src/plugins/irc-events/whois.js @@ -5,23 +5,37 @@ const Msg = require("../../models/msg"); module.exports = function(irc, network) { const client = this; - irc.on("whois", function(data) { + + irc.on("whois", handleWhois); + + irc.on("whowas", (data) => { + data.whowas = true; + + handleWhois(data); + }); + + function handleWhois(data) { let chan = network.getChannel(data.nick); if (typeof chan === "undefined") { - chan = client.createChannel({ - type: Chan.Type.QUERY, - name: data.nick, - }); + // Do not create new windows for errors as they may contain illegal characters + if (data.error) { + chan = network.channels[0]; + } else { + chan = client.createChannel({ + type: Chan.Type.QUERY, + name: data.nick, + }); - client.emit("join", { - shouldOpen: true, - network: network.uuid, - chan: chan.getFilteredClone(true), - index: network.addChannel(chan), - }); - chan.loadMessages(client, network); - client.save(); + client.emit("join", { + shouldOpen: true, + network: network.uuid, + chan: chan.getFilteredClone(true), + index: network.addChannel(chan), + }); + chan.loadMessages(client, network); + client.save(); + } } let msg; @@ -43,5 +57,5 @@ module.exports = function(irc, network) { } chan.pushMessage(client, msg); - }); + } };