1
0
mirror of https://github.com/fumiama/ReiBot.git synced 2026-06-09 04:30:08 +08:00
This commit is contained in:
源文雨
2022-06-10 19:58:48 +08:00
parent e3c0d5efd6
commit 72390b4c09
14 changed files with 845 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
package rei
// New 生成空引擎
func NewEngine() *Engine {
// 生成空引擎
func newEngine() *Engine {
return &Engine{
preHandler: []Rule{},
midHandler: []Rule{},
@@ -9,7 +9,7 @@ func NewEngine() *Engine {
}
}
var defaultEngine = NewEngine()
var defaultEngine = newEngine()
// Engine is the pre_handler, mid_handler, post_handler manager
type Engine struct {
@@ -17,6 +17,9 @@ type Engine struct {
midHandler []Rule
postHandler []Process
matchers []*Matcher
prio int
service string
datafolder string
}
// Delete 移除该 Engine 注册的所有 Matchers
@@ -59,6 +62,11 @@ func (e *Engine) ApplySingle(s *Single[int64]) *Engine {
return e
}
// DataFolder 本插件数据目录, 默认 data/rbp/
func (e *Engine) DataFolder() string {
return e.datafolder
}
// On 添加新的指定消息类型的匹配器(默认Engine)
func On(typ string, rules ...Rule) *Matcher { return defaultEngine.On(typ, rules...) }