commit
7f3561bd27
8 changed files with 91 additions and 4 deletions
|
|
@ -84,14 +84,19 @@ var Channel = function(name) {
|
|||
self.opts = {
|
||||
allow_voteskip: true,
|
||||
voteskip_ratio: 0.5,
|
||||
afk_timeout: 180,
|
||||
afk_timeout: 600,
|
||||
pagetitle: self.name,
|
||||
maxlength: 0,
|
||||
externalcss: "",
|
||||
externaljs: "",
|
||||
chat_antiflood: false,
|
||||
chat_antiflood_params: {
|
||||
burst: 4,
|
||||
sustained: 1,
|
||||
cooldown: 4
|
||||
},
|
||||
show_public: false,
|
||||
enable_link_regex: true
|
||||
enable_link_regex: true,
|
||||
};
|
||||
self.filters = [
|
||||
new Filter("monospace", "`([^`]+)`", "g", "<code>$1</code>"),
|
||||
|
|
@ -2108,12 +2113,25 @@ Channel.prototype.tryUpdateOptions = function(user, data) {
|
|||
if(key in adminonly && user.rank < 3) {
|
||||
continue;
|
||||
}
|
||||
if (key === "chat_antiflood_params") {
|
||||
var b = parseInt(data[key].burst);
|
||||
if (isNaN(b) || b < 0)
|
||||
b = 1;
|
||||
var s = parseFloat(data[key].sustained);
|
||||
if (isNaN(s) || s <= 0)
|
||||
s = 1;
|
||||
var c = b / s;
|
||||
this.opts.chat_antiflood_params.burst = b;
|
||||
this.opts.chat_antiflood_params.sustained = s;
|
||||
this.opts.chat_antiflood_params.cooldown = c;
|
||||
continue;
|
||||
}
|
||||
this.opts[key] = data[key];
|
||||
if(key === "afk_timeout" && this.opts[key] != data[key]) {
|
||||
this.users.forEach(function (u) {
|
||||
u.autoAFK();
|
||||
});
|
||||
}
|
||||
this.opts[key] = data[key];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2231,7 +2249,10 @@ Channel.prototype.tryChat = function(user, data) {
|
|||
if(msg.length > 240) {
|
||||
msg = msg.substring(0, 240);
|
||||
}
|
||||
if(this.opts.chat_antiflood && user.noflood("chat", 2.0)) {
|
||||
|
||||
if (user.rank < 2 && this.opts.chat_antiflood &&
|
||||
user.chatLimiter.throttle(this.opts.chat_antiflood_params)) {
|
||||
user.socket.emit("chatCooldown", 1000/this.opts.chat_antiflood_params.sustained);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ var User = function (socket) {
|
|||
this.throttle = {};
|
||||
this.flooded = {};
|
||||
this.queueLimiter = $util.newRateLimiter();
|
||||
this.chatLimiter = $util.newRateLimiter();
|
||||
this.profile = {
|
||||
image: "",
|
||||
text: ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue