Files
miti99bot/scripts/build-wordle-data.js
T
tiennm99 785de9231a feat(wordle): port classic 5-letter guessing game
Replaces the wordle stub with a full implementation mirroring the loldle
module layout: compare/lookup/daily/render/state/handlers/index split,
per-subject KV state, standard 6 guesses, two-pass duplicate-letter
marking.

Commands: /wordle, /wordle_new, /wordle_giveup, /wordle_stats.

Word list (14,855 entries) sourced from dracos's gist
(https://gist.github.com/dracos/dd0668f281e685bad51479e5acaadb93) and
bundled via scripts/build-wordle-data.js. Credits in module README and
generated file headers.

Dispatcher test updated for the new command count (12 → 13).
2026-04-20 22:08:58 +07:00

50 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
/**
* @file build-wordle-data — fetches the 5-letter wordle word list from the
* dracos gist and writes it as an ES module export to
* src/modules/wordle/words-data.js.
*
* Source: https://gist.github.com/dracos/dd0668f281e685bad51479e5acaadb93
* Credits: Anna Eilering (dracos) — combined Wordle dictionary of allowed guesses.
*
* Usage:
* node scripts/build-wordle-data.js
*/
import { writeFileSync } from "node:fs";
import { resolve } from "node:path";
const GIST_URL = "https://gist.githubusercontent.com/dracos/dd0668f281e685bad51479e5acaadb93/raw/";
const root = resolve(import.meta.dirname, "..");
const dst = resolve(root, "src/modules/wordle/words-data.js");
const res = await fetch(GIST_URL);
if (!res.ok) throw new Error(`fetch failed: ${res.status} ${res.statusText}`);
const text = await res.text();
const words = [
...new Set(
text
.split(/\r?\n/)
.map((w) => w.trim().toLowerCase())
.filter((w) => /^[a-z]{5}$/.test(w)),
),
].sort();
if (words.length === 0) throw new Error("no words parsed from gist");
const body = words.map((w) => ` "${w}",`).join("\n");
const out = [
"// Auto-generated from https://gist.github.com/dracos/dd0668f281e685bad51479e5acaadb93",
"// Credits: Anna Eilering (dracos) — combined Wordle dictionary of allowed 5-letter guesses.",
"// Regenerate with: node scripts/build-wordle-data.js",
"export default [",
body,
"];",
"",
].join("\n");
writeFileSync(dst, out);
console.log(`wrote ${dst} (${words.length} words)`);