channel

package
v1.261022.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MPL-2.0 Imports: 3 Imported by: 2 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 channel defines the human-facing side of the remote middle layer: a Channel is a surface (IM bot, web UI, CLI, …) that can deliver an interaction.Notification or interaction.Interaction to a human and (for interactive ones) collect a Reply.

The Channel interface deliberately speaks the JSON-friendly interaction.* types so the same contract can be served over RPC in the future.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	Buttons      bool
	EditMessages bool
	Markdown     bool
}

Capabilities reports what UI affordances a Channel supports. Used by scenarios to decide whether to use buttons or fall back to numbered text replies.

type Channel

type Channel interface {
	// ID is the stable identifier this channel is registered under
	// (typically a bot UUID).
	ID() string
	// Platform returns the channel-native platform name ("telegram",
	// "feishu", …) for logging / routing decisions.
	Platform() string
	// Capabilities reports what UI affordances the channel supports.
	Capabilities() Capabilities
	// Send delivers a one-way notification.
	Send(ctx context.Context, target Target, msg interaction.Notification) error
	// Prompt delivers an interactive request and blocks until a reply
	// arrives or the context / timeout fires.
	Prompt(ctx context.Context, target Target, ix interaction.Interaction) (interaction.Reply, error)
}

Channel is a one-way + interactive message surface for humans.

Implementations must be safe for concurrent use by multiple goroutines. Send is fire-and-forget (no reply); Prompt blocks until the human replies, the context is cancelled, or the interaction's own Timeout elapses.

type Registry

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

Registry is a thread-safe map of Channel by stable ID. Bots register their Channel implementation at startup and unregister at shutdown; scenarios look up the Channel they should send to via the binding resolver.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty registry.

func (*Registry) ByPlatform added in v1.261022.2

func (r *Registry) ByPlatform(platform string) []Channel

ByPlatform returns the registered channels of one platform ("telegram", "feishu", …), in no particular order.

func (*Registry) Get

func (r *Registry) Get(id string) (Channel, bool)

Get returns the channel for id and whether one is registered.

func (*Registry) Len

func (r *Registry) Len() int

Len returns the number of registered channels.

func (*Registry) Register

func (r *Registry) Register(c Channel)

Register adds or replaces a channel under its ID.

func (*Registry) Unregister

func (r *Registry) Unregister(id string)

Unregister removes the channel for id.

type Target

type Target struct {
	// ChatID is the channel-native conversation/room identifier.
	ChatID string
	// User is the optional channel-native user identifier (for routing
	// to a specific person inside a multi-user chat).
	User string
}

Target identifies who on a Channel should receive a message.

Directories

Path Synopsis
Package autochannel provides a non-IM Channel implementation for headless / CI / programmatic setups.
Package autochannel provides a non-IM Channel implementation for headless / CI / programmatic setups.
Package imchannel adapts an IM bot (one of the platforms in github.com/tingly-dev/tingly-box/imbot) into the internal/remote/channel.Channel contract.
Package imchannel adapts an IM bot (one of the platforms in github.com/tingly-dev/tingly-box/imbot) into the internal/remote/channel.Channel contract.

Jump to

Keyboard shortcuts

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