2026-02-22 20:55:15 +00:00
|
|
|
package channels
|
|
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
|
|
// TypingCapable — channels that can show a typing/thinking indicator.
|
|
|
|
|
// StartTyping begins the indicator and returns a stop function.
|
|
|
|
|
// The stop function MUST be idempotent and safe to call multiple times.
|
|
|
|
|
type TypingCapable interface {
|
|
|
|
|
StartTyping(ctx context.Context, chatID string) (stop func(), err error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MessageEditor — channels that can edit an existing message.
|
|
|
|
|
// messageID is always string; channels convert platform-specific types internally.
|
|
|
|
|
type MessageEditor interface {
|
|
|
|
|
EditMessage(ctx context.Context, chatID string, messageID string, content string) error
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-26 19:02:40 +00:00
|
|
|
// ReactionCapable — channels that can add a reaction (e.g. 👀) to an inbound message.
|
|
|
|
|
// ReactToMessage adds a reaction and returns an undo function to remove it.
|
|
|
|
|
// The undo function MUST be idempotent and safe to call multiple times.
|
|
|
|
|
type ReactionCapable interface {
|
|
|
|
|
ReactToMessage(ctx context.Context, chatID, messageID string) (undo func(), err error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PlaceholderCapable — channels that can send a placeholder message
|
|
|
|
|
// (e.g. "Thinking... 💭") that will later be edited to the actual response.
|
|
|
|
|
// The channel MUST also implement MessageEditor for the placeholder to be useful.
|
|
|
|
|
// SendPlaceholder returns the platform message ID of the placeholder so that
|
|
|
|
|
// Manager.preSend can later edit it via MessageEditor.EditMessage.
|
|
|
|
|
type PlaceholderCapable interface {
|
|
|
|
|
SendPlaceholder(ctx context.Context, chatID string) (messageID string, err error)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 20:55:15 +00:00
|
|
|
// PlaceholderRecorder is injected into channels by Manager.
|
|
|
|
|
// Channels call these methods on inbound to register typing/placeholder state.
|
|
|
|
|
// Manager uses the registered state on outbound to stop typing and edit placeholders.
|
|
|
|
|
type PlaceholderRecorder interface {
|
|
|
|
|
RecordPlaceholder(channel, chatID, placeholderID string)
|
|
|
|
|
RecordTypingStop(channel, chatID string, stop func())
|
2026-02-26 19:02:40 +00:00
|
|
|
RecordReactionUndo(channel, chatID string, undo func())
|
2026-02-22 20:55:15 +00:00
|
|
|
}
|