Skip to content

Commit

Permalink
nov
Browse files Browse the repository at this point in the history
  • Loading branch information
SilvaTechB authored Nov 6, 2024
1 parent 97a2ab0 commit 3b5c04a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lazackcmds/autostatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export async function before(statusUpdate, {
return false;
}

// Initialize the story array if it doesn't exist
// Initialize the story array and the last quote sent timestamp if they don't exist
this.story = this.story || [];
this.lastQuoteSent = this.lastQuoteSent || {}; // Store the last time the quote was sent

// List of motivational quotes
const motivationalQuotes = [
Expand All @@ -25,6 +26,16 @@ export async function before(statusUpdate, {
"Difficult roads often lead to beautiful destinations.SILVA MD BOT"
];

// Get the current time
const currentTime = Date.now();
const lastQuoteTime = this.lastQuoteSent[statusUpdate.sender] || 0;

// Only send a quote if 24 hours have passed
if (currentTime - lastQuoteTime < 24 * 60 * 60 * 1000) {
console.log("24 hours haven't passed since the last motivational quote.");
return false; // Don't send the quote if 24 hours haven't passed
}

// Select a random motivational quote
const randomQuote = motivationalQuotes[Math.floor(Math.random() * motivationalQuotes.length)];

Expand All @@ -34,6 +45,9 @@ export async function before(statusUpdate, {
mentions: [statusUpdate.sender]
});
console.log(`Motivational quote sent to ${statusUpdate.sender.split('@')[0]}`);

// Update the last quote sent timestamp
this.lastQuoteSent[statusUpdate.sender] = currentTime;
} catch (error) {
console.error("Error sending motivational quote:", error);
}
Expand Down

0 comments on commit 3b5c04a

Please sign in to comment.