thelounge/src/plugins/irc-events/part.js
Reto Brunner 0d209fce09 Clear obsolete mentions upon channel part
Currently, the mentions only track the chanID and MsgID.
However, when we part a channel the chanID becomes orphaned.

Considering that mentions from a parted channel probably aren't
that relevant, let's automatically clear them when we part.
Should the user really want to look at them again, they can re-join
the channel and get the scroll back that way.
2021-12-29 16:46:16 +01:00

33 lines
654 B
JavaScript

"use strict";
const Msg = require("../../models/msg");
module.exports = function (irc, network) {
const client = this;
irc.on("part", function (data) {
const chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {
return;
}
const user = chan.getUser(data.nick);
const msg = new Msg({
type: Msg.Type.PART,
time: data.time,
text: data.message || "",
hostmask: data.ident + "@" + data.hostname,
from: user,
self: data.nick === irc.user.nick,
});
chan.pushMessage(client, msg);
if (data.nick === irc.user.nick) {
client.part(network, chan);
} else {
chan.removeUser(user);
}
});
};