Documentation
¶
Index ¶
- Constants
- Variables
- func NewWebhookDriver(gaSettings AnalyticsSettings, botHost botsfw.BotHost, panicTextFooter string) botsfw.WebhookDriver
- func NewWebhookRouter(errorFooterText func(ctx context.Context, botContext ErrorFooterArgs) string) botsfw.Router
- type AnalyticsSettings
- type CommandsRegisterer
- type ErrorFooterArgs
- type ErrorFooterTextFunc
- type RegisterCommandsForInputTypeFunc
- type RegisterCommandsFunc
- type RouteTraceEvent
- type TypeCommands
Constants ¶
const MaxWebhookRequestBodyBytes int64 = 8 << 20
MaxWebhookRequestBodyBytes limits webhook payloads before platform adapters decode them. Webhook bodies are metadata envelopes rather than media uploads; 8 MiB leaves ample room for batched updates while bounding memory use.
Variables ¶
var ErrNoCommandsMatched = errors.New("no commands matched")
var ErrorIcon = "🚨"
ErrorIcon is used to report errors to user
var RoutingTracer func(ctx context.Context, event RouteTraceEvent)
RoutingTracer, when non-nil, receives a RouteTraceEvent for the final routing decision of each text message — which command won and why (or that nothing matched). It is an opt-in troubleshooting hook: leave it nil (the default) in production for zero overhead, and set it to answer "why did this reply route there?" without turning on framework-wide debug logging.
This is a package-level toggle shared by every router; set it from one place while debugging. The callback must be cheap and non-blocking.
Functions ¶
func NewWebhookDriver ¶ added in v0.62.0
func NewWebhookDriver(gaSettings AnalyticsSettings, botHost botsfw.BotHost, panicTextFooter string) botsfw.WebhookDriver
NewWebhookDriver registers new bot driver (TODO: describe why we need it)
func NewWebhookRouter ¶ added in v0.66.0
func NewWebhookRouter(errorFooterText func(ctx context.Context, botContext ErrorFooterArgs) string) botsfw.Router
NewWebhookRouter creates new router
Types ¶
type AnalyticsSettings ¶
type AnalyticsSettings struct {
GaTrackingID string // TODO: Refactor to list of analytics providers
Enabled func(r *http.Request) bool
}
AnalyticsSettings keeps data for Google Analytics
type CommandsRegisterer ¶ added in v0.66.0
type ErrorFooterArgs ¶ added in v0.66.0
type ErrorFooterArgs struct {
}
type ErrorFooterTextFunc ¶ added in v0.66.0
type ErrorFooterTextFunc func(ctx context.Context, botContext ErrorFooterArgs) string
type RegisterCommandsForInputTypeFunc ¶ added in v0.66.0
type RegisterCommandsFunc ¶ added in v0.66.0
type RouteTraceEvent ¶ added in v0.75.0
type RouteTraceEvent struct {
// InputText is the message text that was being routed.
InputText string
// AwaitingReplyTo is the chat's AwaitingReplyTo at match time ("" if none).
AwaitingReplyTo string
// CommandCode is the command that matched, or "" for a no-match.
CommandCode string
// Reason is HOW the command matched, one of:
// "command-code" — explicit "/code"
// "start-command" — "/start <code>"
// "command-alias" — one of Command.Commands
// "awaiting-reply" — the chat is awaiting a reply to this command
// "awaiting-reply-replies" — matched a nested reply under the awaiting command
// "exact-match" — Command.ExactMatch
// "default-title" — Command.DefaultTitle
// "matcher" — Command.Matcher returned true
// "no-match" — nothing matched (CommandCode is "")
Reason string
}
RouteTraceEvent describes the final command-routing decision for one text message: which command won and by which rule (or that nothing matched). It is emitted by the message router when RoutingTracer is set.
type TypeCommands ¶ added in v0.66.0
type TypeCommands struct {
// contains filtered or unexported fields
}
TypeCommands container for commands