Add support for WHOWAS
Fixes #2050 Co-Authored-By: jay2k1 <jay2k1@users.noreply.github.com>
This commit is contained in:
parent
c95b09cbac
commit
5091939aa4
@ -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">
|
<dl class="whois">
|
||||||
{{#if whois.account}}
|
{{#if whois.account}}
|
||||||
<dt>Logged in as:</dt>
|
<dt>Logged in as:</dt>
|
||||||
|
@ -5,23 +5,37 @@ const Msg = require("../../models/msg");
|
|||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
const client = this;
|
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);
|
let chan = network.getChannel(data.nick);
|
||||||
|
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
chan = client.createChannel({
|
// Do not create new windows for errors as they may contain illegal characters
|
||||||
type: Chan.Type.QUERY,
|
if (data.error) {
|
||||||
name: data.nick,
|
chan = network.channels[0];
|
||||||
});
|
} else {
|
||||||
|
chan = client.createChannel({
|
||||||
|
type: Chan.Type.QUERY,
|
||||||
|
name: data.nick,
|
||||||
|
});
|
||||||
|
|
||||||
client.emit("join", {
|
client.emit("join", {
|
||||||
shouldOpen: true,
|
shouldOpen: true,
|
||||||
network: network.uuid,
|
network: network.uuid,
|
||||||
chan: chan.getFilteredClone(true),
|
chan: chan.getFilteredClone(true),
|
||||||
index: network.addChannel(chan),
|
index: network.addChannel(chan),
|
||||||
});
|
});
|
||||||
chan.loadMessages(client, network);
|
chan.loadMessages(client, network);
|
||||||
client.save();
|
client.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg;
|
let msg;
|
||||||
@ -43,5 +57,5 @@ module.exports = function(irc, network) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chan.pushMessage(client, msg);
|
chan.pushMessage(client, msg);
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user