This commit is contained in:
calzoneman 2013-11-29 21:09:19 -06:00
parent 0945fc0d7b
commit 873330e991
2 changed files with 16 additions and 4 deletions

View File

@ -2122,7 +2122,7 @@ Channel.prototype.tryUpdateOptions = function(user, data) {
if ("afk_timeout" in data) { if ("afk_timeout" in data) {
data.afk_timeout = parseInt(data.afk_timeout); data.afk_timeout = parseInt(data.afk_timeout);
if(data.afk_timeout < 0) if (isNaN(data.afk_timeout) || data.afk_timeout < 0)
data.afk_timeout = 0; data.afk_timeout = 0;
} }
@ -2144,12 +2144,14 @@ Channel.prototype.tryUpdateOptions = function(user, data) {
this.opts.chat_antiflood_params.cooldown = c; this.opts.chat_antiflood_params.cooldown = c;
continue; continue;
} }
this.opts[key] = data[key];
if(key === "afk_timeout" && this.opts[key] != data[key]) { if(key === "afk_timeout" && this.opts[key] != data[key]) {
console.log(typeof data[key], data[key]);
this.opts[key] = data[key];
this.users.forEach(function (u) { this.users.forEach(function (u) {
u.autoAFK(); u.autoAFK();
}); });
} }
this.opts[key] = data[key];
} }
} }

View File

@ -111,12 +111,22 @@ User.prototype.autoAFK = function () {
if (self.awaytimer) if (self.awaytimer)
clearTimeout(self.awaytimer); clearTimeout(self.awaytimer);
if (!self.inChannel() || self.channel.opts.afk_timeout === 0) if (!self.inChannel()) {
return; return;
}
var timeout = parseFloat(self.channel.opts.afk_timeout);
if (isNaN(timeout)) {
return;
}
if (timeout <= 0) {
return;
}
self.awaytimer = setTimeout(function () { self.awaytimer = setTimeout(function () {
self.setAFK(true); self.setAFK(true);
}, self.channel.opts.afk_timeout * 1000); }, timeout * 1000);
}; };
User.prototype.kick = function (reason) { User.prototype.kick = function (reason) {