mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-06-08 18:16:54 +00:00
b3dea5fe21ff2eea401cf9daaf2328d4f7dfba25
Phase 5 of the 2026-05-09 review remediation plan. Closes the handler-layer test gap (5 modules at 0% coverage in the audit) and ends the storage-package's CI t.Skip on Firestore emulator tests. - internal/testutil: Update fixture builders (NewPrivateMessage, NewGroupMessage, NewSupergroupMessage, NewChannelMessage) plus a RecordingBot that wraps the real go-telegram/bot.Bot with an httptest server. The bot library hits the test server instead of Telegram; multipart form fields are captured per call. Tests assert on Sent() / LastSent() / AssertSentText(). - Handler tests added: misc (4), util (7), wordle (10), loldle (9), loldleemoji (8). Cover happy paths, error paths, auth gates, group-vs-private subject keying, KV side effects. - Coverage 44.7% -> 69.8% (verified via -coverprofile). All packages now report coverage in CI output. - CI: ci.yml installs cloud-firestore-emulator beta component and starts it on localhost:8090 before go test. Sets FIRESTORE_EMULATOR_HOST + GOOGLE_CLOUD_PROJECT env so the storage package's emulator-gated tests execute instead of skipping. go test -race -count=1 ./... clean across all 15 packages locally.
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%