thelounge/src/plugins/irc-events/kick.js

38 lines
762 B
JavaScript
Raw Normal View History

"use strict";
const _ = require("lodash");
const Msg = require("../../models/msg");
2014-09-13 23:29:45 +02:00
module.exports = function(irc, network) {
const client = this;
2014-09-13 23:29:45 +02:00
irc.on("kick", function(data) {
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
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) {
2014-09-13 23:29:45 +02:00
chan.users = [];
} else {
chan.users = _.without(chan.users, msg.target);
2014-09-13 23:29:45 +02:00
}
2014-10-04 14:31:45 +02:00
2014-09-13 23:29:45 +02:00
client.emit("users", {
chan: chan.id,
2014-09-13 23:29:45 +02:00
});
});
};