control

package
v0.0.0-...-b518f07 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Overview

Package control 控制插件的启用与优先级等

Index

Constants

View Source
const (
	// StorageFolder 插件控制数据目录
	StorageFolder = "data/control/"
	// Md5File ...
	Md5File = StorageFolder + "stor.spb"
)

Variables

This section is empty.

Functions

func Delete

func Delete(service string)

Delete 删除插件控制器, 不会删除数据

func ForEachByPrio

func ForEachByPrio(iterator func(i int, manager *ctrl.Control[*zero.Ctx]) bool)

ForEachByPrio iterates through managers by their priority.

func Lookup

func Lookup(service string) (*ctrl.Control[*zero.Ctx], bool)

Lookup 查找服务

Types

type Engine

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

Engine is the pre_handler, post_handler manager

func Register

func Register(service string, o *ctrl.Options[*zero.Ctx]) *Engine

Register 注册插件控制器

func (*Engine) ApplySingle

func (e *Engine) ApplySingle(s *single.Single[int64]) *Engine

ApplySingle 应用反并发

func (*Engine) DataFolder

func (e *Engine) DataFolder() string

DataFolder 本插件数据目录, 默认 data/zbp/

func (*Engine) Delete

func (e *Engine) Delete()

Delete 移除该 Engine 注册的所有 Matchers

func (*Engine) GetCustomLazyData

func (e *Engine) GetCustomLazyData(dataurl, filename string) ([]byte, error)

GetCustomLazyData 下载并获取本 engine 文件夹下的自动定义懒加载数据

func (*Engine) GetLazyData

func (e *Engine) GetLazyData(filename string, isDataMustEqual bool) ([]byte, error)

GetLazyData 下载并获取本 engine 文件夹下的懒加载数据

func (*Engine) InitWhenNoError

func (e *Engine) InitWhenNoError(errfun func() error, do func())

InitWhenNoError 在 errfun 无误时执行 do

func (*Engine) IsEnabledIn

func (e *Engine) IsEnabledIn(id int64) bool

IsEnabledIn 自己是否在 id (正群负个人零全局) 启用

func (*Engine) On

func (e *Engine) On(typ string, rules ...zero.Rule) *Matcher

On 添加新的指定消息类型的匹配器

func (*Engine) OnCommand

func (e *Engine) OnCommand(commands string, rules ...zero.Rule) *Matcher

OnCommand 命令触发器

func (*Engine) OnCommandGroup

func (e *Engine) OnCommandGroup(commands []string, rules ...zero.Rule) *Matcher

OnCommandGroup 命令触发器组

func (*Engine) OnFullMatch

func (e *Engine) OnFullMatch(src string, rules ...zero.Rule) *Matcher

OnFullMatch 完全匹配触发器

func (*Engine) OnFullMatchGroup

func (e *Engine) OnFullMatchGroup(src []string, rules ...zero.Rule) *Matcher

OnFullMatchGroup 完全匹配触发器组

func (*Engine) OnKeyword

func (e *Engine) OnKeyword(keyword string, rules ...zero.Rule) *Matcher

OnKeyword 关键词触发器

func (*Engine) OnKeywordGroup

func (e *Engine) OnKeywordGroup(keywords []string, rules ...zero.Rule) *Matcher

OnKeywordGroup 关键词触发器组

func (*Engine) OnMessage

func (e *Engine) OnMessage(rules ...zero.Rule) *Matcher

OnMessage 消息触发器

func (*Engine) OnMetaEvent

func (e *Engine) OnMetaEvent(rules ...zero.Rule) *Matcher

OnMetaEvent 元事件触发器

func (*Engine) OnNotice

func (e *Engine) OnNotice(rules ...zero.Rule) *Matcher

OnNotice 系统提示触发器

func (*Engine) OnPrefix

func (e *Engine) OnPrefix(prefix string, rules ...zero.Rule) *Matcher

OnPrefix 前缀触发器

func (*Engine) OnPrefixGroup

func (e *Engine) OnPrefixGroup(prefix []string, rules ...zero.Rule) *Matcher

OnPrefixGroup 前缀触发器组

func (*Engine) OnRegex

func (e *Engine) OnRegex(regexPattern string, rules ...zero.Rule) *Matcher

OnRegex 正则触发器

func (*Engine) OnRequest

func (e *Engine) OnRequest(rules ...zero.Rule) *Matcher

OnRequest 请求消息触发器

func (*Engine) OnShell

func (e *Engine) OnShell(command string, model any, rules ...zero.Rule) *Matcher

OnShell shell命令触发器

func (*Engine) OnSuffix

func (e *Engine) OnSuffix(suffix string, rules ...zero.Rule) *Matcher

OnSuffix 后缀触发器

func (*Engine) OnSuffixGroup

func (e *Engine) OnSuffixGroup(suffix []string, rules ...zero.Rule) *Matcher

OnSuffixGroup 后缀触发器组

func (*Engine) UseMidHandler

func (e *Engine) UseMidHandler(rules ...zero.Rule)

UseMidHandler 向该 Engine 添加新 MidHandler(Rule), 会在 Rule 判断后, Matcher 触发前触发,如果 midHandler 没有通过,则 Matcher 不会触发 可用于速率限制等

func (*Engine) UsePostHandler

func (e *Engine) UsePostHandler(handler ...zero.Handler)

UsePostHandler 向该 Engine 添加新 PostHandler(Rule), 会在 Matcher 触发后触发,如果 PostHandler 返回 false, 则后续的 post handler 不会触发 可用于反并发等

func (*Engine) UsePreHandler

func (e *Engine) UsePreHandler(rules ...zero.Rule)

UsePreHandler 向该 Engine 添加新 PreHandler(Rule), 会在 Rule 判断前触发,如果 preHandler 没有通过,则 Rule, Matcher 不会触发 可用于分群组管理插件等

type Matcher

type Matcher zero.Matcher

Matcher 是 ZeroBot 匹配和处理事件的最小单元

func (*Matcher) Handle

func (m *Matcher) Handle(handler zero.Handler)

Handle 直接处理事件

func (*Matcher) Limit

func (m *Matcher) Limit(limiterfn func(*zero.Ctx) *rate.Limiter, postfn ...func(*zero.Ctx)) *Matcher

Limit 限速器

postfn 当请求被拒绝时的操作

func (*Matcher) SetBlock

func (m *Matcher) SetBlock(block bool) *Matcher

SetBlock 设置是否阻断后面的 Matcher 触发

Jump to

Keyboard shortcuts

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