← back to Animate Museum Posts

src/runOvernight.js

55 lines

import { generateScheduledContent } from './contentGenerator.js';
import { startPostingLoop } from './scheduledPoster.js';
import { startDashboard } from './webDashboard.js';
import { initDatabase } from './database.js';
import { verifyVideo } from './verifyVideo.js';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);

/**
 * Run the overnight museum art bot
 * 1. Generate content for next 12 hours
 * 2. Start poster loop
 * 3. Dashboard runs separately
 */
async function runOvernight() {
  console.log('='.repeat(60));
  console.log('MUSEUM ART BOT - OVERNIGHT MODE');
  console.log('='.repeat(60));
  console.log(`Started: ${new Date().toISOString()}`);
  console.log('');

  await initDatabase();

  // Generate content for 12 hours (36 posts at 20 min intervals)
  const hoursAhead = parseInt(process.argv[2]) || 12;
  console.log(`Generating ${hoursAhead} hours of content...`);
  console.log('');

  try {
    await generateScheduledContent(hoursAhead);
  } catch (err) {
    console.error('Content generation error:', err.message);
  }

  console.log('');
  console.log('='.repeat(60));
  console.log('Content generation complete. Starting poster loop...');
  console.log('='.repeat(60));
  console.log('');

  // Start posting loop (checks every 60 seconds)
  startPostingLoop(60000);

  console.log('');
  console.log('Bot is running. Posts every 20 minutes.');
  console.log('Dashboard: http://45.61.58.125:7890');
  console.log('');
  console.log('Press Ctrl+C to stop.');
}

if (process.argv[1] === fileURLToPath(import.meta.url)) {
  runOvernight().catch(console.error);
}