Files
miti99bot/internal/modules/wordle/wordle.go
T
tiennm99 3e8d6bf2a7 refactor(storage): replace KVStore with generic typed DocStore[T]
Delete the byte-oriented KVStore/VersionedStore abstraction and the
DynamoDB/memory KV backends. Add a generic typed store (DocStore[T] with
Provider/Collection/Typed) persisting each value as a flattened native
Mongo document (storedDoc[T] via bson inline) — no value envelope.

- MongoDB is the only runtime backend; memory kept for tests/local.
- All modules + deploynotify use typed stores; persisted structs carry
  bson tags == json names (incl. nested lolschedule/wordle types).
- lolschedule wraps its array/scalar values in named structs.
- migrate-dynamo-to-mongo writes the flattened shape via Typed[bson.M]
  with wrap rules; Scan/--dry-run/--verify retained.

Verified: go vet/build clean; full go test green hermetically and
in-container vs real Mongo 7 + DynamoDB Local (storage integration +
migrator e2e).
2026-06-28 18:02:11 +07:00

48 lines
1.2 KiB
Go

package wordle
import (
"github.com/tiennm99/miti99bot/internal/modules"
"github.com/tiennm99/miti99bot/internal/storage"
)
// New is the wordle module Factory. Loads the embedded dictionary once,
// captures the per-module typed stores via closure, and registers all four commands.
func New(deps modules.Deps) modules.Module {
words, set := loadWords()
s := &state{
games: storage.Typed[GameState](deps.Store),
stats: storage.Typed[Stats](deps.Store),
words: words,
set: set,
}
return modules.Module{
Commands: []modules.Command{
{
Name: "wordle",
Visibility: modules.VisibilityPublic,
Description: "Classic wordle — guess the 5-letter word",
Handler: s.handleWordle,
},
{
Name: "wordle_new",
Visibility: modules.VisibilityPublic,
Description: "Start a new round (auto-gives-up any in-progress one)",
Handler: s.handleNew,
},
{
Name: "wordle_giveup",
Visibility: modules.VisibilityPublic,
Description: "Reveal the current wordle answer",
Handler: s.handleGiveup,
},
{
Name: "wordle_stats",
Visibility: modules.VisibilityPublic,
Description: "Show your wordle stats (wins, streak)",
Handler: s.handleStats,
},
},
}
}