mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-09-10 16:18:32 +00:00
80ef66447313de45ae003e1bc6ca89bbd5853a26
Phase 3 of the 2026-05-09 review remediation plan. Eliminates the helper drift (subjectFor / argAfterCommand / nowMillis / reply / replyHTML / winRate) that previously lived in 3-4 modules, plus the loldle-specific normalize / findChampion / findByExactName. - internal/modules/util/chathelper: SubjectFor, ArgAfterCommand, NowMillis, Reply, ReplyHTML, WinRate. Single canonical SubjectFor shape (group/supergroup -> chat ID, else user ID); WinRate uses math.Round to match JS Math.round (the truncation drift caught in Phase 5b/5c). - internal/champname: Normalize + generic Find[T] / FindByExactName[T] with name-extractor closure. Loldle and loldle-emoji both consume via Champion / EmojiChampion. Migrations: wordle, loldle, loldle-emoji, misc, util/info, util/stickerid. Module-local lookup.go + normalize.go in loldle and loldle-emoji deleted. go test -race -count=1 ./... clean across all 12 packages. Net ~290 lines removed across handler files.
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 in Go, self-hosted on Coolify + MongoDB Atlas with cron, games, schedules, and paper trading modules.
bot-frameworkcoolifycrongeminigoleague-of-legendslong-pollingmongodbmongodb-atlaspaper-tradingself-hostedtelegramtelegram-botwordleworld-cup
Readme
Apache-2.0
4.7 MiB
Languages
Go
99.8%
Dockerfile
0.2%