mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 05:30:07 +08:00
🚸 增加了涩图触发的频率限制
This commit is contained in:
parent
c8852927db
commit
027168e671
3
go.mod
3
go.mod
@ -5,7 +5,8 @@ go 1.15
|
||||
require (
|
||||
github.com/antchfx/htmlquery v1.2.3
|
||||
github.com/mattn/go-sqlite3 v1.14.6
|
||||
github.com/sirupsen/logrus v1.7.0
|
||||
github.com/tidwall/gjson v1.6.8
|
||||
github.com/wdvxdr1123/ZeroBot v0.0.0-20210212165900-0c6c4d79b40e
|
||||
github.com/wdvxdr1123/ZeroBot v0.0.0-20210214154537-b88c3977a0c1
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
)
|
||||
|
||||
2
go.sum
2
go.sum
@ -45,6 +45,8 @@ github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU=
|
||||
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/wdvxdr1123/ZeroBot v0.0.0-20210212165900-0c6c4d79b40e h1:BaUnQOFcCU4l+uf+mifbPdzrBtYfGeDM9RgIFhMBRLs=
|
||||
github.com/wdvxdr1123/ZeroBot v0.0.0-20210212165900-0c6c4d79b40e/go.mod h1:MC6+vOkILANgHlEvZpDMKLNeOWSde5eRgiGFtNGix/4=
|
||||
github.com/wdvxdr1123/ZeroBot v0.0.0-20210214154537-b88c3977a0c1 h1:HxjJ5hOLS1Qmhnd+X0ZFhEspaVqgNs5FR2jR/UBnI10=
|
||||
github.com/wdvxdr1123/ZeroBot v0.0.0-20210214154537-b88c3977a0c1/go.mod h1:MC6+vOkILANgHlEvZpDMKLNeOWSde5eRgiGFtNGix/4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd h1:QPwSajcTUrFriMF1nJ3XzgoqakqQEsnZf9LdXdi2nkI=
|
||||
|
||||
@ -3,12 +3,16 @@ package setutime
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
utils "bot/setutime/utils"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
)
|
||||
|
||||
var limit = rate.NewManager(time.Minute*1, 5)
|
||||
|
||||
type setuGet struct{} // setuGet 来份色图
|
||||
|
||||
func (_ setuGet) GetPluginInfo() zero.PluginInfo { // 返回插件信息
|
||||
@ -66,6 +70,10 @@ type scenery struct {
|
||||
func (_ setuGet) Start() { // 插件主体
|
||||
zero.OnFullMatchGroup([]string{"来份涩图", "setu", "来份色图"}).SetBlock(true).SetPriority(20).
|
||||
Handle(func(matcher *zero.Matcher, event zero.Event, state zero.State) zero.Response {
|
||||
if limit.Load(event.UserID).Acquire() == false {
|
||||
zero.Send(event, "请稍后重试0x0...")
|
||||
return zero.FinishResponse
|
||||
}
|
||||
var (
|
||||
type_ = "setu"
|
||||
illust = &setu{}
|
||||
@ -110,6 +118,10 @@ func (_ setuGet) Start() { // 插件主体
|
||||
})
|
||||
zero.OnFullMatchGroup([]string{"二次元", "ecy", "来份二次元"}).SetBlock(true).SetPriority(20).
|
||||
Handle(func(matcher *zero.Matcher, event zero.Event, state zero.State) zero.Response {
|
||||
if limit.Load(event.UserID).Acquire() == false {
|
||||
zero.Send(event, "请稍后重试0x0...")
|
||||
return zero.FinishResponse
|
||||
}
|
||||
var (
|
||||
type_ = "ecy"
|
||||
illust = &ecy{}
|
||||
@ -154,6 +166,10 @@ func (_ setuGet) Start() { // 插件主体
|
||||
})
|
||||
zero.OnFullMatchGroup([]string{"风景", "来份风景"}).SetBlock(true).SetPriority(20).
|
||||
Handle(func(matcher *zero.Matcher, event zero.Event, state zero.State) zero.Response {
|
||||
if limit.Load(event.UserID).Acquire() == false {
|
||||
zero.Send(event, "请稍后重试0x0...")
|
||||
return zero.FinishResponse
|
||||
}
|
||||
var (
|
||||
type_ = "scenery"
|
||||
illust = &scenery{}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user