Documentation ¶
Overview ¶
Package control 控制插件的启用与优先级等
Index ¶
- Variables
- type BanStatus
- type BlockStatus
- type Control
- func (m *Control[CTX]) Ban(uid, gid int64)
- func (m *Control[CTX]) Disable(groupID int64)
- func (m *Control[CTX]) Enable(groupID int64)
- func (m *Control[CTX]) EnableMarkIn(grp int64) EnableMark
- func (m *Control[CTX]) Flip() error
- func (m *Control[CTX]) GetData(gid int64) int64
- func (m *Control[CTX]) GetExtra(obj any) error
- func (m *Control[CTX]) Handler(gid, uid int64) bool
- func (m *Control[CTX]) IsBannedIn(uid, gid int64) bool
- func (m *Control[CTX]) IsEnabledIn(gid int64) bool
- func (m *Control[CTX]) Permit(uid, gid int64)
- func (m *Control[CTX]) Reset(groupID int64)
- func (m *Control[CTX]) SetData(groupID int64, data int64) error
- func (m *Control[CTX]) SetExtra(obj any) error
- func (m *Control[CTX]) String() string
- type EnableMark
- type GroupConfig
- type Manager
- func (manager *Manager[CTX]) CanResponse(gid int64) bool
- func (manager *Manager[CTX]) DoBlock(uid int64) error
- func (manager *Manager[CTX]) DoUnblock(uid int64) error
- func (manager *Manager[CTX]) ForEach(iterator func(key string, manager *Control[CTX]) bool)
- func (manager *Manager[CTX]) IsBlocked(uid int64) bool
- func (manager *Manager[CTX]) Lookup(service string) (*Control[CTX], bool)
- func (manager *Manager[CTX]) NewControl(service string, o *Options[CTX]) *Control[CTX]
- func (manager *Manager[CTX]) Response(gid int64) error
- func (manager *Manager[CTX]) Silence(gid int64) error
- type Options
- type ResponseGroup
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyExtra ... ErrEmptyExtra = errors.New("empty extra") // ErrUnregisteredExtra ... ErrUnregisteredExtra = errors.New("unregistered extra") )
Functions ¶
This section is empty.
Types ¶
type BlockStatus ¶ added in v1.5.1
type BlockStatus struct {
UserID int64 `db:"uid"`
}
BlockStatus 全局 ban 某人
type Control ¶
type Control[CTX any] struct { Service string Cache map[int64]uint8 // map[gid]isdisable Options Options[CTX] Manager *Manager[CTX] }
Control is to control the plugins.
func (*Control[CTX]) Disable ¶
Disable disables a group to pass the Manager. groupID == 0 (ALL) will operate on all grps.
func (*Control[CTX]) Enable ¶
Enable enables a group to pass the Manager. groupID == 0 (ALL) will operate on all grps.
func (*Control[CTX]) EnableMarkIn ¶ added in v1.4.0
func (m *Control[CTX]) EnableMarkIn(grp int64) EnableMark
EnableMarkIn 打印 ● 或 ○
func (*Control[CTX]) IsBannedIn ¶
IsBannedIn 某人是否在某群被 ban
func (*Control[CTX]) IsEnabledIn ¶
IsEnabledIn 查询开启群 当全局未配置或与默认相同时, 状态取决于单独配置, 后备为默认配置; 当全局与默认不同时, 状态取决于全局配置, 单独配置失效。
func (*Control[CTX]) Reset ¶
Reset resets the default config of a group. groupID == 0 (ALL) is not allowed.
type GroupConfig ¶ added in v1.5.1
type GroupConfig struct { GroupID int64 `db:"gid"` // GroupID 群号 Disable int64 `db:"disable"` // Disable 默认启用该插件 }
GroupConfig holds the group config for the Manager.
type Manager ¶ added in v1.4.0
type Manager[CTX any] struct { sync.RWMutex M map[string]*Control[CTX] D sql.Sqlite // contains filtered or unexported fields }
Manager 管理
func NewManager ¶ added in v1.4.0
NewManager 打开管理数据库
func (*Manager[CTX]) CanResponse ¶ added in v1.5.1
CanResponse ...
func (*Manager[CTX]) Lookup ¶ added in v1.4.0
Lookup returns a Manager by the service name, if not exist, it will return nil.
func (*Manager[CTX]) NewControl ¶ added in v1.5.1
NewControl returns Manager with settings.
type Options ¶
type Options[CTX any] struct { DisableOnDefault bool Extra int16 // 插件申请的 Extra 记录号, 可为 -32768~32767, 0 不可用 Brief string // 简介 Help string // 帮助文本信息 Banner string // 背景图路径, 可为 http 或 本地 路径 PrivateDataFolder string // 全部小写的数据文件夹名, 不出现在 zbpdata PublicDataFolder string // 驼峰的数据文件夹名, 出现在 zbpdata OnEnable func(CTX) // 启用插件后执行的命令, 为空则打印 “已启用服务: xxx” OnDisable func(CTX) // 禁用插件后执行的命令, 为空则打印 “已禁用服务: xxx” }
Options holds the optional parameters for the Manager.
type ResponseGroup ¶ added in v1.5.1
type ResponseGroup struct { GroupID int64 `db:"gid"` // GroupID 群号, 个人为负 Extra string `db:"ext"` // Extra 该群的扩展数据 }
ResponseGroup 响应的群