Documentation
¶
Index ¶
- func ValidateManifest(manifest *PluginManifest) error
- type BasePlugin
- func (p *BasePlugin) Commands() []PluginCommand
- func (p *BasePlugin) GetConfig() Config
- func (p *BasePlugin) GetHost() PluginHost
- func (p *BasePlugin) Init(config Config) error
- func (p *BasePlugin) Name() string
- func (p *BasePlugin) OnMessage(msg Message) ([]Message, error)
- func (p *BasePlugin) SetHost(host PluginHost)
- type Config
- type Message
- type Plugin
- type PluginCommand
- type PluginHost
- type PluginManifest
- type PluginRequest
- type PluginResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateManifest ¶
func ValidateManifest(manifest *PluginManifest) error
ValidateManifest validates a plugin manifest
Types ¶
type BasePlugin ¶
type BasePlugin struct {
// contains filtered or unexported fields
}
BasePlugin provides a basic implementation of the Plugin interface
func NewBasePlugin ¶
func NewBasePlugin(name string) *BasePlugin
NewBasePlugin creates a new base plugin
func (*BasePlugin) Commands ¶
func (p *BasePlugin) Commands() []PluginCommand
Commands provides a default implementation that returns no commands
func (*BasePlugin) GetConfig ¶
func (p *BasePlugin) GetConfig() Config
GetConfig returns the plugin configuration
func (*BasePlugin) GetHost ¶
func (p *BasePlugin) GetHost() PluginHost
GetHost returns the plugin host
func (*BasePlugin) Init ¶
func (p *BasePlugin) Init(config Config) error
Init initializes the base plugin
func (*BasePlugin) OnMessage ¶
func (p *BasePlugin) OnMessage(msg Message) ([]Message, error)
OnMessage provides a default implementation that does nothing
func (*BasePlugin) SetHost ¶
func (p *BasePlugin) SetHost(host PluginHost)
SetHost sets the plugin host
type Config ¶
type Config struct {
PluginDir string `json:"plugin_dir"`
DataDir string `json:"data_dir"`
Settings map[string]string `json:"settings"`
}
Config represents plugin configuration
type Message ¶
type Message struct {
Sender string `json:"sender"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
Type string `json:"type,omitempty"`
}
Message represents a chat message
type Plugin ¶
type Plugin interface {
// Name returns the plugin's unique identifier
Name() string
// Init initializes the plugin with configuration
Init(config Config) error
// OnMessage is called when a new message is received
// Plugins can return additional messages to be sent
OnMessage(msg Message) ([]Message, error)
// Commands returns the list of commands this plugin registers
Commands() []PluginCommand
}
Plugin is the main interface that all marchat plugins must implement
type PluginCommand ¶
type PluginCommand struct {
Name string `json:"name"`
Description string `json:"description"`
Usage string `json:"usage"`
AdminOnly bool `json:"admin_only"`
}
PluginCommand represents a command that a plugin can register
type PluginHost ¶
type PluginHost interface {
// SendMessage sends a message to the chat
SendMessage(msg Message) error
// GetUsers returns the list of online users
GetUsers() []string
// GetSetting retrieves a plugin setting
GetSetting(key string) string
// SetSetting stores a plugin setting
SetSetting(key, value string) error
// Log logs a message to the host's log system
Log(level, message string)
}
PluginHost provides methods for plugins to interact with the host
type PluginManifest ¶
type PluginManifest struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Author string `json:"author"`
License string `json:"license"`
Repository string `json:"repository,omitempty"`
Homepage string `json:"homepage,omitempty"`
Commands []PluginCommand `json:"commands"`
Permissions []string `json:"permissions"`
Settings map[string]string `json:"settings,omitempty"`
MinVersion string `json:"min_version,omitempty"`
MaxVersion string `json:"max_version,omitempty"`
}
PluginManifest contains metadata about a plugin
type PluginRequest ¶
type PluginRequest struct {
Type string `json:"type"`
Command string `json:"command,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
}
PluginRequest represents a request to a plugin
type PluginResponse ¶
type PluginResponse struct {
Type string `json:"type"`
Success bool `json:"success"`
Data json.RawMessage `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
PluginResponse represents a response from a plugin