Documentation
¶
Index ¶
- func GetPluginRegistry() pluginRegistry
- func GetRegisteredRoomTags() map[string][]string
- func Load(dataFilesPath string)
- func OnNetConnect(n NetConnection)
- func ReadFile(dfPath string) ([]byte, error)
- func Save()
- func SetAdminRegistrar(r ModuleAdminRegistrar)
- type AdminAPIRoute
- type AdminWebPage
- type ModuleAPIHandler
- type ModuleAdminRegistrar
- type ModulePermission
- type NetConnection
- type Plugin
- func (p *Plugin) AddMobCommand(command string, handlerFunc mobcommands.MobCommand, allowWhenDowned bool)
- func (p *Plugin) AddScriptingFunction(funcName string, scriptFunc any)
- func (p *Plugin) AddUserCommand(command string, handlerFunc usercommands.UserCommand, allowWhenDowned bool, ...)
- func (p *Plugin) AttachFileSystem(f embed.FS) error
- func (p *Plugin) ExportFunction(stringId string, f any)
- func (p *Plugin) ReadBytes(identifier string) ([]byte, error)
- func (p *Plugin) ReadIntoStruct(identifier string, out any) error
- func (p *Plugin) Requires(modname string, modversion string)
- func (p *Plugin) ReserveTags(tags ...string)
- func (p *Plugin) WriteBytes(identifier string, bytes []byte) error
- func (p *Plugin) WriteStruct(identifier string, in any) error
- type PluginCallbacks
- func (c *PluginCallbacks) SetIACHandler(f func(uint64, []byte) bool)
- func (c *PluginCallbacks) SetOnLoad(f func())
- func (c *PluginCallbacks) SetOnNetConnect(f func(NetConnection))
- func (c *PluginCallbacks) SetOnSave(f func())
- func (c *PluginCallbacks) SetTextPrefixHandler(f func(uint64, []byte) bool)
- type PluginConfig
- type PluginFiles
- type WebConfig
- func (w *WebConfig) AdminAPIEndpoint(method, slug string, handler ModuleAPIHandler, permissionKey ...string)
- func (w *WebConfig) AdminPage(name, slug, htmlFile string, addToNav bool, ...)
- func (w *WebConfig) NavLink(name string, path string)
- func (w *WebConfig) RegisterPermissions(perms ...ModulePermission)
- func (w *WebConfig) WebPage(name string, path string, file string, addToNav bool, ...)
- type WebPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPluginRegistry ¶
func GetPluginRegistry() pluginRegistry
func GetRegisteredRoomTags ¶ added in v0.9.8
GetRegisteredRoomTags returns a map of plugin name to the room tags it has reserved, containing only plugins that reserved at least one tag.
func OnNetConnect ¶
func OnNetConnect(n NetConnection)
func SetAdminRegistrar ¶ added in v0.9.8
func SetAdminRegistrar(r ModuleAdminRegistrar)
SetAdminRegistrar provides the callback that plugins.Load() uses to register module admin pages and API endpoints without importing web directly.
Types ¶
type AdminAPIRoute ¶ added in v0.9.8
type AdminAPIRoute struct {
Method string
Slug string
Path string // "/admin/api/v1/<slug>"
Handler ModuleAPIHandler
PermissionKey string // if non-empty, required permission key for this endpoint
}
AdminAPIRoute describes an admin API endpoint contributed by a module.
type AdminWebPage ¶ added in v0.9.8
type AdminWebPage struct {
Name string
Slug string // e.g. "mudmail" -> /admin/mudmail
Path string // "/admin/mudmail"
HTMLFile string // path inside plugin FS, relative to datafiles/html/admin/
Description string // short one-sentence description for this leaf entry
DataFunction func(*http.Request) map[string]any
}
AdminWebPage describes an admin page contributed by a module.
type ModuleAPIHandler ¶ added in v0.9.8
ModuleAPIHandler is the signature for module-provided admin API handlers. The handler receives the raw *http.Request and returns:
status - HTTP status code (e.g. 200, 400, 500) success - written into APIResponse.Success data - written into APIResponse.Data (must be JSON-serialisable)
type ModuleAdminRegistrar ¶ added in v0.9.8
type ModuleAdminRegistrar interface {
RegisterAdminPage(name, slug, htmlContent string, addToNav bool, navGroup, navParent, description, navParentDescription string, dataFunc func(*http.Request) map[string]any)
RegisterAdminAPIEndpoint(method, slug, permissionKey string, handler func(*http.Request) (int, bool, any))
// RegisterPermission adds a single module-contributed permission key to the
// catalog so it appears in the admin permission picker.
RegisterPermission(key, description, category string)
}
ModuleAdminRegistrar is implemented by internal/web and provided to plugins via SetAdminRegistrar. This breaks the import cycle between web and plugins.
type ModulePermission ¶ added in v0.9.8
ModulePermission describes a permission key contributed by a module.
type NetConnection ¶
type Plugin ¶
type Plugin struct {
Callbacks PluginCallbacks
Config PluginConfig
Web WebConfig
// contains filtered or unexported fields
}
func (*Plugin) AddMobCommand ¶
func (p *Plugin) AddMobCommand(command string, handlerFunc mobcommands.MobCommand, allowWhenDowned bool)
Registers a MobCommand and callback
func (*Plugin) AddScriptingFunction ¶
Registers a UserCommand and callback
func (*Plugin) AddUserCommand ¶
func (p *Plugin) AddUserCommand(command string, handlerFunc usercommands.UserCommand, allowWhenDowned bool, isAdminOnly bool)
Registers a UserCommand and callback
func (*Plugin) AttachFileSystem ¶
Adds an embedded file system to the plugin
func (*Plugin) ExportFunction ¶
func (*Plugin) ReserveTags ¶ added in v0.9.8
ReserveTags registers room tags that this plugin recognises, so that "room tags" can list them alongside the owning module name.
type PluginCallbacks ¶
type PluginCallbacks struct {
// contains filtered or unexported fields
}
func (*PluginCallbacks) SetIACHandler ¶
func (c *PluginCallbacks) SetIACHandler(f func(uint64, []byte) bool)
func (*PluginCallbacks) SetOnLoad ¶
func (c *PluginCallbacks) SetOnLoad(f func())
func (*PluginCallbacks) SetOnNetConnect ¶
func (c *PluginCallbacks) SetOnNetConnect(f func(NetConnection))
func (*PluginCallbacks) SetOnSave ¶
func (c *PluginCallbacks) SetOnSave(f func())
func (*PluginCallbacks) SetTextPrefixHandler ¶ added in v0.9.8
func (c *PluginCallbacks) SetTextPrefixHandler(f func(uint64, []byte) bool)
type PluginConfig ¶
type PluginConfig struct {
// contains filtered or unexported fields
}
func (*PluginConfig) Get ¶
func (p *PluginConfig) Get(name string) any
func (*PluginConfig) Set ¶
func (p *PluginConfig) Set(name string, val any)
type PluginFiles ¶
type PluginFiles struct {
// contains filtered or unexported fields
}
Implements fs.ReadFileFS
func (PluginFiles) KnownPaths ¶ added in v0.9.8
func (p PluginFiles) KnownPaths() []string
KnownPaths returns all file paths registered in this plugin's file system.
type WebConfig ¶
type WebConfig struct {
// contains filtered or unexported fields
}
func (*WebConfig) AdminAPIEndpoint ¶ added in v0.9.8
func (w *WebConfig) AdminAPIEndpoint(method, slug string, handler ModuleAPIHandler, permissionKey ...string)
AdminAPIEndpoint registers an HTTP handler under /admin/api/v1/<slug>.
- method - HTTP method string: "GET", "POST", "PATCH", "DELETE", etc.
- slug - path suffix, e.g. "mudmail" -> /admin/api/v1/mudmail
- handler - the handler function
- permissionKey - if non-empty, the permission key required to call this endpoint. Conventionally "<module>.write" for mutating methods. Leave empty for GET (read) endpoints.
func (*WebConfig) AdminPage ¶ added in v0.9.8
func (w *WebConfig) AdminPage(name, slug, htmlFile string, addToNav bool, navGroup, navParent, description, navParentDescription string, dataFunc func(*http.Request) map[string]any)
AdminPage registers an admin-only page served under /admin/<slug>.
- name - display label used in nav
- slug - URL path segment, e.g. "mudmail" -> /admin/mudmail
- htmlFile - path inside the plugin's embedded FS, relative to datafiles/html/admin/
- addToNav - whether to add a nav entry
- navGroup - if non-empty, places the nav entry inside a top-level group dropdown
- navParent - if non-empty, nests the entry under this parent within the group (or top-level)
- description - short one-sentence description for this leaf entry
- navParentDescription - short one-sentence description for the parent nav group entry (used on first registration)
- dataFunc - optional function to supply extra template data; receives *http.Request
func (*WebConfig) RegisterPermissions ¶ added in v0.9.8
func (w *WebConfig) RegisterPermissions(perms ...ModulePermission)
RegisterPermissions declares permission keys that this module contributes. Call this during module initialisation for any write permission keys used in AdminAPIEndpoint calls so they appear in the admin permission picker.