2014-06-19 15:28:53 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
var Chan = require("../models/chan");
|
|
|
|
var Msg = require("../models/msg");
|
|
|
|
|
2014-06-23 17:28:36 +00:00
|
|
|
module.exports = function(slate, network) {
|
|
|
|
var client = this;
|
|
|
|
slate.on("kick", function(data) {
|
2014-06-19 15:28:53 +00:00
|
|
|
var chan = _.findWhere(network.channels, {name: data.channel});
|
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-23 17:28:36 +00:00
|
|
|
if (data.client == slate.me) {
|
2014-06-19 15:28:53 +00:00
|
|
|
chan.users = [];
|
|
|
|
} else {
|
|
|
|
chan.users = _.without(chan.users, _.findWhere(chan.users, {name: data.client}));
|
|
|
|
}
|
2014-06-23 17:28:36 +00:00
|
|
|
client.emit("users", {
|
2014-06-19 15:28:53 +00:00
|
|
|
id: chan.id,
|
|
|
|
users: chan.users,
|
|
|
|
});
|
|
|
|
var msg = new Msg({
|
|
|
|
type: "kick",
|
|
|
|
from: data.nick,
|
|
|
|
text: data.client,
|
|
|
|
});
|
|
|
|
chan.addMsg(msg);
|
2014-06-23 17:28:36 +00:00
|
|
|
client.emit("msg", {
|
2014-06-19 15:28:53 +00:00
|
|
|
id: chan.id,
|
|
|
|
msg: msg,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|