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 ¶
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 ¶
DoneMessage returns a formatted task completion notification.
func GoodbyeMessage ¶
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 ¶
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 )