2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
|
|
|
irc.on("quit", function(data) {
|
2017-04-08 12:34:31 +00:00
|
|
|
network.channels.forEach((chan) => {
|
2017-07-11 14:30:47 +00:00
|
|
|
const user = chan.findUser(data.nick);
|
2014-09-13 21:29:45 +00:00
|
|
|
if (typeof user === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
chan.users = _.without(chan.users, user);
|
|
|
|
client.emit("users", {
|
2016-02-17 02:29:44 +00:00
|
|
|
chan: chan.id
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
var msg = new Msg({
|
2016-03-12 09:36:55 +00:00
|
|
|
time: data.time,
|
2014-09-13 21:29:45 +00:00
|
|
|
type: Msg.Type.QUIT,
|
2016-03-08 09:26:43 +00:00
|
|
|
mode: user.mode || "",
|
2016-02-23 16:22:41 +00:00
|
|
|
text: data.message || "",
|
2016-03-08 09:26:43 +00:00
|
|
|
hostmask: data.ident + "@" + data.hostname,
|
2017-07-11 14:30:47 +00:00
|
|
|
from: data.nick
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
2016-04-19 10:20:18 +00:00
|
|
|
chan.pushMessage(client, msg);
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|