Network Weekend (Marty 2026-11-17): 8 instant picks per position Fri 11-27 00:00 CT to Tue 12-01 00:00 CT, ribbon, chatbot facts

weekend.js: date gate by the purchase's chain time (WEEKEND_PICKS=0 switches it off, WEEKEND_NOW test clock); /api/config, quote,
order and the attach hook use it. Tank check 11-17: draft pool 1,339, 2 positions sold. netdeals.js + /assets/netweekend.js ribbon
(/api/network-deals from the hub), loaded by common.js (not draftday/admin), common.js?v=4. chatbot FACTS weekend line and a
chatcore finish hook so stored instant answers say 8 while live. qa/weekend.test.cjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 07:22:44 -06:00
parent 394aec44c3
commit f56fc551fe
22 changed files with 199 additions and 22 deletions
+6 -2
View File
@@ -12,7 +12,8 @@
const core = require('./chatcore');
const C = require('./config').get();
const KNOWLEDGE_DATE = '2026-11-15';
const KNOWLEDGE_DATE = '2026-11-17';
const weekend = require('./weekend');
const URL_ = 'https://' + C.site;
const SUPPORT = 'https://instantadpay.com/support';
const PO = C.position, SP = C.split, D = C.draft, PK = C.picks;
@@ -90,12 +91,15 @@ const FACTS = () => [
'- BEST COACH POT: ' + SP.potPct + '% of every position to a prize wallet fixed in the contract; each Central week shared among the coaches whose picks started the most (places ' + POT + ' percent; tie = got there first), announced on the board, every payout on the ledger. Prizes depend on that week\'s pot, never promised. Boards also show Rookie of the Week and last week\'s top 3.',
'- CARDS: Rookie (drafted), Starter (wallet), Pro (payouts on), All-Star (first purchase), Hall of Fame (holds a position of their own). Public cards show milestones, never earnings; scouting earnings show to coaches only.',
'- PAGES: / (pool, tracker, standings), /join (buy), /team (coaching), /cards, /builder (CryptoTeamBuild builder, third-party programs), /promote, /ledger, /contract, /terms, /disclaimer, /privacy. Run by TrustClickz.',
(weekend.live() ? '- NETWORK WEEKEND (live now, Black Friday to Cyber Monday, Fri 11-27 to Mon 11-30, midnight to midnight Central): every position bought in the window comes with ' + weekend.weekendPicks() + ' instant picks instead of ' + PO.picksOnBuy + ', same $' + PO.usd + ' price. This overrides the ' + PO.picksOnBuy + ' picks above until Tuesday 12-01 00:00 Central. Every network deal: https://instantadpay.com/weekend' : null),
'- NO REFUNDS: blockchain payments are final. SUPPORT for account or payment problems: network support at ' + SUPPORT + ' (InstantAdPay runs the one desk for every network site). ' + NOT_INCOME
].join('\n');
].filter(Boolean).join('\n');
const SITE = {
id: 'fivex', hubSite: 'fivex', netId: 'fivex', name: '5xYourTeam', url: URL_, supportUrl: SUPPORT, knowledgeDate: KNOWLEDGE_DATE,
dataDir: C.dataDir, canned: CANNED, faq: FAQ, facts: FACTS,
// Network Weekend: the stored instant answers say the normal picks; while the weekend is live the reply carries the weekend number
finish: r => (weekend.live() ? r.replace(new RegExp('\\b' + PO.picksOnBuy + ' (picks right away|instant picks)', 'g'), weekend.weekendPicks() + ' $1 (Network Weekend, through Monday 11-30 midnight Central)') : r),
intro: 'You are the assistant on 5xYourTeam (' + URL_ + '), The Draft: coaches buy a $' + PO.usd + ' one-time position and draft people who joined the network without a sponsor every week, then coach them through site messages.',
quickTopics: ['How does The Draft work?', 'Where does the $10 go?', 'When is the draft?', 'What is Downline Banners?']
};
+1
View File
@@ -175,6 +175,7 @@ async function handle(req, res, p, u, h) {
const b = await h.readBody(req);
const hist = Array.isArray(b.history) ? b.history.map(x => String(x || '')).join(' ').slice(-800) : String(b.history || '').slice(-800);
const r = await answer(b.message, hist);
if (r.reply && typeof S.finish === 'function') { try { r.reply = S.finish(r.reply); } catch (e) {} } // site hook: date-gated wording (Network Weekend 2026-11-17)
if (r.handoff) r.support = supportLink(b.message);
h.json(res, r.error ? 400 : 200, r); return true;
}
+54
View File
@@ -0,0 +1,54 @@
// Network deals for this site's "Network Weekend" ribbon (Marty 2026-11-17). One source: the hub's public GET /v1/network-deals
// (HUB_URL). Cached 2 minutes, refreshed in the background, never waits on a slow hub (2.5 s timeout); hub down = no ribbon.
// The same file lives in every network site. Never RM Circle, never the games (the hub list never names them).
// The page (/assets/netweekend.js) switches the ribbon on and off by its own clock at startsAt / endsAt, so a cached copy never
// shows early or late. setLocal(fn) lets a site rewrite its own deal line from live data (for example a price read from chain),
// so the ribbon never shows a number the contract does not charge: fn(deal) returns the deal, a changed copy, or null to drop it.
const TTL = 2 * 60 * 1000;
let cache = { at: 0, body: { events: [] } };
let inflight = null;
let local = null;
const hubUrl = () => String(process.env.HUB_URL || 'https://hub.saasy.top').trim().replace(/\/+$/, '');
const safeUrl = u => (/^https:\/\/[a-z0-9.-]+(\/[^\s"'<>]*)?$/i.test(String(u || '')) ? String(u) : '');
const str = (v, n) => String(v == null ? '' : v).slice(0, n || 300);
function clean(j) {
if (!j || !Array.isArray(j.events)) return null;
return { events: j.events.slice(0, 5).filter(e => e && e.id && !Number.isNaN(Date.parse(e.startsAt)) && !Number.isNaN(Date.parse(e.endsAt))).map(e => ({
id: str(e.id, 60), name: str(e.name, 60), tagline: str(e.tagline, 160), url: safeUrl(e.url), startsAt: e.startsAt, endsAt: e.endsAt,
days: e.days && typeof e.days === 'object' ? Object.fromEntries(Object.entries(e.days).slice(0, 20).map(([k, v]) => [str(k, 10), str(v, 40)])) : {},
deals: (Array.isArray(e.deals) ? e.deals : []).slice(0, 40).map(d => {
const x = { site: str(d.site, 30), name: str(d.name, 80), url: safeUrl(d.url), text: str(d.text), endsAt: Number.isNaN(Date.parse(d.endsAt)) ? e.endsAt : d.endsAt };
if (d.note) x.note = str(d.note, 120);
if (d.byDay && typeof d.byDay === 'object') x.byDay = Object.fromEntries(Object.entries(d.byDay).slice(0, 20).map(([k, v]) => [str(k, 10), str(v)]));
return x;
})
})) };
}
function refresh() {
if (inflight || process.env.NETWORK_DEALS_HUB === '0') return inflight;
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 2500);
inflight = fetch(hubUrl() + '/v1/network-deals', { signal: ac.signal })
.then(r => (r.ok ? r.json() : null))
.then(j => { const b = clean(j); if (b) cache = { at: Date.now(), body: b }; else cache.at = Date.now(); })
.catch(() => { cache.at = Date.now() - TTL + 30 * 1000; }) // hub down: try again in 30 s, keep the last good copy
.finally(() => { clearTimeout(t); inflight = null; });
return inflight;
}
function current() { if (Date.now() - cache.at > TTL) refresh(); return cache.body; }
function setLocal(fn) { local = typeof fn === 'function' ? fn : null; }
function withLocal(body, self) {
if (!local) return body;
return { events: body.events.map(e => Object.assign({}, e, { deals: e.deals.map(d => {
if (d.site !== self) return d;
try { const r = local(Object.assign({}, d)); return r === undefined ? d : r; } catch (err) { return d; }
}).filter(Boolean) })) };
}
// GET /api/network-deals: public, short cache, the same answer on every page. self = this site's network id (NETWORK_SITE_ID).
function handle(req, res, self) {
const me = String(self || process.env.NETWORK_SITE_ID || '').trim().toLowerCase();
const body = Object.assign({ self: me }, withLocal(current(), me));
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=60', 'X-Content-Type-Options': 'nosniff' });
res.end(JSON.stringify(body));
}
module.exports = { current, handle, refresh, setLocal, clean, _set: b => { cache = { at: Date.now(), body: clean(b) || { events: [] } }; } };
+1 -1
View File
@@ -28,7 +28,7 @@
<section class="panel"><h3>Best Coach pot (last week)</h3><pre id="potOut" class="kit-pre"></pre></section>
<section class="panel"><h3>Old-link map (JSON {"oldrefs": {"old": "network username"}})</h3><input type="file" id="oldFile" accept="application/json"><pre id="oldOut" class="kit-pre"></pre></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/misc.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+6
View File
@@ -112,3 +112,9 @@ window.FX = (function () {
}
return { $, esc, getConfig, short, status, getJSON, post, n, polOf, when, ago, left, initials, renderNav, renderFooter, setWeek, weekNo, card, silentSso, signInBlock, wireSignIn };
})();
// Network Weekend ribbon (Marty 2026-11-17): netweekend.js paints it only while a network event is live (dates from the hub through
// /api/network-deals). Not on the 1080x1080 draft-day card or the admin page.
(function () {
if (/^\/(draftday|admin)/.test(location.pathname)) return;
var s = document.createElement('script'); s.src = '/assets/netweekend.js?v=20261117'; s.defer = true; s.setAttribute('data-site', 'fivex'); document.head.appendChild(s);
})();
+67
View File
@@ -0,0 +1,67 @@
// "Network Weekend" ribbon (Marty 2026-11-17): a thin bar at the top of every network site page while a network event is live.
// Data: /api/network-deals (netdeals.js, from the hub). Switches on and off by this page's own clock at the event's exact
// startsAt / endsAt (US Central midnights), so a cached feed never shows it early or late, and it takes itself down at endsAt on
// a page left open. Shows this site's own deal for today (byDay, Central date) and links to the full deals page.
// The same file lives in every network site. Never RM Circle, never the games. No inline styles (CSP): styles go through CSSOM.
// Test clock: window.__NW_NOW (ms) before this script runs; nothing else.
(function () {
if (window.__nwRibbon) return; window.__nwRibbon = 1;
var tag = document.currentScript;
var meAttr = (tag && tag.getAttribute('data-site')) || '';
function now() { return typeof window.__NW_NOW === 'number' ? window.__NW_NOW : Date.now(); }
// late November is CST (UTC-6) for every date this ribbon covers
function ctDay(ms) { return new Date(ms - 6 * 3600 * 1000).toISOString().slice(0, 10); }
function closedKey(id, day) { return 'nw.closed.' + id + '.' + day; }
function isClosed(id, day) { try { return window.localStorage.getItem(closedKey(id, day)) === '1'; } catch (e) { return false; } }
function setClosed(id, day) { try { window.localStorage.setItem(closedKey(id, day), '1'); } catch (e) {} }
var bar = null;
function remove() { if (bar && bar.parentNode) bar.parentNode.removeChild(bar); bar = null; }
function paint(body) {
var me = meAttr || (body && body.self) || '';
var t = now();
var ev = ((body && body.events) || []).filter(function (e) { return t >= Date.parse(e.startsAt) && t < Date.parse(e.endsAt); })[0];
if (!ev) { remove(); return false; }
var day = ctDay(t);
if (isClosed(ev.id, day)) { remove(); return true; }
var mine = (ev.deals || []).filter(function (d) { return d.site === me && t < Date.parse(d.endsAt || ev.endsAt); })[0];
var line = mine ? ((mine.byDay && mine.byDay[day]) || mine.text) : '';
var label = (ev.days && ev.days[day]) || '';
var onDealsPage = ev.url && (location.origin + location.pathname) === ev.url;
remove();
bar = document.createElement('div');
bar.className = 'nw-ribbon'; bar.setAttribute('role', 'region'); bar.setAttribute('aria-label', ev.name);
bar.style.cssText = 'position:relative;z-index:50;display:flex;flex-wrap:wrap;gap:4px 12px;align-items:center;justify-content:center;padding:8px 40px 8px 16px;'
+ 'background:#14161b;color:#f4f1e8;font:600 13.5px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;text-align:center;border-bottom:2px solid #f2c94c';
// built node by node with CSSOM styles: no style attributes, so a strict CSP (style-src 'self') has nothing to block
function el(tagName, css, text) { var n = document.createElement(tagName); if (css) n.style.cssText = css; if (text) n.textContent = text; return n; }
var head = el('span'); head.appendChild(el('b', 'color:#f2c94c', ev.name)); if (label) head.appendChild(document.createTextNode(' · ' + label));
bar.appendChild(head);
var body2 = el('span', 'font-weight:500', line || ev.tagline);
if (line && mine && mine.note) { body2.appendChild(document.createTextNode(' ')); body2.appendChild(el('span', 'opacity:.75', mine.note)); }
bar.appendChild(body2);
if (ev.url && !onDealsPage) { var a = el('a', 'color:#f2c94c;text-decoration:underline', 'See every deal'); a.href = ev.url; a.target = '_blank'; a.rel = 'noopener'; bar.appendChild(a); }
var x = el('button', 'position:absolute;right:8px;top:50%;transform:translateY(-50%);background:none;border:0;color:#f4f1e8;font-size:18px;line-height:1;cursor:pointer;padding:4px 8px', '×');
x.type = 'button'; x.setAttribute('aria-label', 'Hide for today'); bar.appendChild(x);
bar.querySelector('button').addEventListener('click', function () { setClosed(ev.id, day); remove(); });
document.body.insertBefore(bar, document.body.firstChild);
return true;
}
var feed = null, timer = null;
function schedule() {
clearTimeout(timer); if (!feed) return;
// wake at the next switch moment (start, end, a deal ending, the next Central midnight), at least once a minute
var t = now(), next = t + 60 * 1000;
(feed.events || []).forEach(function (e) {
[e.startsAt, e.endsAt].concat((e.deals || []).map(function (d) { return d.endsAt; })).forEach(function (s) { var x = Date.parse(s); if (x > t && x < next) next = x; });
});
timer = setTimeout(function () { if (typeof window.__NW_NOW === 'number') window.__NW_NOW += next - t; paint(feed); schedule(); }, Math.max(250, next - t));
}
function run() {
fetch('/api/network-deals', { credentials: 'omit' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (b) {
if (!b || !Array.isArray(b.events) || !b.events.length) return;
feed = b; paint(b); schedule();
}).catch(function () {});
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run();
window.__nwPaint = function (b) { feed = b; return paint(b); }; // tests
})();
+1 -1
View File
@@ -28,7 +28,7 @@
<p id="status" class="note" hidden></p>
<section class="panel" id="bList"></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/wallet.js?v=3"></script>
<script src="/assets/misc.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
+1 -1
View File
@@ -28,7 +28,7 @@
<section style="display:flex;flex-direction:column;gap:12px"><h2>The five tiers</h2><div class="cards" id="tiers"></div>
<p class="small">Rookie when drafted, Starter when they link a wallet, Pro when they switch on payouts, All-Star at their first purchase, Hall of Fame when they hold a position of their own and coach a team. Tap a card to flip it for the stats on the back.</p></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/cards.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+1 -1
View File
@@ -27,7 +27,7 @@
<div class="r"><h3>The team</h3><p class="small" style="color:#4a587e">Milestones only. Every Monday this coach drafts people who joined the network without a sponsor and helps them get started.</p><div class="row"><a class="btn-gold" id="cJoin" href="https://instantadpay.com/?return=fivex&amp;to=%2Fmy">Join the network free</a><a class="btn" href="/join">Coach a team of your own</a></div></div></section>
<section class="cards" id="cTeam"></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/coach.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+1 -1
View File
@@ -26,7 +26,7 @@
<section><p class="kicker">CONTRACT</p><h1 style="font-size:44px">Check the contract yourself</h1><p class="muted">Read live from Polygon. No owner withdraw, no proxy, the split fixed in the code.</p></section>
<section class="panel"><div class="tbl"><table id="facts"></table></div></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/contract.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+1 -1
View File
@@ -30,7 +30,7 @@
<section class="card"><h2>Prices and taxes</h2><p>Positions are priced in US dollars and paid in POL, whose price moves. You are responsible for any taxes on what you receive where you live.</p></section>
<section class="card"><h2>Who to ask</h2><p>TrustClickz. <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Network support</a>.</p></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/misc.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+1 -1
View File
@@ -15,4 +15,4 @@ h1{margin:0;font-family:Oswald,Impact,sans-serif;font-weight:700;font-size:108px
</style></head><body data-page="draftday"><div class="dd"><img class="spot" src="/art/dd/spotlight.jpg" alt=""><img class="conf" src="/art/dd/confetti.png" alt=""><div class="top"><span class="wm">5X<b>YOUR</b>TEAM</span><span class="wk" id="ddWeek"></span></div>
<h1>DRAFT DAY<br><span>RESULTS</span></h1><div class="rows" id="ddRows"></div>
<div class="ft"><div><span id="ddStats"></span><span class="p" id="ddPot"></span></div><span class="url">5xyourteam.com</span></div></div>
<script src="/assets/common.js?v=3"></script><script src="/assets/misc.js?v=3"></script></body></html>
<script src="/assets/common.js?v=4"></script><script src="/assets/misc.js?v=3"></script></body></html>
+1 -1
View File
@@ -55,7 +55,7 @@
</main>
<!-- PolHunter mission (every rebuilt network site gets one, Marty 2026-11-14): the 3 How The Draft steps -->
<script src="https://polhunter.com/embed.js" data-slots="3" data-selector=".how .s" async></script>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/board.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+1 -1
View File
@@ -34,7 +34,7 @@
<p class="small">Your sponsor gets 25% and levels 2 to 5 of your network sponsor line get 5% each. Only people who hold a position can receive a share: anyone in your line who does not is passed over and the share goes up to the next person who does. 10% goes to the weekly Best Coach pot and 45% to 5xYourTeam. The contract keeps nothing. Check it on the <a href="/contract">contract page</a> and every payment on the <a href="/ledger">ledger</a>.</p>
<p class="small">A position buys a draft spot and coaching tools, not income. Nothing is promised.</p></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/wallet.js?v=3"></script>
<script src="/assets/join.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
+1 -1
View File
@@ -28,7 +28,7 @@
<section class="panel"><div class="tbl"><table id="rows"><thead><tr><th>WHEN</th><th>POSITION</th><th>PAID IN THE SAME TRANSACTION</th><th></th></tr></thead><tbody></tbody></table></div></section>
<section class="panel"><h3 style="font-size:24px">Best Coach payouts</h3><div class="tbl"><table id="payouts"><thead><tr><th>WEEK</th><th>COACH</th><th>POL</th><th></th></tr></thead><tbody></tbody></table></div></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/ledger.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+1 -1
View File
@@ -32,7 +32,7 @@
<section class="card"><h2>Your choices</h2><p>You can ask us to remove your account and messages here. Records on the blockchain cannot be removed by anyone.</p></section>
<section class="card"><h2>Contact</h2><p>TrustClickz. <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Network support</a>. Last updated November 15, 2026.</p></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/misc.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+1 -1
View File
@@ -28,7 +28,7 @@
<p id="status" class="note" hidden></p>
<div id="kit" style="display:flex;flex-direction:column;gap:16px"></div>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/kitpage.js?v=3"></script>
<script src="/assets/misc.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
+1 -1
View File
@@ -52,7 +52,7 @@
</div>
</div>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/wallet.js?v=3"></script>
<script src="/assets/team.js?v=4"></script>
<script src="/assets/chat.js?v=2" defer></script>
+1 -1
View File
@@ -37,7 +37,7 @@
<section class="card"><h2>The service</h2><p>The site is provided as it is. We work to keep it running but cannot promise it will always be available or free of errors. The smart contract runs on Polygon on its own; its rules are public on the <a href="/contract">contract page</a>. We may change features, draft settings, the price of future positions or these terms; changes apply from the date they are posted here. As far as the law allows, our total responsibility to you is limited to what you paid for the purchase in question. These terms are governed by the laws of the State of Alabama, USA.</p></section>
<section class="card"><h2>Contact</h2><p>TrustClickz. <a href="https://instantadpay.com/support" target="_blank" rel="noopener">Network support</a>. Last updated November 15, 2026.</p></section>
</main>
<script src="/assets/common.js?v=3"></script>
<script src="/assets/common.js?v=4"></script>
<script src="/assets/misc.js?v=3"></script>
<script src="/assets/chat.js?v=2" defer></script>
</body>
+26
View File
@@ -0,0 +1,26 @@
// Network Weekend gate (weekend.js + chatbot wording): 8 picks Fri 11-27 00:00 CT to Tue 12-01 00:00 CT, by the purchase's time.
// Tested with the WEEKEND_NOW test clock and explicit times; never the server clock.
const assert = require('assert');
const w = require('../weekend');
const C = { position: { picksOnBuy: 5 } };
const T = s => Date.parse(s);
delete process.env.WEEKEND_PICKS;
assert.strictEqual(w.picks(C, T('2026-11-27T05:59:59Z')), 5, 'Thu 23:59:59 CT: normal');
assert.strictEqual(w.picks(C, T('2026-11-27T06:00:00Z')), 8, 'Fri 00:00 CT: weekend');
assert.strictEqual(w.picks(C, T('2026-11-30T23:00:00Z')), 8, 'Cyber Monday');
assert.strictEqual(w.picks(C, T('2026-12-01T05:59:59Z')), 8, 'Mon 23:59:59 CT');
assert.strictEqual(w.picks(C, T('2026-12-01T06:00:00Z')), 5, 'Tue 00:00 CT: normal again');
process.env.WEEKEND_PICKS = '0';
assert.strictEqual(w.picks(C, T('2026-11-28T12:00:00Z')), 5, 'WEEKEND_PICKS=0 switches it off');
process.env.WEEKEND_PICKS = '12'; assert.strictEqual(w.picks(C, T('2026-11-28T12:00:00Z')), 12);
delete process.env.WEEKEND_PICKS;
process.env.WEEKEND_NOW = '2026-11-29T18:00:00Z'; assert.strictEqual(w.picks(C), 8, 'test clock'); assert.strictEqual(w.live(), true);
const bot = require('../chatbot');
assert.match(bot.SITE.finish('A $10 position gives you 5 picks right away.'), /gives you 8 picks right away \(Network Weekend/);
assert.ok(/NETWORK WEEKEND/.test(bot.SITE.facts()) && !/\u2014/.test(bot.SITE.facts()));
process.env.WEEKEND_NOW = '2026-12-01T06:00:00Z';
assert.strictEqual(bot.SITE.finish('gives you 5 picks right away'), 'gives you 5 picks right away');
assert.ok(!/NETWORK WEEKEND/.test(bot.SITE.facts()));
process.env.WEEKEND_NOW = '2026-11-20T12:00:00Z'; assert.ok(!/NETWORK WEEKEND/.test(bot.SITE.facts()), 'nothing before the window');
delete process.env.WEEKEND_NOW;
console.log('weekend gate: all pass');
+10 -6
View File
@@ -31,6 +31,8 @@ const hubline = require('./hubline');
const hubevents = require('./hubevents'); // network hub hook (2026-11-16): sign-out-everywhere, block and erase end sessions here
const proof = require('./proof');
const netsites = require('./netsites');
const netdeals = require('./netdeals');
const weekend = require('./weekend');
const wild = require('./wild');
const PUB = path.join(__dirname, 'public');
@@ -256,7 +258,7 @@ const server = http.createServer(async (req, res) => {
// -- public API
if (p === '/api/config' && req.method === 'GET') {
return json(res, 200, { site: C.site, siteName: C.siteName, chainId: C.chainId, chainName: C.chainName, rpc: C.publicRpc, walletConnectProjectId: C.walletConnectProjectId,
position: C.position, split: C.split, draft: { dow: C.draft.dow, hour: C.draft.hour, rounds: C.draft.rounds, pickSeconds: C.draft.pickSeconds }, picks: { returnDays: C.picks.returnDays, maxOpen: C.picks.maxOpen, holdHours: C.picks.holdHours },
position: Object.assign({}, C.position, { picksOnBuy: weekend.picks(C), weekend: weekend.live() }), split: C.split, draft: { dow: C.draft.dow, hour: C.draft.hour, rounds: C.draft.rounds, pickSeconds: C.draft.pickSeconds }, picks: { returnDays: C.picks.returnDays, maxOpen: C.picks.maxOpen, holdHours: C.picks.holdHours },
pot: C.pot, sso: networksso.enabled(), shop: { live: shop.watching(), contract: shop.watching() ? C.contractAddress : null }, explorer: C.explorer, tank: C.tankMode, testMode: tank.preview(), joinUrl: joinUrl('') });
}
if (p === '/api/board' && req.method === 'GET') { const s = session(req); return json(res, 200, await board(s ? s.address : null)); }
@@ -275,6 +277,7 @@ const server = http.createServer(async (req, res) => {
if (p === '/api/ledger' && req.method === 'GET') return json(res, 200, proof.ledger(u.searchParams.get('n')), { 'Cache-Control': 'public, max-age=10' });
if (p === '/api/contract' && req.method === 'GET') { if (limited(req, 'contract', 600, 3600000)) return json(res, 429, { error: 'Too many requests' }); return json(res, 200, await proof.contract(), { 'Cache-Control': 'public, max-age=60' }); }
if (p === '/api/network-sites' && req.method === 'GET') return netsites.handle(req, res);
if (p === '/api/network-deals' && req.method === 'GET') return netdeals.handle(req, res, 'fivex'); // Network Weekend ribbon (2026-11-17)
// toasts: real events of the last 30 minutes (new coaches, picks, picks that levelled up)
if (p === '/api/recent' && req.method === 'GET') {
const t = now(); const cut = t - 30 * 60000;
@@ -288,7 +291,7 @@ const server = http.createServer(async (req, res) => {
if (limited(req, 'quote', 600, 3600000)) return json(res, 429, { error: 'Too many requests this hour.' });
const qty = Number(u.searchParams.get('qty') || 1);
if (!Number.isInteger(qty) || qty < 1 || qty > C.position.maxQty) return json(res, 400, { error: 'Pick 1 to ' + C.position.maxQty + ' positions.' });
try { return json(res, 200, Object.assign({ usd: C.position.usd * qty, picks: C.position.picksOnBuy * qty }, await shop.quote(qty))); } catch (e) { return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
try { return json(res, 200, Object.assign({ usd: C.position.usd * qty, picks: weekend.picks(C) * qty }, await shop.quote(qty))); } catch (e) { return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
}
if (p === '/api/gas' && req.method === 'GET') { try { return json(res, 200, shop.watching() ? await shop.fees() : {}); } catch (e) { return json(res, 200, {}); } }
if (/^\/api\/tx\/0x[0-9a-fA-F]{64}$/.test(p) && req.method === 'GET') {
@@ -360,7 +363,7 @@ const server = http.createServer(async (req, res) => {
}
if (p === '/api/my/instant' && req.method === 'POST') {
const b = await readBody(req); if (!HUBID_RE.test(String(b.person || ''))) return json(res, 400, { error: 'Pick a player.' });
if (!isCoach(me)) return json(res, 403, { error: 'Get a position first: it comes with ' + C.position.picksOnBuy + ' picks right away.' });
if (!isCoach(me)) return json(res, 403, { error: 'Get a position first: it comes with ' + weekend.picks(C) + ' picks right away.' });
return json(res, 200, await league.instantPick(me, String(b.person)));
}
if (p === '/api/my/queue' && req.method === 'POST') {
@@ -410,7 +413,7 @@ const server = http.createServer(async (req, res) => {
if (!wallets.length) why = 'no-line'; else v = await shop.voucher(me, wallets);
}
const hubRef = m.hubId ? BigInt('0x' + crypto.createHash('sha256').update(m.hubId).digest('hex').slice(0, 15)) : 0n; // ref = a short hash of the hub id (free data)
try { return json(res, 200, Object.assign({ buyer: me, usd: C.position.usd * qty, picks: C.position.picksOnBuy * qty, qty, why }, await shop.order(me, qty, hubRef, v))); }
try { return json(res, 200, Object.assign({ buyer: me, usd: C.position.usd * qty, picks: weekend.picks(C) * qty, qty, why }, await shop.order(me, qty, hubRef, v))); }
catch (e) { return json(res, 503, { error: 'Price unavailable right now. Try again in a minute.' }); }
}
if (p === '/api/my/paid' && req.method === 'POST') { shop.nudge(); return json(res, 200, { ok: true, confirmations: C.shopConfirmations }); }
@@ -422,7 +425,7 @@ const server = http.createServer(async (req, res) => {
if (!isAdmin(req)) return json(res, 401, { error: 'no' });
if (p === '/api/admin/status' && req.method === 'GET') {
const t = now(); const w = league.weekInfo(t); const d = store.draft(w.week);
return json(res, 200, { day: store.ctDay(t), week: w.week, now: t, draftAt: w.draftAt, config: { position: C.position, split: C.split, draft: C.draft, picks: C.picks, pot: C.pot, tankMode: C.tankMode },
return json(res, 200, { day: store.ctDay(t), week: w.week, now: t, draftAt: w.draftAt, config: { position: Object.assign({}, C.position, { picksOnBuy: weekend.picks(C), weekend: weekend.live() }), split: C.split, draft: C.draft, picks: C.picks, pot: C.pot, tankMode: C.tankMode },
members: store.members().length, coaches: store.coaches().length, picks: { all: store.picks().length, open: store.picks().filter(x => x.status === 'open').length, done: store.picks().filter(x => x.status === 'done').length, returned: store.picks().filter(x => x.status === 'returned').length, kept: store.picks().filter(x => x.status === 'kept').length },
draft: d ? { status: d.status, made: d.made.length, slots: d.slots.length, why: d.why || null } : null, pot: { weekWei: proof.potOf(w.from, w.to), best: draft.bestCoach(store.picks(), w.from, w.to, display).slice(0, 5) },
shop: shop.view(), proof: proof.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), hubEvents: hubevents.view(), tank: tank.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length, testClock: C.testClock });
@@ -474,7 +477,8 @@ const server = http.createServer(async (req, res) => {
proof.init(C, { shop, weekStats, nameOf: async a => { const h = await hubpeople.byWallet(a).catch(() => ({ ok: false })); return h.ok && h.person && h.person.username ? h.person.username : null; } });
league.init(C, { proof });
hubreport.init({ dataDir: C.dataDir, purchases: () => store.purchases().map(x => ({ key: x.key, buyer: x.buyer, sponsor: x.sponsor || null, usdCents: x.usdCents, block: x.block, at: x.at })) });
shop.setAttach(rec => { store.addCredits(rec.buyer, C.position.picksOnBuy * (Number(rec.qty) || 1)); store.bump('positions', Number(rec.qty) || 1); });
shop.setAttach(rec => { store.addCredits(rec.buyer, weekend.picks(C, Number(rec.blockAt) ? Number(rec.blockAt) * 1000 : (Number(rec.at) || undefined)) * (Number(rec.qty) || 1)); store.bump('positions', Number(rec.qty) || 1); }); // Network Weekend: the purchase's chain time decides the picks
netdeals.setLocal(d => (weekend.weekendPicks() > 0 ? d : null)); // WEEKEND_PICKS=0: no 5x line on the ribbon
shop.setHook(proof.onPurchase);
shop.init(C);
const loop = () => league.tick().catch(e => console.error('league tick', e.message)).finally(() => setTimeout(loop, C.draft.tickMs).unref());
+15
View File
@@ -0,0 +1,15 @@
// Network Weekend (Marty 2026-11-17, Black Friday to Cyber Monday 2026): 8 instant picks per position instead of 5 for positions
// bought from Fri 11-27 00:00 CT to Tue 12-01 00:00 CT (CST = UTC-6), no price change. It switches on and off by itself at those
// instants; the purchase's own chain time (blockAt) decides, so a Monday 23:59 buy confirmed after midnight still gets 8.
// Holding-tank check 2026-11-17: draft pool 1,339 people, 2 positions sold since launch 11-15, so 8 per sale is covered.
// WEEKEND_PICKS the weekend number (default 8, 1 to 20); WEEKEND_PICKS=0 switches the weekend deal off (normal picks all weekend)
// WEEKEND_NOW test clock (ISO), tests only: never set it on the server
'use strict';
const START = Date.parse('2026-11-27T06:00:00Z');
const END = Date.parse('2026-12-01T06:00:00Z');
function nowMs() { const o = process.env.WEEKEND_NOW; const t = o ? Date.parse(o) : NaN; return Number.isNaN(t) ? Date.now() : t; }
function weekendPicks() { const v = Number(process.env.WEEKEND_PICKS === undefined || process.env.WEEKEND_PICKS === '' ? 8 : process.env.WEEKEND_PICKS); return Number.isInteger(v) && v >= 1 && v <= 20 ? v : 0; }
function live(ms) { ms = ms === undefined ? nowMs() : ms; return weekendPicks() > 0 && ms >= START && ms < END; }
// instant picks per position for a purchase made at `ms` (default: now)
function picks(C, ms) { return live(ms) ? weekendPicks() : C.position.picksOnBuy; }
module.exports = { START, END, nowMs, live, picks, weekendPicks };