mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
✨ 增加戳一戳频率限制
This commit is contained in:
parent
fd1b992cc9
commit
af0332f454
19
chat/chat.go
19
chat/chat.go
@ -4,14 +4,27 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var poke = rate.NewManager(time.Minute*5, 8) // 戳一戳
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
// 戳一戳
|
// 戳一戳
|
||||||
zero.On("notice/notify/poke", zero.OnlyToMe).SetBlock(false).SetPriority(0).
|
zero.On("notice/notify/poke", zero.OnlyToMe).SetBlock(false).FirstPriority().
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
time.Sleep(time.Second * 1)
|
switch {
|
||||||
ctx.Send("请不要戳我 >_<")
|
case poke.Load(ctx.Event.UserID).AcquireN(3):
|
||||||
|
// 5分钟共8块命令牌 一次消耗3块命令牌
|
||||||
|
time.Sleep(time.Second * 1)
|
||||||
|
ctx.Send("请不要戳我 >_<")
|
||||||
|
case poke.Load(ctx.Event.UserID).Acquire():
|
||||||
|
// 5分钟共8块命令牌 一次消耗1块命令牌
|
||||||
|
time.Sleep(time.Second * 1)
|
||||||
|
ctx.Send("喂(#`O′) 戳我干嘛!")
|
||||||
|
default:
|
||||||
|
// 频繁触发,不回复
|
||||||
|
}
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user