sdk

package
v0.92.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sdk provides the plugin SDK for building flowbot module plugins. It defines the Module interface, no-op ModuleBase, and go-plugin serve helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeModule

func ServeModule(m Module)

ServeModule starts a go-plugin server for a module plugin. Called from the plugin binary's main().

Types

type Context

type Context struct {
	AuthContext string            `json:"auth_context"`
	UserID      string            `json:"user_id"`
	ChannelID   string            `json:"channel_id"`
	Platform    string            `json:"platform"`
	Metadata    map[string]string `json:"metadata"`
}

Context wraps flowbot's types.Context with SDK-friendly types.

type Module

type Module interface {
	Init(config json.RawMessage) error
	Bootstrap() error
	Command(ctx *Context, content any) (*MsgPayload, error)
	Form(ctx *Context, values map[string]string) (*MsgPayload, error)
	Rules() (*Rules, error)
	Help() (map[string][]string, error)
	IsReady() bool
}

Module is the interface for module plugins.

type ModuleBase

type ModuleBase struct{}

ModuleBase provides no-op default implementations for Module.

func (ModuleBase) Bootstrap

func (ModuleBase) Bootstrap() error

func (ModuleBase) Command

func (ModuleBase) Command(_ *Context, _ any) (*MsgPayload, error)

func (ModuleBase) Form

func (ModuleBase) Form(_ *Context, _ map[string]string) (*MsgPayload, error)

func (ModuleBase) Help

func (ModuleBase) Help() (map[string][]string, error)

func (ModuleBase) Init

func (ModuleBase) Init(_ json.RawMessage) error

func (ModuleBase) IsReady

func (ModuleBase) IsReady() bool

func (ModuleBase) Rules

func (ModuleBase) Rules() (*Rules, error)

type ModulePlugin

type ModulePlugin struct {
	goPlugin.NetRPCUnsupportedPlugin
	// contains filtered or unexported fields
}

ModulePlugin implements the go-plugin interface for module plugins.

func (*ModulePlugin) GRPCClient

GRPCClient creates a PluginServiceClient.

func (*ModulePlugin) GRPCServer

func (*ModulePlugin) GRPCServer(_ *goPlugin.GRPCBroker, _ *grpc.Server) error

GRPCServer registers the module as a PluginServiceServer.

type MsgPayload

type MsgPayload struct {
	Text string `json:"text"`
}

MsgPayload is the message payload returned by plugin handlers.

type Rules

type Rules struct {
	Commands    []any `json:"commands"`
	Forms       []any `json:"forms"`
	Webservices []any `json:"webservices"`
	Webhooks    []any `json:"webhooks"`
}

Rules holds plugin-declared rulesets.

Jump to

Keyboard shortcuts

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