Use findUser
This commit is contained in:
parent
d06c279f02
commit
48d367e379
@ -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 || "",
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user