2022-06-19 00:25:21 +00:00
|
|
|
import {IrcEventHandler} from "../../client";
|
2016-10-09 19:14:02 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
import Msg, {MessageType} from "../../models/msg";
|
2014-09-13 21:29:45 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
export default <IrcEventHandler>function (irc, network) {
|
2017-11-10 20:44:14 +00:00
|
|
|
const client = this;
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
irc.on("part", function (data) {
|
2022-06-19 00:25:21 +00:00
|
|
|
if (!data.channel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-10 20:44:14 +00:00
|
|
|
const chan = network.getChannel(data.channel);
|
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-10 20:44:14 +00:00
|
|
|
|
2019-01-21 16:07:00 +00:00
|
|
|
const user = chan.getUser(data.nick);
|
|
|
|
const msg = new Msg({
|
2022-06-19 00:25:21 +00:00
|
|
|
type: MessageType.PART,
|
2019-01-21 16:07:00 +00:00
|
|
|
time: data.time,
|
|
|
|
text: data.message || "",
|
|
|
|
hostmask: data.ident + "@" + data.hostname,
|
|
|
|
from: user,
|
|
|
|
self: data.nick === irc.user.nick,
|
|
|
|
});
|
|
|
|
chan.pushMessage(client, msg);
|
|
|
|
|
2017-11-10 20:44:14 +00:00
|
|
|
if (data.nick === irc.user.nick) {
|
2021-12-29 14:46:06 +00:00
|
|
|
client.part(network, chan);
|
2014-09-13 21:29:45 +00:00
|
|
|
} else {
|
2017-11-16 20:32:03 +00:00
|
|
|
chan.removeUser(user);
|
2014-09-13 21:29:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|