mirror of
https://github.com/Myxelium/RandomMemerBot.git
synced 2026-07-07 21:45:08 +00:00
Update cron expression
This commit is contained in:
16
bot.ts
16
bot.ts
@@ -110,9 +110,13 @@ async function joinRandomChannel(retries = 12) {
|
|||||||
|
|
||||||
function scheduleNextJoin(){
|
function scheduleNextJoin(){
|
||||||
const randomInterval = Math.floor(Math.random() * (maxTime - minTime + 1)) + minTime;
|
const randomInterval = Math.floor(Math.random() * (maxTime - minTime + 1)) + minTime;
|
||||||
log(randomInterval);
|
|
||||||
|
|
||||||
schedule.scheduleJob(`*/${randomInterval} * * * *`, function(){
|
log(randomInterval);
|
||||||
|
|
||||||
|
const minutes = randomInterval % 60;
|
||||||
|
const hours = Math.floor(randomInterval / 60);
|
||||||
|
|
||||||
|
schedule.scheduleJob(`${minutes} ${hours == 0 ? '*' : hours } * * *`, function(){
|
||||||
joinRandomChannel();
|
joinRandomChannel();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -123,12 +127,14 @@ function convertHoursToMinutes(hours: number){
|
|||||||
|
|
||||||
function log(waitTime: number){
|
function log(waitTime: number){
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
const nextJoinTime = new Date(currentTime.getTime() + waitTime * 60 * 1000); // Convert waitTime from minutes to milliseconds
|
const nextJoinTime = new Date(currentTime.getTime() + waitTime * 60000);
|
||||||
|
const minutes = waitTime % 60;
|
||||||
|
const hours = Math.floor(waitTime / 60);
|
||||||
console.log(
|
console.log(
|
||||||
LoggerColors.Cyan, `
|
LoggerColors.Cyan, `
|
||||||
Wait time: ${waitTime} minutes,
|
Wait time: ${waitTime} minutes,
|
||||||
Current time: ${currentTime.toLocaleTimeString()},
|
Current time: ${currentTime.toLocaleTimeString()},
|
||||||
Next join time: ${nextJoinTime.toLocaleTimeString()}`
|
Next join time: ${nextJoinTime.toLocaleTimeString()},
|
||||||
|
Cron: ${minutes} ${hours == 0 ? '*' : hours } * * *`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user