Documentation
¶
Overview ¶
Package api serves the HTTP API on top of a bot.Bot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeChats ¶
NormalizeChats turns allowlist entries (phone numbers or JIDs) into JIDs.
Types ¶
type CallerStats ¶
type CallerStats struct {
bot.TokenUsage
Streams int `json:"open_streams"`
}
CallerStats is a token's (or the owner's, as "api") activity in the last 24 hours.
type Handler ¶
Handler is the API. StopStreams ends open /events and /messages/wait connections, which http.Server.Shutdown doesn't; register it with RegisterOnShutdown.
func NewHandler ¶
NewHandler serves the API. Every route requires a scope; see docs/API.md for the table.
type Stats ¶
type Stats struct {
Version string `json:"version"`
Started time.Time `json:"started"`
AutoReply bool `json:"auto_reply"`
Limits StatsLimits `json:"limits"`
Webhook *bot.WebhookStats `json:"webhook"`
Queue bot.QueueStats `json:"queue"`
Alerts bot.AlertStats `json:"alerts"`
Callers []CallerStats `json:"callers"`
}
Stats is the body of GET /stats: what the admin panel's Health tab shows.
type StatsLimits ¶
type StatsLimits struct {
Send bot.LimiterStats `json:"send"`
Lookups bot.LimiterStats `json:"lookups"`
AutoReply bot.LimiterStats `json:"auto_reply"`
}