module

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: 22 Imported by: 0

Documentation

Overview

Package module provides the module handler interface and base types.

Index

Constants

View Source
const (
	MessageBotIncomingBehavior   = "message_bot_incoming"
	MessageGroupIncomingBehavior = "message_group_incoming"
)

Variables

This section is empty.

Functions

func Behavior

func Behavior(uid types.Uid, flag string, number int)

func Bootstrap

func Bootstrap() error

func FormMsg

func FormMsg(ctx types.Context, id string) types.MsgPayload

func Help

func Help(rules []any) (map[string][]string, error)

func Init

func Init(jsonconf json.RawMessage) error

func List

func List() map[string]Handler

func Register

func Register(name string, module Handler)

func RunCommand

func RunCommand(commandRules []command.Rule, ctx types.Context, content any) (types.MsgPayload, error)

func RunForm

func RunForm(formRules []form.Rule, ctx types.Context, values types.KV) (types.MsgPayload, error)

func ServiceURL

func ServiceURL(ctx types.Context, group, path string, param types.KV) string

func SettingGet

func SettingGet(ctx types.Context, id string, key string) (types.KV, error)

func SettingMsg

func SettingMsg(ctx types.Context, id string) types.MsgPayload

func Shortcut

func Shortcut(title, link string) (string, error)

func StoreForm

func StoreForm(ctx types.Context, payload types.MsgPayload) types.MsgPayload

func StoreParameter

func StoreParameter(params types.KV, expiredAt time.Time) (string, error)

func Unregister

func Unregister(name string)

Unregister removes a previously registered module handler. It is a no-op if the name is not found. Intended primarily for test teardown.

func Webservice

func Webservice(app *fiber.App, name string, ruleset webservice.Ruleset)

Types

type Base

type Base struct{}

func (Base) Bootstrap

func (Base) Bootstrap() error

func (Base) Command

func (Base) Command(_ types.Context, _ any) (types.MsgPayload, error)

func (Base) Form

func (Base) Form(_ types.Context, _ types.KV) (types.MsgPayload, error)

func (Base) Help

func (b Base) Help() (map[string][]string, error)

func (Base) Input

func (Base) Input(_ types.Context, _ types.KV, _ any) (types.MsgPayload, error)

func (Base) Rules

func (Base) Rules() []any

func (Base) Webservice

func (Base) Webservice(_ *fiber.App)

type Handler

type Handler interface {
	// Init initializes the module.
	Init(jsonconf json.RawMessage) error

	// IsReady checks if the module is initialized.
	IsReady() bool

	// Bootstrap Lifecycle hook
	Bootstrap() error

	// Help return module help
	Help() (map[string][]string, error)

	// Rules return module ruleset
	Rules() []any

	// Input return input result
	Input(ctx types.Context, head types.KV, content any) (types.MsgPayload, error)

	// Command return module result
	Command(ctx types.Context, content any) (types.MsgPayload, error)

	// Form return module form result
	Form(ctx types.Context, values types.KV) (types.MsgPayload, error)

	// Webservice return webservice routes
	Webservice(app *fiber.App)
}

func FindRuleAndHandler

func FindRuleAndHandler[T types.Ruler](flag string, handlers map[string]Handler) (T, Handler)

Jump to

Keyboard shortcuts

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