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