control

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConfig added in v1.5.0

type BaseConfig struct {
	FileSecret []byte `gorm:"column:file_secret"`
}

BaseConfig 基础配置表

type BotBlockConfig

type BotBlockConfig struct {
	UserID string `gorm:"column:uid"` // 用户ID
}

BotBlockConfig bot ban配置表,ban掉的用户无法使用所有插件

type BotResponseConfig

type BotResponseConfig struct {
	GroupID string `gorm:"column:gid"`    // 群组ID
	Status  bool   `gorm:"column:status"` // 响应状态,默认启用
}

BotResponseConfig bot响应群配置表

type Control

type Control struct {
	Service string          // Service 插件服务名
	Cache   map[string]bool // Cache 缓存
	Options Options         // Options 插件配置
	Manager *Manager        // Manager 插件管理器
}

Control 插件控制器

func (*Control) Ban

func (m *Control) Ban(uid, gid string) error

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

func (*Control) CloseGlobalMode added in v1.0.3

func (m *Control) CloseGlobalMode() error

CloseGlobalMode 关闭全局模式

func (*Control) Disable

func (m *Control) Disable(groupID string) error

Disable 使插件在某个群中禁用

func (*Control) Enable

func (m *Control) Enable(groupID string) error

Enable 使插件在某个群中启用

func (*Control) Handler

func (m *Control) Handler(gid, uid string) bool

Handler 返回预处理器

func (*Control) IsBannedIn

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

IsBannedIn 某人是否在某群被ban

func (*Control) IsEnabledAll added in v1.0.3

func (m *Control) IsEnabledAll(enable bool) (isEnable bool, ok bool)

IsEnabledAll 查询是否全局开启

func (*Control) IsEnabledIn

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

IsEnabledIn 查询开启群组

func (*Control) UnBan added in v1.6.3

func (m *Control) UnBan(uid, gid string) error

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

type Engine

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

func Register

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

Register 注册插件控制器

func (*Engine) GetCacheFolder

func (e *Engine) GetCacheFolder() string

GetCacheFolder 获取插件缓存目录

func (*Engine) GetDataFolder

func (e *Engine) GetDataFolder() string

GetDataFolder 获取插件数据目录

func (*Engine) OnCommand

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

OnCommand 命令触发器

func (*Engine) OnCommandGroup

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

OnCommandGroup 命令触发器组

func (*Engine) OnFullMatch

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

OnFullMatch 完全匹配触发器

func (*Engine) OnFullMatchGroup

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

OnFullMatchGroup 完全匹配触发器组

func (*Engine) OnKeyword

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

OnKeyword 关键词触发器

func (*Engine) OnKeywordGroup

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

OnKeywordGroup 关键词触发器组

func (*Engine) OnMessage

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

OnMessage 消息触发器

func (*Engine) OnPrefix

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

OnPrefix 前缀触发器

func (*Engine) OnPrefixGroup

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

OnPrefixGroup 前缀触发器组

func (*Engine) OnRegex

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

OnRegex 正则触发器

func (*Engine) OnSuffix

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

OnSuffix 后缀触发器

func (*Engine) OnSuffixGroup

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

OnSuffixGroup 后缀触发器组

type Manager

type Manager struct {
	sync.RWMutex
	M map[string]*Control
	D *gorm.DB
}

func NewManager

func NewManager(dbpath string) (m Manager)

func (*Manager) CanResponse

func (manager *Manager) CanResponse(gid string) bool

func (*Manager) DoBlock

func (manager *Manager) DoBlock(uid string) error

func (*Manager) DoUnblock

func (manager *Manager) DoUnblock(uid string) error

func (*Manager) IsBlocked

func (manager *Manager) IsBlocked(uid string) bool

func (*Manager) Lookup

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

Lookup 查找插件管理器

func (*Manager) LookupAll

func (manager *Manager) LookupAll() map[string]*Control

LookupAll 查找全部插件管理器

func (*Manager) NewControl

func (manager *Manager) NewControl(service string, o *Options) *Control

func (*Manager) Response

func (manager *Manager) Response(gid string) error

func (*Manager) Silence

func (manager *Manager) Silence(gid string) error

type Matcher

type Matcher robot.Matcher

func (*Matcher) Handle

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

Handle 直接处理事件

func (*Matcher) SetBlock

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

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

func (*Matcher) SetPriority added in v1.6.4

func (m *Matcher) SetPriority(priority uint64) *Matcher

SetPriority 设置当前Matcher优先级

type MessageRecord added in v1.2.1

type MessageRecord struct {
	*robot.MessageRecord
}

MessageRecord 消息记录表

type Options

type Options struct {
	Alias            string               // 插件别名
	Help             string               // 插件帮助信息
	Priority         uint64               // 优先级,只读
	DisableOnDefault bool                 // 默认禁用状态
	HideMenu         bool                 // 是否隐藏在菜单中,默认显示,可用于隐藏一些不希望展示的插件
	DataFolder       string               // 数据文件夹
	OnEnable         func(ctx *robot.Ctx) // 自定义启用插件后执行的操作
	OnDisable        func(ctx *robot.Ctx) // 自定义禁用插件后执行的操作
}

type PluginBanConfig

type PluginBanConfig struct {
	Label   string `gorm:"column:label"` // 标签(service_uid_gid)
	UserID  string `gorm:"column:uid"`   // 用户ID
	GroupID string `gorm:"column:gid"`   // 群组ID
}

PluginBanConfig 插件Ban配置表

type PluginConfig

type PluginConfig struct {
	GroupID string `gorm:"column:gid"`    // 群组ID
	Enable  bool   `gorm:"column:enable"` // 启用状态,默认启用
}

PluginConfig 插件配置表

Jump to

Keyboard shortcuts

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