Skip to content

Optional interfaces

Beyond Module, Goroku checks for these at registration. Implement the method and the capability turns on; skip it and nothing happens.

Assert them at compile time

An optional interface is matched by shape. A typo in the signature means your method is silently ignored. One line prevents that:

go
var _ goroku.ModuleWithConfigSchema = (*Weather)(nil)

ModuleWithMeta

go
CommandMetas() map[string]CommandMeta

Aliases and filters per command. See CommandMeta.

ModuleWithWatcherMetas

go
WatcherMetas() []CommandMeta

Filters for watchers, matched positionally to Watchers().

ModuleWithConfigSchema

go
ConfigSchema() []ConfigField

Typed settings with defaults and validation. The preferred config surface. See ConfigField.

ModuleWithConfigReady

go
ConfigReady(config map[string]any) error

Called at startup and whenever a setting changes. Returning an error rejects the change.

ModuleWithConfig

go
ConfigDefaults() map[string]any

Older, untyped config surface. Prefer ConfigSchema.

ModuleWithConfigValidators

go
ConfigValidators() map[string]Validator

Validators for ConfigDefaults. Unnecessary with ConfigSchema, which carries its own.

ModuleWithTranslationAliases

go
TranslationAliases() []string

Extra names to try when resolving translation keys, for modules whose translation files use a name that does not derive from Name().

go
func (m *APIProtection) Name() string { return "APILimiter" }
func (m *APIProtection) TranslationAliases() []string {
	return []string{"api_protection"}
}

ModuleWithAllModules

go
SetAllModules(*Modules)

Receives the module registry, for modules that inspect or drive other modules — help, config UI, loaders.

ModuleWithTranslator

go
SetTranslator(*Translator)

Receives a translator. Unnecessary when embedding Base, which already has one.

SecuredModule

go
CommandPermissions() map[string]int

Default permission masks per command. See Permissions.

RatelimitedModule

go
RatelimitedCommands() map[string]bool

Commands subject to rate limiting. Equivalent to Ratelimit: true in CommandMeta.

Released under the GNU AGPL v3 License.