Improve anti-chatflood

This commit is contained in:
calzoneman 2013-04-30 10:30:59 -05:00
parent 9bc712c003
commit af8fcbb673
2 changed files with 5 additions and 1 deletions

View file

@ -1195,6 +1195,9 @@ Channel.prototype.tryChat = function(user, data) {
}
var msg = data.msg;
if(msg.length > 240) {
msg = msg.substring(0, 240);
}
if(this.opts.chat_antiflood && user.noflood("chat", 2.0)) {
return;
}

View file

@ -54,7 +54,8 @@ User.prototype.noflood = function(name, hz) {
else {
this.throttle[name].push(time);
var diff = (time - this.throttle[name][0]) / 1000.0;
if(diff > 1.0) {
// Twice might be an accident, more than that is probably spam
if(this.throttle[name].length > 2) {
var rate = this.throttle[name].length / diff;
this.throttle[name] = [time];
if(rate > hz) {