This repository has no description
0

Configure Feed

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

add variable delay.

+32 -20
+2
README.md
··· 36 36 ```sh 37 37 BLUESKY_USERNAME="your_bluesky_username" 38 38 BLUESKY_PASSWORD="your_bluesky_password" 39 + MIN_DELAY_HOURS=1 40 + MAX_DELAY_HOURS=3 39 41 ``` 40 42 41 43 2. **Fill in Your Bluesky Credentials:**
+30 -20
src/index.ts
··· 11 11 service: "https://bsky.social", 12 12 }); 13 13 14 + // Function to get the maximum delay hours from environment 15 + function getMaxDelayHours() { 16 + return parseInt(process.env.MAX_DELAY_HOURS) || 1; // Default to 1 if not set or invalid 17 + } 18 + 19 + // Function to get the minimum delay hours from environment 20 + function getMinDelayHours() { 21 + return parseInt(process.env.MIN_DELAY_HOURS) || 3; // Default to 3 if not set or invalid 22 + } 23 + 24 + // Function to generate a random delay before the next post 25 + function getRandomDelay() { 26 + const minHours = getMinDelayHours(); // Get minimum delay hours 27 + const maxHours = getMaxDelayHours(); // Get maximum delay hours 28 + 29 + // Convert hours to seconds 30 + const minDelaySeconds = minHours * 60 * 60; 31 + const maxDelaySeconds = maxHours * 60 * 60; 32 + 33 + let randomDelay; 34 + do { 35 + // Generate a random number within the desired range (inclusive) 36 + randomDelay = 37 + Math.floor(Math.random() * (maxDelaySeconds - minDelaySeconds + 1)) + 38 + minDelaySeconds; 39 + } while (randomDelay < minDelaySeconds || randomDelay > maxDelaySeconds); 40 + 41 + return randomDelay; 42 + } 43 + 14 44 // Main function for generating and posting wolf noise strings 15 45 async function main() { 16 46 console.log("Main function called."); ··· 56 86 console.error("Error during posting:", error); 57 87 // You can optionally implement retry logic or notify someone here 58 88 } 59 - } 60 - 61 - // Function to generate a random delay before the next post 62 - function getRandomDelay() { 63 - const minHours = 1; // Minimum hours for delay 64 - const maxHours = 3; // Maximum hours for delay 65 - 66 - // Convert hours to seconds 67 - const minDelaySeconds = minHours * 60 * 60; 68 - const maxDelaySeconds = maxHours * 60 * 60; 69 - 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); 77 - 78 - return randomDelay; 79 89 } 80 90 81 91 // Function to run the main function in a loop with random delays