Core

package module
v0.0.0-...-8e58936 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

README

GreekMilkBot

这只是一个非常早期的设计

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Modules

func Modules(prefix string) []string

func RegisterModule

func RegisterModule(instance Module)

Types

type Bot

type Bot struct {
	// contains filtered or unexported fields
}

func NewBot

func NewBot() *Bot

func (*Bot) Add

func (b *Bot) Add(name string, cfg map[string]any) error

func (*Bot) Start

func (b *Bot) Start(ctx context.Context) (func() error, error)

func (*Bot) Update

func (b *Bot) Update(name string, cfg map[string]any, index int) error

type BotModule

type BotModule struct {
	Mod    Module
	Config variables.Variables
	// contains filtered or unexported fields
}

func (*BotModule) Close

func (b *BotModule) Close() error

func (*BotModule) Ctx

func (b *BotModule) Ctx(ctx context.Context) Context

type CleanerUpper

type CleanerUpper interface {
	Cleanup() error
}

type Context

type Context struct {
	context.Context
	Logger
	Config variables.Variables
}

func NewContext

func NewContext(ctx context.Context) Context

func (Context) WithValue

func (ctx Context) WithValue(key, value any) Context

type DependsOn

type DependsOn interface {
	DependsOn() []string
}

DependsOn 依赖项,此配置决定了模块加载顺序,如果未指定则全部在最后加载

type Logger

type Logger interface {
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(format string, args ...any)
}

type LoggerFactory

type LoggerFactory interface {
	Logger(ctx context.Context) Logger
}

type Module

type Module interface {
	BotModule() ModuleInfo
}

type ModuleGroup

type ModuleGroup struct {
	ModuleInfo
	Mods []*BotModule
	// contains filtered or unexported fields
}

func (*ModuleGroup) Ctx

type ModuleInfo

type ModuleInfo struct {
	ID  string // 插件 ID
	New func() Module
}

func GetModule

func GetModule(name string) (ModuleInfo, error)

GetModule returns module information from its ID (full name).

type Provisioner

type Provisioner interface {
	Provision(ctx Context) error
}

type Validator

type Validator interface {
	Validate() error
}

Directories

Path Synopsis
cmd
bot command
modules
shared

Jump to

Keyboard shortcuts

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