Improve anti-chatflood
This commit is contained in:
parent
9bc712c003
commit
af8fcbb673
|
@ -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;
|
||||
}
|
||||
|
|
3
user.js
3
user.js
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue