feat: 타로 각 카드 — 최근 7일에 쓴 각은 제외하고 상위 15개 안에서 먹거리·계절·집 각도 섞어 고르게(out/tarot-history.json)

This commit is contained in:
minaChoi committed 2026-10-26 13:22:53 +09:00
1 parent 01263f4149
commit 512ae6b591
2 files changed
+42 -9

No files matched your search

+11 -1
View File
@@ -6,7 +6,7 @@
// --post 면 다 그린 뒤 날씨각 오늘 피드에 바로 올리고, --post-wait 면 승인 대기로 저장한다 (관리자 서버 /api/post).
// 지역은 고르지 않는다. 카드는 서울 예보로 만들고 카드에 지역 이름은 나가지 않는다 (src/cards/data.ts BASE_REGION)
import { execFileSync } from 'node:child_process'
import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs'
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { resolve } from 'node:path'
const SLIDES = { tarot: 5, ootd: 4, intro: 8 }
@@ -65,6 +65,16 @@ if (topic !== null || feedback !== null || (!copy && AUTO_PLAN.includes(template
console.log(`주제: ${body.topic}`)
for (const [k, v] of Object.entries(body.copy)) console.log(` ${k}: ${v.replaceAll('\n', ' / ')}`)
copy = Buffer.from(JSON.stringify({ ...current, ...body.copy })).toString('base64url')
// 타로: 오늘 고른 각을 적어 두면 다음 7일은 다른 각이 나온다 (scripts/plan.mjs recentCodes)
if (template === 'tarot') {
const file = resolve('out/tarot-history.json')
const today = new Date(Date.now() + 9 * 3600_000).toISOString().slice(0, 10)
const history = existsSync(file) ? JSON.parse(readFileSync(file, 'utf8')) : {}
const codes = ['c1', 'c2', 'c3'].map((k) => body.copy[k]).filter(Boolean)
history[today] = [...new Set([...(history[today] ?? []), ...codes])]
mkdirSync(resolve('out'), { recursive: true })
writeFileSync(file, JSON.stringify(history, null, 1))
}
}
{