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

@ -55,6 +55,7 @@ dev goals for 1.1 pineapple express:
- videojs.coffee(hls,videojs,raw-file,gdrive,rtmp) ✓ - videojs.coffee(hls,videojs,raw-file,gdrive,rtmp) ✓
- dailymotion ~(this is kinda broken, likely not possible client-side without breaking CORS policy. This can wait until next version when an installation script including nginx and cors-proxy config gets added to support the catbox.moe image upload button which faces the same issue. - dailymotion ~(this is kinda broken, likely not possible client-side without breaking CORS policy. This can wait until next version when an installation script including nginx and cors-proxy config gets added to support the catbox.moe image upload button which faces the same issue.
- vimeo ✓ - vimeo ✓
- slide out panel (not an end user feature in and of itself, however a common UI element used for most menus, made to be quick and ezpz ✓ - slide out panel (not an end user feature in and of itself, however a common UI element used for most menus, made to be quick and ezpz ✓
- function for opening, closing ✓ - function for opening, closing ✓
- allow switching menus on panel without having to open/close it ✓ - allow switching menus on panel without having to open/close it ✓
@ -228,9 +229,11 @@ dev goals for 1.1 pineapple express:
- display on tooltip ✓ - display on tooltip ✓
- add toke to profile client side on toke(avoid sending information twice, write after tokes in tooltip) ✓ - add toke to profile client side on toke(avoid sending information twice, write after tokes in tooltip) ✓
- include modflair on tokewhisper ✓ - include modflair on tokewhisper ✓
- reset toke cooldown every hour at *:19:30 for 4:20 !tokes ✓
- extend toke until *:20:00 if it ends after *:19:30 but before *:20:00 ✓
- autobump - autobump
- Serverside - Serverside
- Bump Management System ✓ - Bump Management System ✓
- bump object: name, user(person who made bump, optional), lowername, resettoke bool, id, listname, media item ✓ - bump object: name, user(person who made bump, optional), lowername, resettoke bool, id, listname, media item ✓
- bumplist object: name, lowername, bump array ✓ - bumplist object: name, lowername, bump array ✓
@ -249,7 +252,7 @@ dev goals for 1.1 pineapple express:
- remove whitespace and non - or _ specials from lowernames ✓ - remove whitespace and non - or _ specials from lowernames ✓
- bump ✓ - bump ✓
- bumplist ✓ - bumplist ✓
- Automated Bump Queueing - Automated Bump Queueing
- base queueing function ✓ - base queueing function ✓
- queue bump next ✓ - queue bump next ✓
- call from socket ✓ - call from socket ✓
@ -285,26 +288,14 @@ dev goals for 1.1 pineapple express:
- minimum length to bump (default: 240 sec) ✓ - minimum length to bump (default: 240 sec) ✓
- base setting ✓ - base setting ✓
- set from packet ✓ - set from packet ✓
- per-channel config files in bumps/config/<channame>.conf, loaded on channel startup for persistent settings(move to db by next major update) - per-channel config files in bumps/config/<channame>.conf, loaded on channel startup for persistent settings(move to db by next major update) ✓
- json object with following values - json object with following values ✓
- active lists - active lists ✓
- write ✓ - agro level ✓
- load ✓ - bump frequency ✓
- agro level - bump selmed ✓
- write ✓ - list selmed ✓
- load ✓ - min length to bump ✓
- bump frequency
- write ✓
- load ✓
- bump selmed
- write ✓
- load ✓
- list selmed
- write ✓
- load ✓
- min length to bump
- write ✓
- load ✓
- Add manual only property to bump object(default false). - Add manual only property to bump object(default false).
- add boolean to obj ✓ - add boolean to obj ✓
- add to handleAddBump & its type ✓ - add to handleAddBump & its type ✓
@ -314,7 +305,8 @@ dev goals for 1.1 pineapple express:
- full random ✓ - full random ✓
- last-half random ✓ - last-half random ✓
- Change packList to send history as array of arrays ([[lname,id],[lname,id]]) ✓ - Change packList to send history as array of arrays ([[lname,id],[lname,id]]) ✓
- double check perms(all actions should be at least mod+ only) - double check perms(all actions should be at least mod+ only) ✓
- reset tokebot when tokebump is played ✓
- Clientside - Clientside
- finishing touches - finishing touches

View file

@ -396,7 +396,7 @@ AutobumpModule.prototype.lastHalfRandom = function lastHalfRandom(){
}); });
alist.forEach(function(bump){ alist.forEach(function(bump){
if(bump != null) if(bump != null && !bump.noauto)
alength++; alength++;
}); });
if(inhist.length >= alength){//if all active bumps have been played 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 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.isBump = true;
nmed.tokeBump = bump.rtoke;
this.channel.modules.playlist._addItem(nmed, data, "autobump"); this.channel.modules.playlist._addItem(nmed, data, "autobump");
@ -703,7 +704,6 @@ AutobumpModule.prototype.handleNewBump = function(user, data){//handle newBump
}); });
return; return;
} }
media.isBump = true;
if(data.user === ""){ if(data.user === ""){
data.user = null; data.user = null;
} }

View file

@ -92,6 +92,14 @@ TokebotModule.prototype.cdel = 120;
TokebotModule.prototype.ctime = 120; TokebotModule.prototype.ctime = 120;
TokebotModule.prototype.statmap = null; 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 //mod commands
TokebotModule.prototype.resettoke = function(user, msg, _meta){ TokebotModule.prototype.resettoke = function(user, msg, _meta){
if(user.account.effectiveRank >= 2 && this.toking == 2){ if(user.account.effectiveRank >= 2 && this.toking == 2){
@ -168,8 +176,21 @@ TokebotModule.prototype.toke = function (user, msg, _meta){
}; };
TokebotModule.prototype.countdown = function (tb){ TokebotModule.prototype.countdown = function (tb){
var dateobj = new Date();
tb.toking = 1;//set toking mode 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.tokesay(tb.cdown + "...");//send countdown msg
--tb.cdown;//count down --tb.cdown;//count down
@ -206,8 +227,15 @@ TokebotModule.prototype.endtoke = function (tb){
TokebotModule.prototype.cooldown = function (tb){ TokebotModule.prototype.cooldown = function (tb){
if(tb.ctime > 0){ if(tb.ctime > 0){
var dateobj = new Date();
tb.toking = 2; tb.toking = 2;
--tb.ctime; --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); setTimeout(tb.cooldown, 1000, tb);
}else{ }else{
tb.toking = 0; tb.toking = 0;

View file

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