thelounge/server/plugins/irc-events/chghost.ts

31 lines
837 B
TypeScript
Raw Normal View History

import {IrcEventHandler} from "../../client";
2017-09-19 17:22:50 +02:00
import Msg, {MessageType} from "../../models/msg";
2017-09-19 17:22:50 +02:00
export default <IrcEventHandler>function (irc, network) {
2017-09-19 17:22:50 +02:00
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) {
2017-09-19 17:22:50 +02:00
network.channels.forEach((chan) => {
const user = chan.findUser(data.nick);
if (typeof user === "undefined") {
return;
}
const msg = new Msg({
time: data.time,
type: MessageType.CHGHOST,
new_ident: data.ident !== data.new_ident ? data.new_ident : "",
2018-06-20 17:30:32 +02:00
new_host: data.hostname !== data.new_hostname ? data.new_hostname : "",
self: data.nick === irc.user.nick,
from: user,
});
2017-09-19 17:22:50 +02:00
chan.pushMessage(client, msg);
});
});
};