Use findUser

This commit is contained in:
Pavel Djundik 2017-07-11 17:30:47 +03:00
parent d06c279f02
commit 48d367e379
5 changed files with 9 additions and 9 deletions

View File

@ -11,10 +11,12 @@ module.exports = function(irc, network) {
return;
}
const user = chan.findUser(data.kicked);
if (data.kicked === irc.user.nick) {
chan.users = [];
} else {
chan.users = _.without(chan.users, _.find(chan.users, {nick: data.kicked}));
chan.users = _.without(chan.users, user);
}
client.emit("users", {
@ -24,7 +26,7 @@ module.exports = function(irc, network) {
var msg = new Msg({
type: Msg.Type.KICK,
time: data.time,
mode: chan.getMode(data.nick),
mode: user.mode,
from: data.nick,
target: data.kicked,
text: data.message || "",

View File

@ -81,7 +81,7 @@ module.exports = function(irc, network) {
return;
}
const user = _.find(targetChan.users, {nick: mode.param});
const user = targetChan.findUser(mode.param);
if (!user) {
return;
}

View File

@ -1,6 +1,5 @@
"use strict";
var _ = require("lodash");
var Msg = require("../../models/msg");
module.exports = function(irc, network) {
@ -25,7 +24,7 @@ module.exports = function(irc, network) {
}
network.channels.forEach((chan) => {
var user = _.find(chan.users, {nick: data.nick});
const user = chan.findUser(data.nick);
if (typeof user === "undefined") {
return;
}

View File

@ -18,7 +18,7 @@ module.exports = function(irc, network) {
chan: chan.id
});
} else {
var user = _.find(chan.users, {nick: from});
const user = chan.findUser(from);
chan.users = _.without(chan.users, user);
client.emit("users", {
chan: chan.id

View File

@ -7,8 +7,7 @@ module.exports = function(irc, network) {
var client = this;
irc.on("quit", function(data) {
network.channels.forEach((chan) => {
var from = data.nick;
var user = _.find(chan.users, {nick: from});
const user = chan.findUser(data.nick);
if (typeof user === "undefined") {
return;
}
@ -22,7 +21,7 @@ module.exports = function(irc, network) {
mode: user.mode || "",
text: data.message || "",
hostmask: data.ident + "@" + data.hostname,
from: from
from: data.nick
});
chan.pushMessage(client, msg);
});