mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-06-09 18:14:46 +00:00
25a5f37d3d
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.
23 lines
788 B
Go
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...)...)
|
|
}
|