Work on ban list and channel ranks

This commit is contained in:
calzoneman 2014-01-08 20:12:02 -06:00
parent 2d7b0fe2ac
commit 9306200a87
9 changed files with 118 additions and 108 deletions

View file

@ -7,6 +7,7 @@ var Logger = require("./logger");
var AsyncQueue = require("./asyncqueue");
var MakeEmitter = require("./emitter");
var InfoGetter = require("./get-info");
var ChatCommand = require("./chatcommand");
var fs = require("fs");
var path = require("path");
@ -664,7 +665,7 @@ Channel.prototype.handleNameBan = function (actor, name, reason) {
// If in the channel already, kick the banned user
for (var i = 0; i < self.users.length; i++) {
if (self.users[i].name.toLowerCase() == name) {
self.kick(self.users[i], "You're banned!");
self.users[i].kick("You're banned!");
break;
}
}
@ -785,7 +786,7 @@ Channel.prototype.banIP = function (actor, ip, name, reason, range) {
// If in the channel already, kick the banned user
for (var i = 0; i < self.users.length; i++) {
if (self.users[i].ip === ip) {
self.kick(self.users[i], "You're banned!");
self.users[i].kick("You're banned!");
break;
}
}
@ -842,6 +843,21 @@ Channel.prototype.sendBanlist = function (users) {
});
}
for (var name in self.namebans) {
bans.push({
ip: "*",
name: name,
reason: self.namebans[name].reason,
bannedby: self.namebans[name].bannedby
});
unmaskedbans.push({
ip: "*",
name: name,
reason: self.namebans[name].reason,
bannedby: self.namebans[name].bannedby
});
}
users.forEach(function (u) {
if (!self.hasPermission(u, "ban")) {
return;
@ -855,6 +871,24 @@ Channel.prototype.sendBanlist = function (users) {
});
};
/**
* Sends the channel ranks list
*/
Channel.prototype.sendChannelRanks = function (users) {
var self = this;
db.channels.allRanks(self.name, function (err, ranks) {
if (err) {
return;
}
users.forEach(function (u) {
if (u.rank >= 3) {
u.socket.emit("channelRanks", ranks);
}
});
});
};
/**
* Sends the chat filter list
*/

View file

@ -297,19 +297,19 @@ function handleKick(chan, user, args) {
chan.logger.log("*** " + user.name + " kicked " + args[0]);
args[0] = "";
var reason = args.join(" ");
chan.kick(kickee, reason);
kickee.kick(reason);
}
}
}
function handleIPBan(chan, user, args) {
chan.tryIPBan(user, args[0], args[1]);
chan.handleBanAllIP(user, args[0], "", args[1]);
// Ban the name too for good measure
chan.tryNameBan(user, args[0]);
chan.handleNameBan(user, args[0], "");
}
function handleBan(chan, user, args) {
chan.tryNameBan(user, args[0]);
chan.handleNameBan(user, args[0], "");
}
function handleUnban(chan, user, args) {

View file

@ -549,7 +549,7 @@ module.exports = {
}
db.query("INSERT INTO `chan_" + chan + "_bans` (ip, name, reason, bannedby) " +
"VALUES (?, ?, ?, ?)", [ip, name, reason, bannedby], callback);
"VALUES (?, ?, ?, ?)", [ip, name, note, bannedby], callback);
},
/**

View file

@ -225,7 +225,7 @@ Server.prototype.isChannelLoaded = function (name) {
Server.prototype.getChannel = function (name) {
var cname = name.toLowerCase();
for (var i = 0; i < this.channels.length; i++) {
if (this.channels[i].canonical_name === cname)
if (this.channels[i].uniqueName === cname)
return this.channels[i];
}

View file

@ -376,6 +376,10 @@ User.prototype.initChannelCallbacks = function () {
self.channel.sendBanlist([self]);
});
wrap("requestChannelRanks", function () {
self.channel.sendChannelRanks([self]);
});
wrap("requestChatFilter", function () {
self.channel.sendChatFilters([self]);
});