control

package
v1.2.5-beta1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: GPL-3.0 Imports: 19 Imported by: 363

README

zbpctrl

ZeroBot-Plugin 的控制库

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(service string)

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

func ForEach

func ForEach(iterator func(key string, manager *Control) bool)

ForEach iterates through managers.

Types

type Control

type Control struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Control is to control the plugins.

func Lookup

func Lookup(service string) (*Control, bool)

Lookup returns a Manager by the service name, if not exist, it will return nil.

func (*Control) Ban

func (m *Control) Ban(uid, gid int64)

Ban 禁止某人在某群使用本插件

func (*Control) Disable

func (m *Control) Disable(groupID int64)

Disable disables a group to pass the Manager. groupID == 0 (ALL) will operate on all grps.

func (*Control) Enable

func (m *Control) Enable(groupID int64)

Enable enables a group to pass the Manager. groupID == 0 (ALL) will operate on all grps.

func (*Control) GetData

func (m *Control) GetData(gid int64) int64

GetData 获取某个群的 63 字节配置信息

func (*Control) Handler

func (m *Control) Handler(ctx *zero.Ctx) bool

Handler 返回 预处理器

func (*Control) IsBannedIn

func (m *Control) IsBannedIn(uid, gid int64) bool

IsBannedIn 某人是否在某群被 ban

func (*Control) IsEnabledIn

func (m *Control) IsEnabledIn(gid int64) bool

IsEnabledIn 开启群

func (*Control) Permit

func (m *Control) Permit(uid, gid int64)

Permit 允许某人在某群使用本插件

func (*Control) Reset

func (m *Control) Reset(groupID int64)

Reset resets the default config of a group. groupID == 0 (ALL) is not allowed.

func (*Control) SetData

func (m *Control) SetData(groupID int64, data int64) error

SetData 为某个群设置低 63 位配置数据

type Engine

type Engine interface {
	// Delete 移除该 Engine 注册的所有 Matchers
	Delete()
	// On 添加新的指定消息类型的匹配器
	On(typ string, rules ...zero.Rule) Matcher
	// OnMessage 消息触发器
	OnMessage(rules ...zero.Rule) Matcher
	// OnNotice 系统提示触发器
	OnNotice(rules ...zero.Rule) Matcher
	// OnRequest 请求消息触发器
	OnRequest(rules ...zero.Rule) Matcher
	// OnMetaEvent 元事件触发器
	OnMetaEvent(rules ...zero.Rule) Matcher
	// OnPrefix 前缀触发器
	OnPrefix(prefix string, rules ...zero.Rule) Matcher
	// OnSuffix 后缀触发器
	OnSuffix(suffix string, rules ...zero.Rule) Matcher
	// OnCommand 命令触发器
	OnCommand(commands string, rules ...zero.Rule) Matcher
	// OnRegex 正则触发器
	OnRegex(regexPattern string, rules ...zero.Rule) Matcher
	// OnKeyword 关键词触发器
	OnKeyword(keyword string, rules ...zero.Rule) Matcher
	// OnFullMatch 完全匹配触发器
	OnFullMatch(src string, rules ...zero.Rule) Matcher
	// OnFullMatchGroup 完全匹配触发器组
	OnFullMatchGroup(src []string, rules ...zero.Rule) Matcher
	// OnKeywordGroup 关键词触发器组
	OnKeywordGroup(keywords []string, rules ...zero.Rule) Matcher
	// OnCommandGroup 命令触发器组
	OnCommandGroup(commands []string, rules ...zero.Rule) Matcher
	// OnPrefixGroup 前缀触发器组
	OnPrefixGroup(prefix []string, rules ...zero.Rule) Matcher
	// OnSuffixGroup 后缀触发器组
	OnSuffixGroup(suffix []string, rules ...zero.Rule) Matcher
	// OnShell shell命令触发器
	OnShell(command string, model interface{}, rules ...zero.Rule) Matcher
}

func Register

func Register(service string, prio int, o *Options) Engine

Register 注册插件控制器

type Matcher

type Matcher interface {
	// SetBlock 设置是否阻断后面的 Matcher 触发
	SetBlock(block bool) Matcher
	// Handle 直接处理事件
	Handle(handler zero.Handler)
}

func On

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

On 添加新的指定消息类型的匹配器(默认Engine)

type Options

type Options struct {
	DisableOnDefault bool
	Help             string // 帮助文本信息
}

Options holds the optional parameters for the Manager.

Directories

Path Synopsis
Package webctrl 包含 webui 所需的所有内容
Package webctrl 包含 webui 所需的所有内容

Jump to

Keyboard shortcuts

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