mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-06-09 02:14:56 +00:00
dd4e86a5de182c79b2924609c2d0d733eb94b6bf
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.
miti99bot-go
Plug-n-play Telegram bot framework in Go, deployed on Google Cloud Run with Firestore + Gemini. Free-tier port of miti99bot.
Status
Early scaffolding. See plans/260508-2222-go-port-cloud-run/plan.md for the full roadmap.
| Phase | What | Status |
|---|---|---|
| 01 | GCP setup, Cloud Run baseline | pending |
| 02 | Repo bootstrap + webhook skeleton | partial (local pieces done; Cloud Run deploy deferred to Phase 01) |
| 03 | Module framework + KVStore | done |
| 04+ | Firestore, modules, cron, CI/CD, cutover | pending |
Layout
cmd/server/ entrypoint
internal/server/ HTTP routes (/, /webhook, /cron/{name})
internal/telegram/ Telegram webhook + bot wrapper
internal/modules/ Module framework, registry, dispatchers
internal/storage/ KVStore interface, in-memory impl, prefix wrapper
Run locally
TELEGRAM_BOT_TOKEN=… \
TELEGRAM_WEBHOOK_SECRET=local \
PORT=8080 \
MODULES= \
go run ./cmd/server
End-to-end smoke test against a Telegram dev bot requires ngrok (local) or a Cloud Run deployment. The dev bot is created manually; token is injected via env vars only.
Test
go vet ./...
go test ./...
Build
docker build -t miti99bot-go .
The image is multi-stage (golang:1.23-alpine → gcr.io/distroless/static:nonroot); resulting image is ~15 MiB.
License
Description
Plug-n-play Telegram bot framework on Cloudflare Workers with grammY. Modules load via env var, three command visibility levels, KV storage behind a swappable interface.
bot-frameworkcloudflarecloudflare-kvcloudflare-workersfungamegrammyjavascriptplaygroundplugin-systemserverlesstelegramtelegram-bottelegrambotwebhook
Readme
Apache-2.0
3.5 MiB
Languages
Go
98.1%
Makefile
1.5%
Shell
0.3%