2016-10-09 15:14:02 -04:00
|
|
|
"use strict";
|
|
|
|
|
2017-11-10 15:44:14 -05:00
|
|
|
const Msg = require("../../models/msg");
|
2014-09-13 17:29:45 -04:00
|
|
|
|
2020-03-21 16:55:36 -04:00
|
|
|
module.exports = function (irc, network) {
|
2017-11-10 15:44:14 -05:00
|
|
|
const client = this;
|
|
|
|
|
2020-03-21 16:55:36 -04:00
|
|
|
irc.on("part", function (data) {
|
2017-11-10 15:44:14 -05:00
|
|
|
const chan = network.getChannel(data.channel);
|
|
|
|
|
2014-09-13 17:29:45 -04:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-10 15:44:14 -05:00
|
|
|
|
2019-01-21 11:07:00 -05:00
|
|
|
const user = chan.getUser(data.nick);
|
|
|
|
const msg = new Msg({
|
|
|
|
type: Msg.Type.PART,
|
|
|
|
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 15:44:14 -05:00
|
|
|
if (data.nick === irc.user.nick) {
|
2021-12-29 09:46:06 -05:00
|
|
|
client.part(network, chan);
|
2014-09-13 17:29:45 -04:00
|
|
|
} else {
|
2017-11-16 15:32:03 -05:00
|
|
|
chan.removeUser(user);
|
2014-09-13 17:29:45 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|