Use findUser
This commit is contained in:
parent
d06c279f02
commit
48d367e379
@ -11,10 +11,12 @@ module.exports = function(irc, network) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const user = chan.findUser(data.kicked);
|
||||||
|
|
||||||
if (data.kicked === irc.user.nick) {
|
if (data.kicked === irc.user.nick) {
|
||||||
chan.users = [];
|
chan.users = [];
|
||||||
} else {
|
} else {
|
||||||
chan.users = _.without(chan.users, _.find(chan.users, {nick: data.kicked}));
|
chan.users = _.without(chan.users, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
client.emit("users", {
|
client.emit("users", {
|
||||||
@ -24,7 +26,7 @@ module.exports = function(irc, network) {
|
|||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.KICK,
|
type: Msg.Type.KICK,
|
||||||
time: data.time,
|
time: data.time,
|
||||||
mode: chan.getMode(data.nick),
|
mode: user.mode,
|
||||||
from: data.nick,
|
from: data.nick,
|
||||||
target: data.kicked,
|
target: data.kicked,
|
||||||
text: data.message || "",
|
text: data.message || "",
|
||||||
|
@ -81,7 +81,7 @@ module.exports = function(irc, network) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = _.find(targetChan.users, {nick: mode.param});
|
const user = targetChan.findUser(mode.param);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _ = require("lodash");
|
|
||||||
var Msg = require("../../models/msg");
|
var Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
@ -25,7 +24,7 @@ module.exports = function(irc, network) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
network.channels.forEach((chan) => {
|
network.channels.forEach((chan) => {
|
||||||
var user = _.find(chan.users, {nick: data.nick});
|
const user = chan.findUser(data.nick);
|
||||||
if (typeof user === "undefined") {
|
if (typeof user === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ module.exports = function(irc, network) {
|
|||||||
chan: chan.id
|
chan: chan.id
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var user = _.find(chan.users, {nick: from});
|
const user = chan.findUser(from);
|
||||||
chan.users = _.without(chan.users, user);
|
chan.users = _.without(chan.users, user);
|
||||||
client.emit("users", {
|
client.emit("users", {
|
||||||
chan: chan.id
|
chan: chan.id
|
||||||
|
@ -7,8 +7,7 @@ module.exports = function(irc, network) {
|
|||||||
var client = this;
|
var client = this;
|
||||||
irc.on("quit", function(data) {
|
irc.on("quit", function(data) {
|
||||||
network.channels.forEach((chan) => {
|
network.channels.forEach((chan) => {
|
||||||
var from = data.nick;
|
const user = chan.findUser(data.nick);
|
||||||
var user = _.find(chan.users, {nick: from});
|
|
||||||
if (typeof user === "undefined") {
|
if (typeof user === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -22,7 +21,7 @@ module.exports = function(irc, network) {
|
|||||||
mode: user.mode || "",
|
mode: user.mode || "",
|
||||||
text: data.message || "",
|
text: data.message || "",
|
||||||
hostmask: data.ident + "@" + data.hostname,
|
hostmask: data.ident + "@" + data.hostname,
|
||||||
from: from
|
from: data.nick
|
||||||
});
|
});
|
||||||
chan.pushMessage(client, msg);
|
chan.pushMessage(client, msg);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user