This commit is contained in:
Calvin Montgomery 2014-03-09 11:24:57 -05:00
parent 2211e4da9c
commit 5e152c8310
2 changed files with 20 additions and 3 deletions

View file

@ -2691,7 +2691,7 @@ Channel.prototype.handleUpdateOptions = function (user, data) {
}
if ("maxlength" in data) {
var ml = parseInt(data.maxlength);
var ml = util.parseTime(data.maxlength);
if (isNaN(ml) || ml < 0) {
ml = 0;
}
@ -2723,7 +2723,7 @@ Channel.prototype.handleUpdateOptions = function (user, data) {
b = 1;
}
var s = parseInt(data.chat_antiflood_params.sustained);
var s = parseFloat(data.chat_antiflood_params.sustained);
if (isNaN(s) || s <= 0) {
s = 1;
}

View file

@ -10,7 +10,7 @@
if (typeof require === "function") {
crypto = require("crypto");
}
var Set = function (items) {
this._items = {};
var self = this;
@ -115,6 +115,23 @@
return [h, m, s].join(":");
},
root.parseTime = function (time) {
var parts = time.split(":");
var seconds = 0;
switch (parts.length) {
case 3:
seconds += parseInt(parts[2]) * 3600;
case 2:
seconds += parseInt(parts[1]) * 60;
case 1:
seconds += parseInt(parts[0]);
break;
default:
break;
}
return seconds;
},
root.newRateLimiter = function () {
return {
count: 0,