channel

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package channel provides an abstraction for external messaging channels (e.g. WeChat, Telegram) that connect to the jcode agent as lightweight notification + remote prompt sidecars.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApprovalMessage

func ApprovalMessage(toolName, toolArgs, hint string) string

ApprovalMessage returns a formatted approval notification.

func BusyMessage

func BusyMessage() string

BusyMessage returns a message for when a task is already in progress.

func DoneMessage

func DoneMessage(summary string, err error) string

DoneMessage returns a formatted task completion notification.

func GoodbyeMessage

func GoodbyeMessage(t time.Time) string

GoodbyeMessage returns a time-aware goodbye message.

func LoginReminderMessage added in v0.2.2

func LoginReminderMessage() string

LoginReminderMessage returns a reminder that the user must send a message to activate the 24-hour session window on WeChat iLink Bot.

func WelcomeMessage

func WelcomeMessage(t time.Time) string

WelcomeMessage returns a time-aware welcome message.

Types

type Channel

type Channel interface {
	// ID returns the channel identifier (e.g. "wechat").
	ID() string
	// State returns the current lifecycle state.
	State() State
	// Login initiates the authentication flow (e.g. QR scan).
	// Returns a login session that can be waited on.
	Login() (*LoginSession, error)
	// Logout clears credentials and stops the channel.
	Logout() error
	// Enable starts push notifications and inbound message polling.
	Enable() error
	// Disable stops push notifications and polling but keeps credentials.
	Disable() error
	// SendText sends a text message to the connected user.
	SendText(text string) error
}

Channel is the interface that all messaging channel implementations must satisfy.

type LoginSession

type LoginSession struct {
	// QRCodeURL is a URL that renders a QR code image for scanning.
	QRCodeURL string
	// QRCodeContent is the raw content to encode as a QR code in terminal.
	QRCodeContent string
	// SessionKey identifies this login attempt.
	SessionKey string
	// WaitFunc blocks until login completes or times out. Returns nil on success.
	WaitFunc func() error
}

LoginSession represents an in-progress login that requires user action (e.g. QR scan).

type State

type State int

State represents the lifecycle state of a channel.

const (
	// StateNone means the channel has never been configured (no credentials).
	StateNone State = iota
	// StateDisabled means the channel has credentials but push/receive is off.
	StateDisabled
	// StateEnabled means the channel is actively pushing notifications and receiving messages.
	StateEnabled
)

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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