api

package
v0.0.0-...-342b693 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func NormalizeChats(entries []string) ([]string, error)

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

type Handler struct {
	http.Handler
	StopStreams func()
}

Handler is the API. StopStreams ends open /events and /messages/wait connections, which http.Server.Shutdown doesn't; register it with RegisterOnShutdown.

func NewHandler

func NewHandler(b *bot.Bot, authn *auth.Authenticator, version string) *Handler

NewHandler serves the API. Every route requires a scope; see docs/API.md for the table.

type LogPage

type LogPage struct {
	Entries []bot.LogEntry `json:"entries"`
}

LogPage is the body of GET /logs.

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL