Documentation
¶
Overview ¶
Package platform defines adapter contracts and platform-neutral outbound messages.
Index ¶
- Variables
- type CommandPrefixAware
- type Community
- type CommunityManagement
- type ConfigValidator
- type Dispatcher
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EventSubscriber
- type LoggerAware
- type Member
- type MessageEditor
- type MessageEditorByRef
- type MessageRef
- type MessageSenderWithRef
- type Migratable
- type OutgoingMessage
- type Platform
- type PrivateMessenger
- type Target
Constants ¶
This section is empty.
Variables ¶
ErrEditUnavailable reports that the current message cannot be edited. Operational adapter errors must be returned unchanged.
var ErrPrivateMessagingUnsupported = errors.New("private messaging is not supported")
Functions ¶
This section is empty.
Types ¶
type CommandPrefixAware ¶
type CommandPrefixAware interface {
SetCommandPrefixes(prefixes []string)
}
CommandPrefixAware is optionally implemented by adapters that parse text commands.
type CommunityManagement ¶
type CommunityManagement interface {
GetCommunity(ctx context.Context, id string) (Community, error)
GetMembers(ctx context.Context, communityID string) ([]Member, error)
}
CommunityManagement exposes optional community lookup operations.
type ConfigValidator ¶ added in v2.0.2
type ConfigValidator interface {
Validate() error
}
ConfigValidator validates an adapter before the app enters the running state.
type Dispatcher ¶
Dispatcher accepts normalized events from adapters.
type Embed ¶ added in v2.0.1
type Embed struct {
Title string
Description string
URL string
Color int
Fields []EmbedField
ImageURL string
ThumbnailURL string
Author *EmbedAuthor
}
Embed is portable rich message content. Platform-specific fields belong in Raw.
type EmbedAuthor ¶ added in v2.0.1
type EmbedField ¶ added in v2.0.1
type EmbedFooter ¶ added in v2.0.1
type EmbedFooter struct {
}
type EventSubscriber ¶
EventSubscriber is optionally implemented by adapters that can limit their upstream subscriptions to the event types used by the application.
type LoggerAware ¶
LoggerAware is implemented by adapters that accept the application logger.
type MessageEditor ¶
type MessageEditor interface {
Edit(ctx context.Context, ev event.Event, msg OutgoingMessage) error
}
MessageEditor is an optional platform capability for editing the message related to an incoming event (typically callback events).
type MessageEditorByRef ¶
type MessageEditorByRef interface {
EditByRef(ctx context.Context, ref MessageRef, msg OutgoingMessage) error
}
MessageEditorByRef is an optional platform capability for editing messages via explicit message references.
type MessageRef ¶
type MessageRef = event.MessageRef
MessageRef is a platform-agnostic reference to an existing message. Platforms may use different fields depending on capabilities.
type MessageSenderWithRef ¶
type MessageSenderWithRef interface {
SendWithRef(ctx context.Context, target Target, msg OutgoingMessage) (MessageRef, error)
}
MessageSenderWithRef is an optional platform capability for sending messages and returning a reference that can be used for later edits.
type Migratable ¶
type OutgoingMessage ¶
type OutgoingMessage struct {
Text string
Keyboard *keyboard.Keyboard
Attachments []attachments.Attachment
Embeds []Embed
ReplyTo *MessageRef
Raw any
}
OutgoingMessage contains portable message content and optional native data.
type Platform ¶
type Platform interface {
Name() string
Capabilities() capability.Capabilities
Start(ctx context.Context, dispatcher Dispatcher) error
Send(ctx context.Context, target Target, msg OutgoingMessage) error
AnswerCallback(ctx context.Context, callbackID string, text string) error
Raw() any
}
Platform is implemented by every concrete messaging adapter.
type PrivateMessenger ¶ added in v2.0.1
type PrivateMessenger interface {
SendPrivate(ctx context.Context, userID string, msg OutgoingMessage) error
}
PrivateMessenger is optionally implemented by adapters that can deliver a message to a user without exposing it in the current chat.