2016-10-09 15:14:02 -04:00
|
|
|
"use strict";
|
|
|
|
|
2017-11-10 15:44:14 -05:00
|
|
|
const _ = require("lodash");
|
|
|
|
const Msg = require("../../models/msg");
|
2014-09-13 17:29:45 -04:00
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
2017-11-10 15:44:14 -05:00
|
|
|
const client = this;
|
|
|
|
|
2014-09-13 17:29:45 -04:00
|
|
|
irc.on("kick", 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;
|
|
|
|
}
|
2014-10-04 08:31:45 -04:00
|
|
|
|
2017-11-10 15:44:14 -05:00
|
|
|
const msg = new Msg({
|
|
|
|
type: Msg.Type.KICK,
|
|
|
|
time: data.time,
|
|
|
|
from: chan.getUser(data.nick),
|
|
|
|
target: chan.getUser(data.kicked),
|
|
|
|
text: data.message || "",
|
|
|
|
highlight: data.kicked === irc.user.nick,
|
|
|
|
self: data.nick === irc.user.nick,
|
|
|
|
});
|
|
|
|
chan.pushMessage(client, msg);
|
2017-07-11 10:30:47 -04:00
|
|
|
|
2016-03-08 05:16:20 -05:00
|
|
|
if (data.kicked === irc.user.nick) {
|
2014-09-13 17:29:45 -04:00
|
|
|
chan.users = [];
|
|
|
|
} else {
|
2017-11-10 15:44:14 -05:00
|
|
|
chan.users = _.without(chan.users, msg.target);
|
2014-09-13 17:29:45 -04:00
|
|
|
}
|
2014-10-04 08:31:45 -04:00
|
|
|
|
2014-09-13 17:29:45 -04:00
|
|
|
client.emit("users", {
|
2017-11-15 01:35:15 -05:00
|
|
|
chan: chan.id,
|
2014-09-13 17:29:45 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|