Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupported = errors.New("operation not supported by this channel")
ErrNotSupported indicates a channel doesn't support a particular operation.
Functions ¶
This section is empty.
Types ¶
type AudioAttachment ¶
type AudioAttachment struct {
MimeType string // e.g. "audio/amr", "audio/ogg", "audio/mp4"
Data []byte // raw audio bytes
Format string // short format hint: "amr", "ogg", "m4a", "mp3", "wav", etc.
Duration int // duration in seconds (if known)
}
AudioAttachment represents a voice/audio message sent by the user.
type Channel ¶
type Channel interface {
Name() string
Start(handler MessageHandler) error
Reply(ctx context.Context, replyCtx any, content string) error
Send(ctx context.Context, replyCtx any, content string) error
Stop() error
}
Channel abstracts a messaging channel (WeCom, Feishu, DingTalk, etc.).
type FileAttachment ¶
type FileAttachment struct {
MimeType string // e.g. "application/pdf", "text/plain"
Data []byte // raw file bytes
FileName string
}
FileAttachment represents a file (PDF, doc, spreadsheet, etc.) sent by the user.
type FileSender ¶
type FileSender interface {
SendFile(ctx context.Context, replyCtx any, file FileAttachment) error
}
FileSender is an optional interface for channels that support sending files.
type ImageAttachment ¶
type ImageAttachment struct {
MimeType string // e.g. "image/png", "image/jpeg"
Data []byte // raw image bytes
FileName string // original filename (optional)
}
ImageAttachment represents an image sent by the user.
type ImageSender ¶
type ImageSender interface {
SendImage(ctx context.Context, replyCtx any, img ImageAttachment) error
}
ImageSender is an optional interface for channels that support sending images.
type Message ¶
type Message struct {
SessionKey string // unique key for user context, e.g. "wecom:{userID}"
Channel string
MessageID string // channel message ID for tracing/dedup
UserID string
UserName string
ChatName string // human-readable chat/group name (optional)
Content string
Images []ImageAttachment // attached images (if any)
Files []FileAttachment // attached files (if any)
Audio *AudioAttachment // voice message (if any)
ReplyCtx any // channel-specific context needed for replying
FromVoice bool // true if message originated from voice transcription
}
Message represents a unified incoming message from any channel.
type MessageHandler ¶
MessageHandler is called by channels when a new message arrives.
type MessageUpdater ¶
type MessageUpdater interface {
UpdateMessage(ctx context.Context, replyCtx any, content string) error
}
MessageUpdater is an optional interface for channels that support updating messages.
type ReplyContextReconstructor ¶
ReplyContextReconstructor is an optional interface for channels that can recreate a reply context from a session key. This is needed for cron jobs to send messages to users without an incoming message.
type TypingIndicator ¶
TypingIndicator is an optional interface for channels that can show a "processing" indicator (typing bubble, emoji reaction, etc.) while the agent is working.