Resolve merge conflict

This commit is contained in:
calzoneman 2015-07-06 11:28:18 -07:00
commit 70be8a6713
21 changed files with 752 additions and 432 deletions

View file

@ -22,6 +22,12 @@ const TYPE_PM = {
meta: "object,optional"
};
// Limit to 10 messages/sec
const MIN_ANTIFLOOD = {
burst: 20,
sustained: 10
};
function ChatModule(channel) {
ChannelModule.apply(this, arguments);
this.buffer = [];
@ -192,7 +198,13 @@ ChatModule.prototype.handlePm = function (user, data) {
return;
}
var msg = data.msg.substring(0, 240);
if (user.chatLimiter.throttle(MIN_ANTIFLOOD)) {
user.socket.emit("cooldown", 1000 / MIN_ANTIFLOOD.sustained);
return;
}
data.msg = data.msg.substring(0, 240);
var to = null;
for (var i = 0; i < this.channel.users.length; i++) {
if (this.channel.users[i].getLowerName() === data.to) {
@ -216,7 +228,7 @@ ChatModule.prototype.handlePm = function (user, data) {
}
}
if (msg.indexOf(">") === 0) {
if (data.msg.indexOf(">") === 0) {
meta.addClass = "greentext";
}
@ -243,13 +255,34 @@ ChatModule.prototype.processChatMsg = function (user, data) {
}
var msgobj = this.formatMessage(user.getName(), data);
var antiflood = MIN_ANTIFLOOD;
if (this.channel.modules.options &&
this.channel.modules.options.get("chat_antiflood") &&
user.account.effectiveRank < 2) {
var antiflood = this.channel.modules.options.get("chat_antiflood_params");
if (user.chatLimiter.throttle(antiflood)) {
user.socket.emit("cooldown", 1000 / antiflood.sustained);
antiflood = this.channel.modules.options.get("chat_antiflood_params");
}
if (user.chatLimiter.throttle(antiflood)) {
user.socket.emit("cooldown", 1000 / antiflood.sustained);
return;
}
if (data.msg.indexOf(">") === 0) {
msgobj.meta.addClass = "greentext";
}
if (data.msg.indexOf("/") === 0) {
var space = data.msg.indexOf(" ");
var cmd;
if (space < 0) {
cmd = data.msg.substring(1);
} else {
cmd = data.msg.substring(1, space);
}
if (cmd in this.commandHandlers) {
this.commandHandlers[cmd](user, data.msg, data.meta);
return;
}
}
@ -270,27 +303,7 @@ ChatModule.prototype.processChatMsg = function (user, data) {
});
return;
}
if (data.msg.indexOf("/") === 0) {
var space = data.msg.indexOf(" ");
var cmd;
if (space < 0) {
cmd = data.msg.substring(1);
} else {
cmd = data.msg.substring(1, space);
}
if (cmd in this.commandHandlers) {
this.commandHandlers[cmd](user, data.msg, data.meta);
} else {
this.sendMessage(msgobj);
}
} else {
if (data.msg.indexOf(">") === 0) {
msgobj.meta.addClass = "greentext";
}
this.sendMessage(msgobj);
}
this.sendMessage(msgobj);
};
ChatModule.prototype.formatMessage = function (username, data) {

View file

@ -39,6 +39,11 @@ OptionsModule.prototype.load = function (data) {
}
}
}
this.opts.chat_antiflood_params.burst = Math.min(20,
this.opts.chat_antiflood_params.burst);
this.opts.chat_antiflood_params.sustained = Math.min(10,
this.opts.chat_antiflood_params.sustained);
};
OptionsModule.prototype.save = function (data) {
@ -216,11 +221,15 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
b = 1;
}
b = Math.min(20, b);
var s = parseFloat(data.chat_antiflood_params.sustained);
if (isNaN(s) || s <= 0) {
s = 1;
}
s = Math.min(10, s);
var c = b / s;
this.opts.chat_antiflood_params = {
burst: b,