diff --git a/lib/channel.js b/lib/channel.js index 45b6d733..d29281df 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -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; } diff --git a/lib/utilities.js b/lib/utilities.js index afdafe03..0aea2a1e 100644 --- a/lib/utilities.js +++ b/lib/utilities.js @@ -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,