bd56f5f03d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
2.6 KiB
Python
26 lines
2.6 KiB
Python
# Badge cards go to the Crypto Team Build "Game Achievements" topic (HUNT_TG_ACH_TOPIC); finds, Ad Detective payouts,
|
|
# bounties and weekly prizes stay in the payments topic (HUNT_TG_TOPIC). Plus /api/public/today for the 6 PM games summary.
|
|
p = 'D:/Projects/HighRisk/polhunter/server.js'
|
|
s = open(p, encoding='utf-8').read()
|
|
R = [
|
|
("async function telegramPhoto(file, caption, general) {\n if (!outbound()) return false; // the gate\n const tok = process.env.HUNT_TG_TOKEN, chat = process.env.HUNT_TG_CHAT, topic = process.env.HUNT_TG_TOPIC;",
|
|
"async function telegramPhoto(file, caption, general, topicOverride) {\n if (!outbound()) return false; // the gate\n const tok = process.env.HUNT_TG_TOKEN, chat = process.env.HUNT_TG_CHAT, topic = topicOverride || process.env.HUNT_TG_TOPIC;"),
|
|
("async function telegram(text) {\n if (!outbound()) return false; // the gate\n const tok = process.env.HUNT_TG_TOKEN, chat = process.env.HUNT_TG_CHAT, topic = process.env.HUNT_TG_TOPIC;",
|
|
"async function telegram(text, topicOverride) {\n if (!outbound()) return false; // the gate\n const tok = process.env.HUNT_TG_TOKEN, chat = process.env.HUNT_TG_CHAT, topic = topicOverride || process.env.HUNT_TG_TOPIC;"),
|
|
("if (!file) return telegram(cap); const ok = await telegramPhoto(file, cap); if (String(process.env.HUNT_TG_BADGE_GENERAL",
|
|
"const ach = process.env.HUNT_TG_ACH_TOPIC || ''; /* badges = achievements topic (Marty, 2026-10-01); payouts stay in HUNT_TG_TOPIC */ if (!file) return telegram(cap, ach); const ok = await telegramPhoto(file, cap, false, ach); if (String(process.env.HUNT_TG_BADGE_GENERAL"),
|
|
(" if (p === '/api/config') {",
|
|
" // the last 24 hours for the shared 6 PM games summary in the achievements topic (counts only, no POL amounts)\n"
|
|
" if (p === '/api/public/today' && req.method === 'GET') {\n"
|
|
" const since = Date.now() - 24 * 3600000, t = v => typeof v === 'number' ? v : Date.parse(v) || 0;\n"
|
|
" const pay = store.read('payouts', []).filter(x => x.status !== 'failed' && t(x.at) >= since && !x.prize && !(x.ref && x.ref.forName));\n"
|
|
" const hunters = Object.values(store.read('hunters', {}));\n"
|
|
" return json(res, 200, { finds: pay.filter(x => !x.detective).length, cases: pay.filter(x => x.detective).length, hunters: new Set(pay.map(x => x.memberId)).size, newHunters: hunters.filter(h => t(h.firstSeen || h.joinedAt) >= since).length });\n"
|
|
" }\n"
|
|
" if (p === '/api/config') {"),
|
|
]
|
|
for a, b in R:
|
|
if s.count(a) != 1: raise SystemExit('anchor %d: %s' % (s.count(a), a[:90]))
|
|
s = s.replace(a, b)
|
|
open(p, 'w', encoding='utf-8').write(s); print('polhunter ok')
|