Handle kick
This commit is contained in:
parent
627b698221
commit
356851c3f2
@ -4,18 +4,15 @@ var Msg = require("../../models/msg");
|
|||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("kick", function(data) {
|
irc.on("kick", function(data) {
|
||||||
var from = data.nick;
|
|
||||||
var chan = _.find(network.channels, {name: data.channel});
|
var chan = _.find(network.channels, {name: data.channel});
|
||||||
var mode = chan.getMode(from);
|
|
||||||
|
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.client === irc.user.nick) {
|
if (data.kicked === irc.user.nick) {
|
||||||
chan.users = [];
|
chan.users = [];
|
||||||
} else {
|
} else {
|
||||||
chan.users = _.without(chan.users, _.find(chan.users, {name: data.client}));
|
chan.users = _.without(chan.users, _.find(chan.users, {name: data.kicked}));
|
||||||
}
|
}
|
||||||
|
|
||||||
client.emit("users", {
|
client.emit("users", {
|
||||||
@ -24,10 +21,11 @@ module.exports = function(irc, network) {
|
|||||||
|
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.KICK,
|
type: Msg.Type.KICK,
|
||||||
mode: mode,
|
mode: chan.getMode(data.nick),
|
||||||
from: from,
|
from: data.nick,
|
||||||
target: data.client,
|
target: data.kicked,
|
||||||
text: data.message || "",
|
text: data.message || "",
|
||||||
|
highlight: data.kicked === irc.user.nick,
|
||||||
self: data.nick === irc.user.nick
|
self: data.nick === irc.user.nick
|
||||||
});
|
});
|
||||||
chan.messages.push(msg);
|
chan.messages.push(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user