binding

package
v0.260507.0-rc5 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package binding describes which channel a scenario should use for a given event. Bindings live alongside bot settings (see internal/data/db.Settings.Scenarios) as a JSON-encoded list per bot.

The binding type is generic across scenarios — fields beyond Name / ChatID / Events are stored as a free-form Options map so new scenarios can add scenario-specific settings without changing the schema or the generic resolver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	// Name matches the scenario plugin Name() and the :scenario URL
	// segment of /tingly/:scenario/...
	Name string `json:"name"`
	// ChatID is the IM chat the bot routes to. Channels look this up
	// when delivering Send / Prompt.
	ChatID string `json:"chat_id"`
	// Events optionally restricts which event names this binding
	// handles. Empty list = all events.
	Events []string `json:"events,omitempty"`
	// Options carries scenario-specific configuration the resolver
	// returns verbatim to the plugin (e.g. permission policy for the
	// claude_code scenario).
	Options map[string]any `json:"-"`
}

Binding declares how a single bot serves a named scenario.

type Resolved

type Resolved struct {
	Binding  Binding
	BotUUID  string
	Platform string
	BotName  string
}

Resolved is what the resolver returns to the plugin: the binding itself plus the bot identity needed to look up a Channel.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver matches (scenario, event) to a single bot binding by scanning enabled bot settings. Read-only and safe for concurrent use.

func NewResolver

func NewResolver(store Store) *Resolver

NewResolver constructs a resolver backed by the given store.

func (*Resolver) Resolve

func (r *Resolver) Resolve(scenario, event string) (*Resolved, error)

Resolve returns the first enabled bot whose binding matches scenario + event. ok=false means no binding exists; err is non-nil only on store failures.

type Store

type Store interface {
	ListEnabledSettings() ([]db.Settings, error)
}

Store is the subset of the imbot settings store the resolver needs. Defining it as an interface keeps the resolver testable.

Jump to

Keyboard shortcuts

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