This commit is contained in:
calzoneman 2013-12-06 15:21:32 -06:00
parent c00ce26d57
commit fb355272fc

View file

@ -36,6 +36,7 @@ var User = function (socket) {
}; };
this.queueLimiter = $util.newRateLimiter(); this.queueLimiter = $util.newRateLimiter();
this.chatLimiter = $util.newRateLimiter(); this.chatLimiter = $util.newRateLimiter();
this.rankListLimiter = $util.newRateLimiter();
this.profile = { this.profile = {
image: "", image: "",
text: "" text: ""
@ -460,9 +461,18 @@ User.prototype.initCallbacks = function () {
self.socket.on("requestChannelRanks", function () { self.socket.on("requestChannelRanks", function () {
if (self.inChannel()) { if (self.inChannel()) {
if (self.noflood("requestChannelRanks", 0.25)) if (self.rankListLimiter.throttle({
return; burst: 0,
self.channel.sendChannelRanks(self); sustained: 0.1,
cooldown: 10
})) {
self.socket.emit("noflood", {
action: "channel ranks",
msg: "You may only refresh channel ranks once every 10 seconds"
});
} else {
self.channel.sendChannelRanks(self);
}
} }
}); });