GoroBot

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigPath = "conf/config.json"
)

Variables

View Source
var DefaultConfig []byte

Functions

This section is empty.

Types

type CommandEventCallback

type CommandEventCallback func(ctx *command.Context)

type Config

type Config struct {
	Owner        map[string]string `json:"owner"`
	LogLevel     logger.LogLevel   `json:"log_level"`
	ResourcePath string            `json:"resource_path"`
}

type EventHandler

type EventHandler struct {
	Name     string
	Callback event.Callback
}

func CommandEvent

func CommandEvent(callback CommandEventCallback) EventHandler

func MessageEvent

func MessageEvent(callback MessageEventCallback) EventHandler

type Instant

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

func Create

func Create() *Instant

func (*Instant) AddContext

func (i *Instant) AddContext(context botc.BotContext) bool

func (*Instant) CloseDatabase

func (i *Instant) CloseDatabase() error

func (*Instant) Command

func (i *Instant) Command(format string) *command.FormatBuilder

func (*Instant) CommandEmit

func (i *Instant) CommandEmit(cmd *command.Context)

func (*Instant) Database

func (i *Instant) Database() *sql.DB

func (*Instant) DatabaseExist

func (i *Instant) DatabaseExist() bool

func (*Instant) EventEmit

func (i *Instant) EventEmit(eventName string, args ...interface{}) error

func (*Instant) EventRegister

func (i *Instant) EventRegister(eventName string)

func (*Instant) EventUnregister

func (i *Instant) EventUnregister(eventName string)

func (*Instant) GetContext

func (i *Instant) GetContext(protocol string) botc.BotContext

func (*Instant) GetLogger

func (i *Instant) GetLogger() logger.Inst

func (*Instant) GetOwner

func (i *Instant) GetOwner(id string) (owner string, ok bool)

func (*Instant) GetResource

func (i *Instant) GetResource(resourceID string) (Resource, error)

GetResource 根据资源ID获取资源信息

func (*Instant) GetResourceData

func (i *Instant) GetResourceData(resourceID string) ([]byte, error)

func (*Instant) MessageEmit

func (i *Instant) MessageEmit(msg botc.MessageContext) error

func (*Instant) Middleware

func (i *Instant) Middleware(callback MiddlewareCallback, prepare ...bool) func()

func (*Instant) On

func (i *Instant) On(event EventHandler) (func(), error)

func (*Instant) OpenDatabase

func (i *Instant) OpenDatabase(driverName string, dataSourceName string) error

func (*Instant) Remove

func (i *Instant) Remove(service Service) error

func (*Instant) RemoveContext

func (i *Instant) RemoveContext(protocol string) bool

func (*Instant) ResourceExists

func (i *Instant) ResourceExists(resourceID string) bool

func (*Instant) Run

func (i *Instant) Run() error

func (*Instant) SaveRemoteResource

func (i *Instant) SaveRemoteResource(resourceURL string) (*Resource, error)

SaveRemoteResource 保存资源文件,并更新资源索引

func (*Instant) SaveResourceData

func (i *Instant) SaveResourceData(data []byte, ext string) (string, error)

func (*Instant) Use

func (i *Instant) Use(service Service)

func (*Instant) UseLogger

func (i *Instant) UseLogger(logger logger.Inst)

type MessageEventCallback

type MessageEventCallback func(ctx botc.MessageContext)

type Middleware

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

type MiddlewareCallback

type MiddlewareCallback func(msg botc.MessageContext, next func(...MiddlewareCallback) error) error

type MiddlewareSystem

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

type Resource

type Resource struct {
	ID         string    // 资源唯一标识符
	FilePath   string    // 资源文件保存路径
	Downloaded time.Time // 资源下载时间
}

type Service

type Service interface {
	Name() string
	Init(*Instant) error
	Release(*Instant) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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