control

package
v1.9.9 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: GPL-3.0 Imports: 36 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 CanResponse

func CanResponse(gid int64) bool

CanResponse 响应状态

func Delete

func Delete(service string)

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

func ExtraFromString

func ExtraFromString(s string) int16

ExtraFromString generate int16 extra key from string's md5

func ForEachByPrio

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

ForEachByPrio iterates through managers by their priority.

func LoadCustomPriority

func LoadCustomPriority(m map[string]uint64)

LoadCustomPriority 加载自定义优先级 map,适配 1.21 及以上版本

func Lookup

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

Lookup 查找服务

func Response

func Response(gid int64) error

Response 响应

func Silence

func Silence(gid int64) error

Silence 沉默

Types

type Engine

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

Engine is the pre_handler, post_handler manager

func AutoRegister

func AutoRegister(o *ctrl.Options[*zero.Ctx]) *Engine

AutoRegister 根据包名自动注册插件

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 触发

Directories

Path Synopsis
web
Package webctrl 包含 webui 所需的所有内容
Package webctrl 包含 webui 所需的所有内容
controller
Package controller 主要处理逻辑
Package controller 主要处理逻辑
docs
Code generated by swaggo/swag.
Code generated by swaggo/swag.
middleware
Package middleware 中间件
Package middleware 中间件
model
Package model 用户模型类
Package model 用户模型类
router
Package router 路由
Package router 路由
types
Package types 结构体
Package types 结构体

Jump to

Keyboard shortcuts

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