platform

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package platform defines adapter contracts and platform-neutral outbound messages.

Index

Constants

This section is empty.

Variables

View Source
var ErrEditUnavailable = errors.New("message editing is unavailable")

ErrEditUnavailable reports that the current message cannot be edited. Operational adapter errors must be returned unchanged.

View Source
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 Community

type Community struct {
	ID       string
	Platform string
	Title    string
	Kind     string
	Raw      any
}

Community is a platform-neutral group, guild or community.

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

type Dispatcher interface {
	Dispatch(ctx context.Context, ev event.Event) error
}

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
	Footer       *EmbedFooter
	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 EmbedAuthor struct {
	Name    string
	URL     string
	IconURL string
}

type EmbedField added in v2.0.1

type EmbedField struct {
	Name   string
	Value  string
	Inline bool
}

type EmbedFooter added in v2.0.1

type EmbedFooter struct {
	Text    string
	IconURL string
}

type EventSubscriber

type EventSubscriber interface {
	SetEventTypes(types []event.Type)
}

EventSubscriber is optionally implemented by adapters that can limit their upstream subscriptions to the event types used by the application.

type LoggerAware

type LoggerAware interface {
	SetLogger(logger *slog.Logger)
}

LoggerAware is implemented by adapters that accept the application logger.

type Member

type Member struct {
	ID       string
	Username string
	Roles    []string
	Raw      any
}

Member is a normalized community member.

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 Migratable interface {
	Migrations() []plugin.Migration
}

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.

type Target

type Target struct {
	ChatID string
	UserID string
}

Target identifies the destination of an outgoing message.

Jump to

Keyboard shortcuts

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