mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
✨ acgimage 增加限速器
This commit is contained in:
parent
3084d4ad54
commit
ba9eb9c023
@ -5,10 +5,12 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/classify"
|
||||
"github.com/FloatTech/AnimeAPI/picture"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||
@ -27,6 +29,7 @@ var (
|
||||
randapi = "&loli=true&r18=true"
|
||||
msgof = make(map[int64]int64)
|
||||
block = false
|
||||
limit = rate.NewManager(time.Minute, 1)
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
@ -54,7 +57,7 @@ func init() { // 插件主体
|
||||
// 有保护的随机图片
|
||||
engine.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if classify.CanVisit(5) {
|
||||
if classify.CanVisit(5) && limit.Load(ctx.Event.UserID).Acquire() {
|
||||
go func() {
|
||||
class, lastvisit, dhash, comment := classify.Classify(randapi, false)
|
||||
replyClass(ctx, dhash, class, false, lastvisit, comment)
|
||||
|
||||
@ -44,6 +44,8 @@ const (
|
||||
"- 在MM月[每周|周几]的hh点mm分时(用http://url)提醒大家XXX\n" +
|
||||
"- 取消在MM月dd日的hh点mm分的提醒\n" +
|
||||
"- 取消在MM月[每周|周几]的hh点mm分的提醒\n" +
|
||||
"- [x] 在\"cron\"时(用[url])提醒大家[xxx]\n" +
|
||||
"- [x] 取消在\"cron\"的提醒\n" +
|
||||
"- 列出所有提醒\n" +
|
||||
"- 翻牌\n" +
|
||||
"- 设置欢迎语XXX\n" +
|
||||
|
||||
Loading…
Reference in New Issue
Block a user