Files
miti99bot/internal/telegram/client.go
T
tiennm99 25a5f37d3d feat(server,modules): bootstrap server and module framework
Implements Phases 02 (partial) and 03 of the go-port-cloud-run plan.
Introduces module framework with per-module KV prefix isolation,
health check endpoint, request timeout protection, and comprehensive
test coverage. Cloud Run deployment deferred to Phase 01.

Security hardening: constant-time secret comparison, cron auth bridge,
and secrets stripped from dependency environment exports. Includes
Dockerfile, GitHub CI workflow (vet + race + build), and integration
tests for module lifecycle.
2026-05-08 23:27:12 +07:00

23 lines
788 B
Go

package telegram
import (
"github.com/go-telegram/bot"
)
// NewBot constructs a Telegram bot configured for webhook mode:
//
// - WithSkipGetMe: avoid a 5s blocking call to Telegram during cold start.
// Token validity surfaces on the first outgoing API call instead.
// - WithNotAsyncHandlers: handlers run synchronously inside the dispatcher's
// goroutine. The webhook handler can rely on r.Context() staying live for
// the duration of dispatch, which a goroutine-spawning default would break.
//
// Callers may pass extra options that override these defaults.
func NewBot(token string, opts ...bot.Option) (*bot.Bot, error) {
defaults := []bot.Option{
bot.WithSkipGetMe(),
bot.WithNotAsyncHandlers(),
}
return bot.New(token, append(defaults, opts...)...)
}