thelounge/src/plugins/irc-events/chghost.js
2018-04-27 13:16:23 +03:00

31 lines
767 B
JavaScript

"use strict";
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
const client = this;
// If server supports CHGHOST cap, then changing the hostname does not require
// sending PART and JOIN, which means less work for us over all
irc.on("user updated", function(data) {
network.channels.forEach((chan) => {
const user = chan.findUser(data.nick);
if (typeof user === "undefined") {
return;
}
const msg = new Msg({
time: data.time,
type: Msg.Type.CHGHOST,
new_ident: data.ident !== data.new_ident ? data.new_ident : "",
new_host: data.hostname !== data.new_host ? data.new_host : "",
self: data.nick === irc.user.nick,
from: user,
});
chan.pushMessage(client, msg);
});
});
};