Merge pull request #2554 from Jay2k1/whowas-support

WHOWAS support
This commit is contained in:
Pavel Djundik 2018-06-20 21:11:41 +03:00 committed by GitHub
commit b986025e1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 15 deletions

View file

@ -1,4 +1,8 @@
<p>{{> ../user_name nick=whois.nick}}</p>
<p>
{{> ../user_name nick=whois.nick}}
{{#if whois.whowas}} is offline, last information:{{/if}}
</p>
<dl class="whois">
{{#if whois.account}}
<dt>Logged in as:</dt>

View file

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