Consolidate schedule config, support multi-post per day
- Schedule config moved to nested schedule object in prompts.json - Scheduler picks 1-3 random times for personality with 4hr min gap - shouldRun reads from schedule object Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
14
bot.js
14
bot.js
@@ -28,18 +28,16 @@ function saveHistory(name, history) {
|
||||
}
|
||||
|
||||
function shouldRun(promptConfig) {
|
||||
const history = loadHistory(promptConfig.name);
|
||||
const now = new Date();
|
||||
const schedule = promptConfig.schedule;
|
||||
if (!schedule || schedule.type === "daily") return true;
|
||||
|
||||
if (promptConfig.frequency === "daily") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (promptConfig.frequency === "random" && promptConfig.minDays) {
|
||||
if (schedule.type === "random" && schedule.minDays) {
|
||||
const history = loadHistory(promptConfig.name);
|
||||
if (history.length > 0) {
|
||||
const now = new Date();
|
||||
const lastPost = new Date(history[history.length - 1].date);
|
||||
const daysSinceLast = (now - lastPost) / (1000 * 60 * 60 * 24);
|
||||
if (daysSinceLast < promptConfig.minDays) return false;
|
||||
if (daysSinceLast < schedule.minDays) return false;
|
||||
}
|
||||
// Random chance so it doesn't always fire on the minimum day
|
||||
return Math.random() < 0.5;
|
||||
|
||||
Reference in New Issue
Block a user