channels

package
v0.0.0-...-fce5618 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 6 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 channels defines the channel Sender abstraction and per-type config handling. A Sender takes a channel's config + an SMS and delivers it. v1 sender: telegram (shared bot). The registry starts empty; main registers the Telegram sender when a bot is configured.

Index

Constants

View Source
const (
	TypeTelegram = "telegram"
)

Variables

View Source
var ErrChannelUnbound = errors.New("channel binding invalid")

ErrChannelUnbound signals the recipient is permanently unreachable for this channel's current config (e.g. Telegram 403: bot blocked / can't initiate / chat not found) — retrying won't help; the forward engine clears the binding so the user is prompted to re-bind.

Functions

func KnownType

func KnownType(typ string) bool

KnownType reports whether typ is a valid channel type (even if its sender isn't wired yet).

func Ready

func Ready(typ, config string) bool

Ready reports whether a channel has enough config to actually deliver.

func ValidateConfig

func ValidateConfig(typ, config string) error

ValidateConfig checks a user-supplied config for a channel type.

Types

type Message

type Message struct {
	Sender    string
	Content   string
	Timestamp int64 // unix seconds
}

Message is one SMS to be delivered.

type Registry

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

Registry maps channel type -> Sender.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Register

func (r *Registry) Register(typ string, s Sender)

Register adds/overrides a sender (main registers Telegram when configured).

func (*Registry) Sender

func (r *Registry) Sender(typ string) (Sender, bool)

type Sender

type Sender interface {
	Send(ctx context.Context, config string, msg Message) error
}

Sender delivers a Message to one channel, given that channel's config JSON.

func NewTelegramSender

func NewTelegramSender(send func(ctx context.Context, chatID int64, text string) error) Sender

NewTelegramSender wires a Telegram sender around the bot's Send function.

Jump to

Keyboard shortcuts

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