Phase 2a — add 'http' handler (sync forwarder)
All checks were successful
Docker Build / build-and-push-image (push) Successful in 53s

The http handler POSTs the Telegram Update JSON to a configurable
internal URL and expects a JSON {text} reply, which it sends back via
sendMessage. Sync : the webhook ack waits for the upstream answer
(timeout default 5s, capped at 30s — Telegram itself closes around 60s).

For slow / unreliable backends use the Phase 3 async handlers once the
queue is in place.

YAML config :

  bots:
    webappbot:
      handler: http
      http:
        url: http://webapp.webapp.svc.cluster.local:8080/telegram/update
        timeout: 5s

Refs ~/.claude/plans/pour-les-notifications-on-inherited-seal.md § Phase 2.
This commit is contained in:
2026-05-09 14:27:58 +02:00
parent 515b407db4
commit 8001460f14
3 changed files with 140 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strings"
"time"
"gopkg.in/yaml.v3"
)
@@ -18,9 +19,21 @@ type BotConfig struct {
// (nil) the registry treats it as true — secure by default. Explicit
// `requireAuth: false` is required to expose a bot publicly.
// Forced to false for handler=auth (chicken-and-egg).
RequireAuth *bool `yaml:"requireAuth,omitempty"`
Token string `yaml:"-"`
Secret string `yaml:"-"`
RequireAuth *bool `yaml:"requireAuth,omitempty"`
// HTTP is the per-bot config for the `http` handler. Required when
// handler=http. See handler_http.go.
HTTP *HTTPConfig `yaml:"http,omitempty"`
Token string `yaml:"-"`
Secret string `yaml:"-"`
}
// HTTPConfig drives the `http` handler : the gateway POSTs the Telegram
// Update JSON to URL, awaits a JSON `{text}` response within Timeout,
// then sends Text back to the user via sendMessage.
type HTTPConfig struct {
URL string `yaml:"url"`
Timeout time.Duration `yaml:"timeout,omitempty"`
}
// LoadConfig reads the YAML routing config and merges per-bot secrets pulled