| … | … | @@ -28,6 +28,16 @@ import { tidFor } from './lib/tid.js' |
| 28 | 28 | |
| 29 | 29 | const argv = process.argv.slice(2) |
| 30 | 30 | const SEND = argv.includes('--send') |
| 31 | // ⛔ A CEILING ON ONE CYCLE, for the first send into a repo that has followers. A feed with a |
| 32 | // history projects ALL of it the first time, and "16 posts at once" is a different act from |
| 33 | // "post". Absent, this is Infinity and nothing changes. |
| 34 | const LIMIT = (() => { |
| 35 | const i = argv.indexOf('--limit') |
| 36 | if (i === -1) return Infinity |
| 37 | const n = Number(argv[i + 1]) |
| 38 | if (!Number.isFinite(n) || n < 0) throw new Error('--limit needs a non-negative number') |
| 39 | return n |
| 40 | })() |
| 31 | 41 | // ⛔ --watch implies --send. A watch that only planned would be a process that costs power and |
| 32 | 42 | // changes nothing, and the flag would read as if it were working. |
| 33 | 43 | const WATCH = argv.includes('--watch') |
| … | … | @@ -85,7 +95,7 @@ async function cycle (send) { |
| 85 | 95 | } |
| 86 | 96 | if (found === null) console.log(' ⚠ could not read the sink — "already there" is unknown below') |
| 87 | 97 | |
| 88 | | let sent = 0; let skipped = 0; let withheld = 0 |
| 98 | let sent = 0; let skipped = 0; let withheld = 0; let held = 0 |
| 89 | 99 | for (const row of rows) { |
| 90 | 100 | const plan = planRecord(row, { roomType: ROOM_TYPE, verb: 'post' }) |
| 91 | 101 | const line = ' ' + row.name + ' [' + plan.networks.join(',') + ']' |
| … | … | @@ -101,6 +111,11 @@ async function cycle (send) { |
| 101 | 111 | } else if (have.has(tidFor(row.name))) { |
| 102 | 112 | skipped++ |
| 103 | 113 | console.log(line + ' bsky: already there') |
| 114 | } else if (send && sent >= LIMIT) { |
| 115 | // Reported per record rather than silently truncated: a run that stopped early and one that |
| 116 | // had nothing left to do print the same summary otherwise. |
| 117 | held++ |
| 118 | console.log(line + ' bsky: held — --limit ' + LIMIT + ' reached this cycle') |
| 104 | 119 | } else if (!send) { |
| 105 | 120 | console.log(line + ' bsky: would send ' + JSON.stringify(plan.bsky.record.text.slice(0, 48)) + |
| 106 | 121 | (plan.bsky.losses.length ? ' — losing: ' + plan.bsky.losses.join('; ') : '')) |
| … | … | @@ -116,7 +131,8 @@ async function cycle (send) { |
| 116 | 131 | } |
| 117 | 132 | |
| 118 | 133 | console.log(' ' + (send ? 'sent ' + sent : 'would send ' + (rows.length - withheld - skipped)) + |
| 119 | | ' · already there ' + skipped + ' · withheld ' + withheld) |
| 134 | ' · already there ' + skipped + ' · withheld ' + withheld + |
| 135 | (held ? ' · held by --limit ' + held : '')) |
| 120 | 136 | } |
| 121 | 137 | |
| 122 | 138 | main().catch((err) => { console.error('favela-bridge: ' + ((err && err.message) || err)); process.exit(1) }) |