diff --git a/spamscan.js b/spamscan.js index fe1ce95..4e4da75 100644 --- a/spamscan.js +++ b/spamscan.js @@ -109,16 +109,28 @@ async function run(opts) { bio: String(a.bio || '').slice(0, 160), quarantined: !!a.profileQuarantined, alsoOn }); } out.sort((x, y) => y.created - x.created); - S = { day: dayOf(now), at: now, candidates: out, scanned: all.length, skipped, manual: !!(opts && opts.manual) }; save(); - if (out.length && !(opts && opts.quiet)) { try { await X.notify(telegramText(out, now)); S.notified = now; save(); } catch (e) { console.error('spamscan notify', e.message); } } + // watch list (Marty 2026-10-31: do not delete the candidates yet, watch whether they activate a wallet or do something real): + // every candidate carries firstSeen from the previous run; the Telegram goes out only when something CHANGED, listing the + // accounts that are new since the last run and the ones that left the list (linked a wallet, bought, or were deleted), + // with the count still being watched. A list that merely persists is silence. + const prev = new Map((S.candidates || []).map(c => [c.email, c])); + for (const c of out) { const p = prev.get(c.email); c.firstSeen = p && p.firstSeen ? p.firstSeen : (p ? p.created || now : now); } + const fresh = out.filter(c => !prev.has(c.email)); + const nowSet = new Set(out.map(c => c.email)); + const left = [...prev.values()].filter(c => !nowSet.has(c.email) && !allow.has(norm(c.email))); + S = { day: dayOf(now), at: now, candidates: out, scanned: all.length, skipped, manual: !!(opts && opts.manual), fresh: fresh.map(c => c.email), left: left.map(c => c.email) }; save(); + if ((fresh.length || left.length) && !(opts && opts.quiet)) { try { await X.notify(telegramText(out, now, { fresh, left })); S.notified = now; save(); } catch (e) { console.error('spamscan notify', e.message); } } console.log('spamscan', X.site, 'scanned', all.length, 'candidates', out.length, 'allowlisted', skipped); return S; } finally { running = false; } } -function telegramText(out, now) { - const lines = [X.site + ' link-farm scan: ' + out.length + ' candidate account' + (out.length === 1 ? '' : 's') + ' (' + dayOf(now) + ', ' + X.siteUrl.replace(/^https?:\/\//, '') + ')']; - for (const c of out.slice(0, 15)) lines.push((c.username ? '@' + c.username : c.email) + ' | joined ' + dayOf(c.created || now) + ' | sponsor ' + (c.sponsorName || 'none') + ' | ' + (c.firstLink || 'no link') + (c.alsoOn === true ? ' | also on ' + X.otherSite : '')); - if (out.length > 15) lines.push('... and ' + (out.length - 15) + ' more'); +function telegramText(out, now, changes) { + const row = c => (c.username ? '@' + c.username : c.email) + ' | joined ' + dayOf(c.created || now) + ' | sponsor ' + (c.sponsorName || 'none') + ' | ' + (c.firstLink || 'no link') + (c.alsoOn === true ? ' | also on ' + X.otherSite : ''); + const fresh = changes && changes.fresh ? changes.fresh : out, left = changes && changes.left ? changes.left : []; + const watched = out.length - fresh.length; + const lines = [X.site + ' link-farm scan (' + dayOf(now) + ', ' + X.siteUrl.replace(/^https?:\/\//, '') + '): ' + fresh.length + ' new, ' + watched + ' still watched, ' + left.length + ' left the list']; + if (fresh.length) { lines.push('New since the last run:'); for (const c of fresh.slice(0, 15)) lines.push(row(c)); if (fresh.length > 15) lines.push('... and ' + (fresh.length - 15) + ' more'); } + if (left.length) { lines.push('Left the list (linked a wallet, bought, or were deleted):'); for (const c of left.slice(0, 10)) lines.push(c.username ? '@' + c.username : c.email); if (left.length > 10) lines.push('... and ' + (left.length - 10) + ' more'); } lines.push('Review in Admin > Members > Link-farm list'); return lines.join('\n'); }