Files
tiennm99bot/internal/modules/loldleability/loldleability.go
T
tiennm99 08e5a6d7fa feat(modules): port loldle-ability
Phase 6c of the go-port-cloud-run plan. Adds the third loldle variant
— guess the champion from a single ability icon (passive or Q/W/E/R).

- internal/modules/loldleability: champions.go (embed
  abilities.json, 5334-line DDragon-sourced pool with
  AbilityChampion + Ability types), state.go (gameState gains a
  `slot` field so the same icon shows across guesses in a round),
  render-free handlers.go (sendPhoto path uses
  models.InputFileString with the DDragon CDN URL directly — no
  binary upload), loldleability.go (Module Factory).
- Reuses internal/modules/util/chathelper and internal/champname
  (same shared layer the other variants use).
- 4 commands wired: loldle_ability (public), loldle_ability_giveup
  (public), loldle_ability_stats (public), loldle_ability_setmax
  (private).
- 14 tests: lookup (embed shape + DDragon URL prefix + slot
  coverage), state (slot round-trip + JS-wire-format decode +
  streak), handlers (sendPhoto with correct URL, win, unknown
  champion, duplicate, giveup with slot label, stats, setmax owner
  + non-owner).
- gocyclo cap nudged 20 -> 22 to accommodate handleAbility's
  pre-flight validation branch.

go test -race -count=1 ./... clean (17 packages); golangci-lint
clean.
2026-05-09 16:53:26 +07:00

40 lines
1.1 KiB
Go

package loldleability
import (
"github.com/tiennm99/miti99bot-go/internal/modules"
)
// New is the loldle-ability module Factory. Loads the embedded pool once
// and shares it (plus the per-subject lock map) across all handlers.
func New(deps modules.Deps) modules.Module {
s := &state{kv: deps.KV, pool: loadPool()}
return modules.Module{
Commands: []modules.Command{
{
Name: "loldle_ability",
Visibility: modules.VisibilityPublic,
Description: "Ability loldle — guess the champion from an ability icon",
Handler: s.handleAbility,
},
{
Name: "loldle_ability_giveup",
Visibility: modules.VisibilityPublic,
Description: "Reveal the current ability loldle answer",
Handler: s.handleGiveup,
},
{
Name: "loldle_ability_stats",
Visibility: modules.VisibilityPublic,
Description: "Show your ability loldle stats (wins, streak)",
Handler: s.handleStats,
},
{
Name: "loldle_ability_setmax",
Visibility: modules.VisibilityPrivate,
Description: "Override ability loldle max guesses per round (1-10)",
Handler: s.handleSetMax,
},
},
}
}