openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
43 lines (42 loc) • 1.52 kB
JavaScript
import { o as writeRuntimeJson } from "./runtime-B-SLYP-m.mjs";
import { n as sanitizeTerminalText } from "./safe-text-C80HAQ2e.mjs";
import { t as formatCliCommand } from "./command-format-CqdwUgPk.mjs";
import { t as ClawHubRequestError } from "./clawhub-client-BLg-dsn2.mjs";
import { n as fetchClawHubPromotions } from "./clawhub-promotions-ChcxrQR2.mjs";
//#region src/commands/promos/list.ts
async function promosListCommand(e, t) {
let n;
try {
n = await fetchClawHubPromotions();
} catch (n) {
if (!(n instanceof ClawHubRequestError) || n.status !== 404) throw n;
if (e.json) writeRuntimeJson(t, { promotions: [] });
else t.log("Promotions are not available from ClawHub yet.");
return;
}
if (e.json) {
writeRuntimeJson(t, { promotions: n });
return;
}
if (n.length === 0) {
t.log("No active promotions right now.");
return;
}
const r = sanitizeTerminalText;
for (const e of n) {
const n = e.sponsor ? ` — ${r(e.sponsor)}` : "";
const i = r(e.title);
const a = Math.max(0, Math.floor((e.endsAt - Date.now()) / 864e5));
const o = a === 0 ? "ends today" : a === 1 ? "1 day left" : `${a} days left`;
t.log(`${i}${n} (${o})`);
t.log(` ${r(e.blurb)}`);
for (const n of e.models) {
const e = n.alias ? ` (${r(n.alias)})` : "";
const i = n.suggestedDefault ? " — suggested default" : "";
t.log(` · ${r(n.modelRef)}${e}${i}`);
}
t.log(` Claim: ${formatCliCommand(`openclaw promos claim ${r(e.slug)}`)}`);
}
}
//#endregion
export { promosListCommand };