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