Add more information to the voteskip passed log message
This commit is contained in:
parent
4b48966e1d
commit
67fbc8e267
2 changed files with 65 additions and 19 deletions
|
|
@ -75,10 +75,14 @@ VoteskipModule.prototype.update = function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var max = this.calcVoteskipMax();
|
||||
var need = Math.ceil(max * this.channel.modules.options.get("voteskip_ratio"));
|
||||
const { total, eligible, noPermission, afk } = this.calcUsercounts();
|
||||
const need = Math.ceil(eligible * this.channel.modules.options.get("voteskip_ratio"));
|
||||
if (this.poll.counts[0] >= need) {
|
||||
this.channel.logger.log("[playlist] Voteskip passed.");
|
||||
const info = `${this.poll.counts[0]}/${eligible} skipped; ` +
|
||||
`eligible voters: ${eligible} = total (${total}) - AFK (${afk}) ` +
|
||||
`- no permission (${noPermission}); ` +
|
||||
`ratio = ${this.channel.modules.options.get("voteskip_ratio")}`;
|
||||
this.channel.logger.log(`[playlist] Voteskip passed: ${info}`);
|
||||
this.reset();
|
||||
this.channel.modules.playlist._playNext();
|
||||
} else {
|
||||
|
|
@ -87,10 +91,10 @@ VoteskipModule.prototype.update = function () {
|
|||
};
|
||||
|
||||
VoteskipModule.prototype.sendVoteskipData = function (users) {
|
||||
var max = this.calcVoteskipMax();
|
||||
const { eligible } = this.calcUsercounts();
|
||||
var data = {
|
||||
count: this.poll ? this.poll.counts[0] : 0,
|
||||
need: this.poll ? Math.ceil(max * this.channel.modules.options.get("voteskip_ratio"))
|
||||
need: this.poll ? Math.ceil(eligible * this.channel.modules.options.get("voteskip_ratio"))
|
||||
: 0
|
||||
};
|
||||
|
||||
|
|
@ -103,17 +107,20 @@ VoteskipModule.prototype.sendVoteskipData = function (users) {
|
|||
});
|
||||
};
|
||||
|
||||
VoteskipModule.prototype.calcVoteskipMax = function () {
|
||||
var perms = this.channel.modules.permissions;
|
||||
return this.channel.users.map(function (u) {
|
||||
if (!perms.canVoteskip(u)) {
|
||||
return 0;
|
||||
}
|
||||
VoteskipModule.prototype.calcUsercounts = function () {
|
||||
const perms = this.channel.modules.permissions;
|
||||
const counts = { total: 0, noPermission: 0, afk: 0 };
|
||||
|
||||
return u.is(Flags.U_AFK) ? 0 : 1;
|
||||
}).reduce(function (a, b) {
|
||||
return a + b;
|
||||
}, 0);
|
||||
this.channel.users.forEach(u => {
|
||||
counts.total++;
|
||||
|
||||
if (!perms.canVoteskip(u)) counts.noPermission++;
|
||||
else if (u.is(Flags.U_AFK)) counts.afk++;
|
||||
});
|
||||
|
||||
counts.eligible = counts.total - (counts.noPermission + counts.afk);
|
||||
|
||||
return counts;
|
||||
};
|
||||
|
||||
VoteskipModule.prototype.reset = function reset() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue