Update limits for chat_antiflood_params

This commit is contained in:
Calvin Montgomery 2015-04-27 12:21:21 -05:00
parent e2c3b2daad
commit 7debb7afa7
2 changed files with 16 additions and 7 deletions

View File

@ -22,10 +22,10 @@ const TYPE_PM = {
meta: "object,optional" meta: "object,optional"
}; };
const DEFAULT_ANTIFLOOD = { // Limit to 10 messages/sec
burst: 4, const MIN_ANTIFLOOD = {
sustained: 1, burst: 10,
cooldown: 4 sustained: 10
}; };
function ChatModule(channel) { function ChatModule(channel) {
@ -198,8 +198,8 @@ ChatModule.prototype.handlePm = function (user, data) {
return; return;
} }
if (user.chatLimiter.throttle(DEFAULT_ANTIFLOOD)) { if (user.chatLimiter.throttle(MIN_ANTIFLOOD)) {
user.socket.emit("cooldown", 1000 / DEFAULT_ANTIFLOOD.sustained); user.socket.emit("cooldown", 1000 / MIN_ANTIFLOOD.sustained);
return; return;
} }
@ -255,7 +255,7 @@ ChatModule.prototype.processChatMsg = function (user, data) {
} }
var msgobj = this.formatMessage(user.getName(), data); var msgobj = this.formatMessage(user.getName(), data);
var antiflood = DEFAULT_ANTIFLOOD; var antiflood = MIN_ANTIFLOOD;
if (this.channel.modules.options && if (this.channel.modules.options &&
this.channel.modules.options.get("chat_antiflood")) { this.channel.modules.options.get("chat_antiflood")) {

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