From af8fcbb67330c0857fea2040eadca5856ea93281 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 30 Apr 2013 10:30:59 -0500 Subject: [PATCH] Improve anti-chatflood --- channel.js | 3 +++ user.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/channel.js b/channel.js index 226848f3..78d6aca0 100644 --- a/channel.js +++ b/channel.js @@ -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; } diff --git a/user.js b/user.js index e0a6eaab..1161bc79 100644 --- a/user.js +++ b/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) {