tokebot now resets on tokebumps and every hour on **:19:30. If toke ends

on or after **:19:30 (but before **:20:00) it will extend the toke until
after **:20:00
This commit is contained in:
rainbownapkin 2022-08-13 07:25:53 +00:00
parent cb4c99727f
commit c9fb5b0b0e
4 changed files with 46 additions and 25 deletions

View file

@ -396,7 +396,7 @@ AutobumpModule.prototype.lastHalfRandom = function lastHalfRandom(){
});
alist.forEach(function(bump){
if(bump != null)
if(bump != null && !bump.noauto)
alength++;
});
if(inhist.length >= alength){//if all active bumps have been played
@ -465,6 +465,7 @@ AutobumpModule.prototype.queueBump = function(listn, bid){//listname, bump ID
var nmed = new Media(bump.media.id, bump.media.title, bump.media.seconds, bump.media.type, bump.media.meta);//revive media object, should probably do this when parsing JSON but fuck you this works :P
nmed.isBump = true;
nmed.tokeBump = bump.rtoke;
this.channel.modules.playlist._addItem(nmed, data, "autobump");
@ -703,7 +704,6 @@ AutobumpModule.prototype.handleNewBump = function(user, data){//handle newBump
});
return;
}
media.isBump = true;
if(data.user === ""){
data.user = null;
}

View file

@ -92,6 +92,14 @@ TokebotModule.prototype.cdel = 120;
TokebotModule.prototype.ctime = 120;
TokebotModule.prototype.statmap = null;
TokebotModule.prototype.onMediaChange = function(data){
if(data.tokeBump){
this.ctime = 0;
console.log("[Tokebot] Cooldown reset on " + this.channel.name + " triggered by bump.");
}
}
//mod commands
TokebotModule.prototype.resettoke = function(user, msg, _meta){
if(user.account.effectiveRank >= 2 && this.toking == 2){
@ -168,7 +176,20 @@ TokebotModule.prototype.toke = function (user, msg, _meta){
};
TokebotModule.prototype.countdown = function (tb){
var dateobj = new Date();
tb.toking = 1;//set toking mode
if(dateobj.getUTCMinutes() == 19){
var ext = 60 - dateobj.getUTCSeconds();
if(ext <= 30){//we let it immediatly reset the cooldwon, but might as well extend it
console.log("[Tokebot] Toke extended on " + tb.channel.name + " by seconds " + ext + " because it's about to be 4:20 somewhere!");
tb.cdown = 3;
setTimeout(tb.countdown, 1000 * ext, tb);
return;
}
}
tb.tokesay(tb.cdown + "...");//send countdown msg
--tb.cdown;//count down
@ -206,8 +227,15 @@ TokebotModule.prototype.endtoke = function (tb){
TokebotModule.prototype.cooldown = function (tb){
if(tb.ctime > 0){
var dateobj = new Date();
tb.toking = 2;
--tb.ctime;
if((dateobj.getUTCMinutes() == 19) && (dateobj.getUTCSeconds() >= 30)){
console.log("[Tokebot] Cooldown reset on " + tb.channel.name + " triggered because it's about to be 4:20 somewhere!");
tb.toking = 0;
tb.ctime = tb.cdel;
return;
}
setTimeout(tb.cooldown, 1000, tb);
}else{
tb.toking = 0;

View file

@ -16,6 +16,7 @@ function Media(id, title, seconds, type, meta) {
this.currentTime = 0;
this.paused = false;
this.isBump = false;
this.tokeBump = false;
}
Media.prototype = {