← back to Norma

agents/instagram-agent/reply-fleet.js

17 lines

#!/usr/bin/env node
// reply-fleet.js — run comment auto-reply across the current phase's accounts, paced.
const { execFileSync } = require('child_process');
const path = require('path'); const fs = require('fs');
const GO = process.argv.includes('--go');
const { phase, accounts } = JSON.parse(fs.readFileSync(path.join(__dirname, 'data', 'reshare-phase.json'), 'utf8'));
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
(async () => {
  console.log(`Reply fleet — phase ${phase} — ${accounts.length} accounts — ${GO ? 'LIVE' : 'DRY'}`);
  for (let i = 0; i < accounts.length; i++) {
    try { const out = execFileSync(process.execPath, [path.join(__dirname, 'comment-reply.js'), accounts[i], ...(GO ? ['--go'] : [])], { encoding: 'utf8' });
      console.log(out.trim().split('\n').filter((l) => /sent|would send|needs a HUMAN|↳/.test(l)).slice(0, 4).join('\n')); }
    catch (e) { console.log(`@${accounts[i]}: ${String(e.message).split('\n')[0]}`); }
    if (GO && i < accounts.length - 1) await sleep(60000);
  }
})();