mirror of
https://github.com/fumiama/ReiBot.git
synced 2026-06-20 03:04:15 +08:00
add more
This commit is contained in:
24
matcher.go
24
matcher.go
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user