1
0
mirror of https://github.com/fumiama/ReiBot.git synced 2026-06-20 03:04:15 +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

@@ -56,6 +56,30 @@ func (m *Matcher) SetBlock(block bool) *Matcher {
return m
}
// setPriority 设置当前 Matcher 优先级
func (m *Matcher) setPriority(priority int) *Matcher {
matcherLock.Lock()
defer matcherLock.Unlock()
m.priority = priority
sortMatcher(m.Type)
return m
}
// firstPriority 设置当前 Matcher 优先级 - 0
func (m *Matcher) firstPriority() *Matcher {
return m.setPriority(0)
}
// secondPriority 设置当前 Matcher 优先级 - 1
func (m *Matcher) secondPriority() *Matcher {
return m.setPriority(1)
}
// thirdPriority 设置当前 Matcher 优先级 - 2
func (m *Matcher) thirdPriority() *Matcher {
return m.setPriority(2)
}
// Limit 限速器
// postfn 当请求被拒绝时的操作
func (m *Matcher) Limit(limiterfn func(*Ctx) *rate.Limiter, postfn ...func(*Ctx)) *Matcher {