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

39 lines
778 B
JavaScript
Raw Normal View History

"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("kick", function(data) {
2016-03-20 14:28:47 +00:00
var chan = network.getChannel(data.channel);
2014-09-13 21:29:45 +00:00
if (typeof chan === "undefined") {
return;
}
2014-10-04 12:31:45 +00:00
2017-07-11 14:30:47 +00:00
const user = chan.findUser(data.kicked);
2016-03-08 10:16:20 +00:00
if (data.kicked === irc.user.nick) {
2014-09-13 21:29:45 +00:00
chan.users = [];
} else {
2017-07-11 14:30:47 +00:00
chan.users = _.without(chan.users, user);
2014-09-13 21:29:45 +00:00
}
2014-10-04 12:31:45 +00:00
2014-09-13 21:29:45 +00:00
client.emit("users", {
chan: chan.id
2014-09-13 21:29:45 +00:00
});
2014-10-04 12:31:45 +00:00
2014-09-13 21:29:45 +00:00
var msg = new Msg({
type: Msg.Type.KICK,
2016-03-12 09:36:55 +00:00
time: data.time,
2017-07-11 14:30:47 +00:00
mode: user.mode,
2016-03-08 10:16:20 +00:00
from: data.nick,
target: data.kicked,
2016-02-23 16:22:41 +00:00
text: data.message || "",
2016-03-08 10:16:20 +00:00
highlight: data.kicked === irc.user.nick,
self: data.nick === irc.user.nick
2014-09-13 21:29:45 +00:00
});
chan.pushMessage(client, msg);
2014-09-13 21:29:45 +00:00
});
};