AFKers don't affect voteskip (#193)
This commit is contained in:
parent
c50baef9c6
commit
1150d03474
12
channel.js
12
channel.js
|
@ -34,6 +34,7 @@ var Channel = function(name, Server) {
|
||||||
// Initialize defaults
|
// Initialize defaults
|
||||||
this.registered = false;
|
this.registered = false;
|
||||||
this.users = [];
|
this.users = [];
|
||||||
|
this.afkcount = 0;
|
||||||
this.playlist = new Playlist(this);
|
this.playlist = new Playlist(this);
|
||||||
this.library = {};
|
this.library = {};
|
||||||
this.position = -1;
|
this.position = -1;
|
||||||
|
@ -958,6 +959,7 @@ Channel.prototype.broadcastChatFilters = function() {
|
||||||
Channel.prototype.broadcastVoteskipUpdate = function() {
|
Channel.prototype.broadcastVoteskipUpdate = function() {
|
||||||
var amt = this.voteskip ? this.voteskip.counts[0] : 0;
|
var amt = this.voteskip ? this.voteskip.counts[0] : 0;
|
||||||
var need = this.voteskip ? parseInt(this.users.length * this.opts.voteskip_ratio) : 0;
|
var need = this.voteskip ? parseInt(this.users.length * this.opts.voteskip_ratio) : 0;
|
||||||
|
need -= this.afkcount;
|
||||||
for(var i = 0; i < this.users.length; i++) {
|
for(var i = 0; i < this.users.length; i++) {
|
||||||
if(Rank.hasPermission(this.users[i], "seeVoteskip") ||
|
if(Rank.hasPermission(this.users[i], "seeVoteskip") ||
|
||||||
this.leader == this.users[i]) {
|
this.leader == this.users[i]) {
|
||||||
|
@ -1536,12 +1538,20 @@ Channel.prototype.tryVoteskip = function(user) {
|
||||||
if(!this.opts.allow_voteskip) {
|
if(!this.opts.allow_voteskip) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Voteskip = auto-unafk
|
||||||
|
if(user.meta.afk) {
|
||||||
|
user.meta.afk = false;
|
||||||
|
this.broadcastUserUpdate(user);
|
||||||
|
this.afkcount--;
|
||||||
|
}
|
||||||
if(!this.voteskip) {
|
if(!this.voteskip) {
|
||||||
this.voteskip = new Poll("voteskip", "voteskip", ["yes"]);
|
this.voteskip = new Poll("voteskip", "voteskip", ["yes"]);
|
||||||
}
|
}
|
||||||
this.voteskip.vote(user.ip, 0);
|
this.voteskip.vote(user.ip, 0);
|
||||||
this.broadcastVoteskipUpdate();
|
this.broadcastVoteskipUpdate();
|
||||||
if(this.voteskip.counts[0] >= parseInt(this.users.length * this.opts.voteskip_ratio)) {
|
var need = parseInt(this.users.length * this.opts.voteskip_ratio);
|
||||||
|
need -= this.afkcount;
|
||||||
|
if(this.voteskip.counts[0] >= need) {
|
||||||
this.playNext();
|
this.playNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,20 @@ function handle(chan, user, msg, data) {
|
||||||
}
|
}
|
||||||
else if(msg.indexOf("/afk") == 0) {
|
else if(msg.indexOf("/afk") == 0) {
|
||||||
user.meta.afk = !user.meta.afk;
|
user.meta.afk = !user.meta.afk;
|
||||||
|
if(user.meta.afk)
|
||||||
|
chan.afkcount++;
|
||||||
|
else
|
||||||
|
chan.afkcount--;
|
||||||
|
if(chan.voteskip) {
|
||||||
|
var need = parseInt(chan.users.length * chan.opts.voteskip_ratio);
|
||||||
|
need -= chan.afkcount;
|
||||||
|
if(chan.voteskip.counts[0] >= need) {
|
||||||
|
chan.playNext();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
chan.broadcastVoteskipUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
chan.broadcastUserUpdate(user);
|
chan.broadcastUserUpdate(user);
|
||||||
}
|
}
|
||||||
else if(msg.indexOf("/m ") == 0) {
|
else if(msg.indexOf("/m ") == 0) {
|
||||||
|
|
Loading…
Reference in a new issue