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:
Matt Jackson
2026-03-07 23:12:29 +00:00
parent 417f943239
commit d2ca2d23ba
3 changed files with 87 additions and 37 deletions

14
bot.js
View File

@@ -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;