This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

adjusted the time logic

+20 -7
+20 -7
src/index.ts
··· 67 67 const minDelaySeconds = minHours * 60 * 60; 68 68 const maxDelaySeconds = maxHours * 60 * 60; 69 69 70 - // Generate a random number within the desired range (inclusive) 71 - const randomDelay = 72 - Math.floor(Math.random() * (maxDelaySeconds - minDelaySeconds + 1)) + 73 - minDelaySeconds; 70 + let randomDelay; 71 + do { 72 + // Generate a random number within the desired range (inclusive) 73 + randomDelay = 74 + Math.floor(Math.random() * (maxDelaySeconds - minDelaySeconds + 1)) + 75 + minDelaySeconds; 76 + } while (randomDelay < minDelaySeconds || randomDelay > maxDelaySeconds); 74 77 75 78 return randomDelay; 76 79 } ··· 82 85 83 86 // Calculate a random delay before the next iteration 84 87 const delay = getRandomDelay(); 85 - console.log( 86 - `Next post scheduled in approximately ${(delay / 3600).toFixed(2)} hours.` 87 - ); 88 + 89 + // Calculate delay in whole hours and minutes 90 + const hours = Math.floor(delay / 3600); // Use 3600 for hours 91 + const minutes = Math.floor((delay % 3600) / 60); // Calculate remaining minutes 92 + 93 + // Format the delay string with hours and minutes (no decimals) 94 + const formattedDelay = `${ 95 + hours > 0 ? hours + " hour" + (hours > 1 ? "s" : "") : "" 96 + }${hours > 0 && minutes > 0 ? " " : ""}${ 97 + minutes > 0 ? minutes + " minute" + (minutes > 1 ? "s" : "") : "" 98 + }`; 99 + 100 + console.log(`Next post scheduled in approximately ${formattedDelay}.`); 88 101 89 102 // Wait for the random delay 90 103 await new Promise((resolve) => setTimeout(resolve, delay * 1000));