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 ¶
- func ServeModule(m Module)
- type Context
- type Module
- type ModuleBase
- func (ModuleBase) Bootstrap() error
- func (ModuleBase) Command(_ *Context, _ any) (*MsgPayload, error)
- func (ModuleBase) Form(_ *Context, _ map[string]string) (*MsgPayload, error)
- func (ModuleBase) Help() (map[string][]string, error)
- func (ModuleBase) Init(_ json.RawMessage) error
- func (ModuleBase) IsReady() bool
- func (ModuleBase) Rules() (*Rules, error)
- type ModulePlugin
- type MsgPayload
- type Rules
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) 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 ¶
func (*ModulePlugin) GRPCClient(_ context.Context, _ *goPlugin.GRPCBroker, c *grpc.ClientConn) (any, error)
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.