2022-06-18 20:25:21 -04:00
|
|
|
import {IrcEventHandler} from "../../client";
|
2016-10-09 15:14:02 -04:00
|
|
|
|
2022-06-18 20:25:21 -04:00
|
|
|
import Msg, {MessageType} from "../../models/msg";
|
2014-09-13 17:29:45 -04:00
|
|
|
|
2022-06-18 20:25:21 -04:00
|
|
|
export default <IrcEventHandler>function (irc, network) {
|
2017-11-10 15:44:14 -05:00
|
|
|
const client = this;
|
|
|
|
|
2020-03-21 16:55:36 -04:00
|
|
|
irc.on("quit", function (data) {
|
2017-04-08 08:34:31 -04:00
|
|
|
network.channels.forEach((chan) => {
|
2017-07-11 10:30:47 -04:00
|
|
|
const user = chan.findUser(data.nick);
|
2017-11-10 15:44:14 -05:00
|
|
|
|
2014-09-13 17:29:45 -04:00
|
|
|
if (typeof user === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-10 15:44:14 -05:00
|
|
|
|
|
|
|
const msg = new Msg({
|
2016-03-12 04:36:55 -05:00
|
|
|
time: data.time,
|
2022-06-18 20:25:21 -04:00
|
|
|
type: MessageType.QUIT,
|
2016-02-23 11:22:41 -05:00
|
|
|
text: data.message || "",
|
2016-03-08 04:26:43 -05:00
|
|
|
hostmask: data.ident + "@" + data.hostname,
|
2017-11-10 15:44:14 -05:00
|
|
|
from: user,
|
2014-09-13 17:29:45 -04:00
|
|
|
});
|
2016-04-19 06:20:18 -04:00
|
|
|
chan.pushMessage(client, msg);
|
2017-11-10 15:44:14 -05:00
|
|
|
|
2017-11-16 15:32:03 -05:00
|
|
|
chan.removeUser(user);
|
2014-09-13 17:29:45 -04:00
|
|
|
});
|
2019-09-15 15:35:18 -04:00
|
|
|
|
|
|
|
// If user with the nick we are trying to keep has quit, try to get this nick
|
|
|
|
if (network.keepNick === data.nick) {
|
|
|
|
irc.changeNick(network.keepNick);
|
|
|
|
network.keepNick = null;
|
|
|
|
}
|
2014-09-13 17:29:45 -04:00
|
|
|
});
|
|
|
|
};
|