2016-10-09 21:14:02 +02:00
|
|
|
"use strict";
|
|
|
|
|
2018-02-13 11:30:26 +01:00
|
|
|
const Chan = require("../../models/chan");
|
2017-11-10 21:44:14 +01:00
|
|
|
const Msg = require("../../models/msg");
|
2014-09-13 23:29:45 +02:00
|
|
|
|
2020-03-21 21:55:36 +01:00
|
|
|
module.exports = function (irc, network) {
|
2017-11-10 21:44:14 +01:00
|
|
|
const client = this;
|
|
|
|
|
2020-03-21 21:55:36 +01:00
|
|
|
irc.on("kick", function (data) {
|
2017-11-10 21:44:14 +01:00
|
|
|
const chan = network.getChannel(data.channel);
|
|
|
|
|
2014-09-13 23:29:45 +02:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-04 14:31:45 +02:00
|
|
|
|
2017-11-10 21:44:14 +01: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 16:30:47 +02:00
|
|
|
|
2016-03-08 11:16:20 +01:00
|
|
|
if (data.kicked === irc.user.nick) {
|
2017-11-16 21:32:03 +01:00
|
|
|
chan.users = new Map();
|
2018-02-13 11:30:26 +01:00
|
|
|
chan.state = Chan.State.PARTED;
|
2018-07-19 20:03:53 +02:00
|
|
|
|
|
|
|
client.emit("channel:state", {
|
|
|
|
chan: chan.id,
|
|
|
|
state: chan.state,
|
|
|
|
});
|
2014-09-13 23:29:45 +02:00
|
|
|
} else {
|
2017-11-16 21:32:03 +01:00
|
|
|
chan.removeUser(msg.target);
|
2014-09-13 23:29:45 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|