mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
🎨 🔥 统一限速器
This commit is contained in:
parent
259b29f6e3
commit
a16bcda7da
6
go.mod
6
go.mod
@ -3,8 +3,8 @@ module github.com/FloatTech/ZeroBot-Plugin
|
|||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/FloatTech/AnimeAPI v1.2.5-beta10
|
github.com/FloatTech/AnimeAPI v1.2.5-beta14
|
||||||
github.com/FloatTech/zbputils v1.2.5-beta7
|
github.com/FloatTech/zbputils v1.2.5-beta12
|
||||||
github.com/antchfx/htmlquery v1.2.4
|
github.com/antchfx/htmlquery v1.2.4
|
||||||
github.com/corona10/goimagehash v1.0.3
|
github.com/corona10/goimagehash v1.0.3
|
||||||
github.com/fogleman/gg v1.3.0
|
github.com/fogleman/gg v1.3.0
|
||||||
@ -19,7 +19,7 @@ require (
|
|||||||
github.com/shirou/gopsutil/v3 v3.21.12
|
github.com/shirou/gopsutil/v3 v3.21.12
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
github.com/tidwall/gjson v1.13.0
|
github.com/tidwall/gjson v1.13.0
|
||||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220207114459-068919ac2b02
|
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220208041536-d463c1c92bb4
|
||||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
12
go.sum
12
go.sum
@ -1,8 +1,8 @@
|
|||||||
github.com/FloatTech/AnimeAPI v1.2.5-beta10 h1:C4gvZ4VbVjNUA8WBgNnq0ra0YG1uNyL8VmHGFdpZ1Tc=
|
github.com/FloatTech/AnimeAPI v1.2.5-beta14 h1:CyP0YTrSkXgOAmunr9s5TpVoZxhc5Nrz6tkKv+avUNk=
|
||||||
github.com/FloatTech/AnimeAPI v1.2.5-beta10/go.mod h1:QXGkLikmx2G4nVL24RwLdfcA8Hd54SdfCqVqu/Znd5A=
|
github.com/FloatTech/AnimeAPI v1.2.5-beta14/go.mod h1:jsUR1c9voZPgBZybMEZl+LpnOtKZFhN9NZKMvHjbT6M=
|
||||||
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
|
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
|
||||||
github.com/FloatTech/zbputils v1.2.5-beta7 h1:5mgJaYa8fTx/PQp+oL13pJGQ6GEjkUDg1r1T2ECAiac=
|
github.com/FloatTech/zbputils v1.2.5-beta12 h1:+MtcwLP5/IaLAX3dMOzHFbv5cNBLlb5BRk2LNFAfEF0=
|
||||||
github.com/FloatTech/zbputils v1.2.5-beta7/go.mod h1:3XY4b7OJuQD2zUOaBc1EzDdpXvx3YM4FvpUKZNwgreA=
|
github.com/FloatTech/zbputils v1.2.5-beta12/go.mod h1:1j71Sna0RnprP3ywDNTblRzITNYCb2FGN2yxl1G4zg0=
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M=
|
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M=
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
|
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
|
||||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||||
@ -166,8 +166,8 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY
|
|||||||
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
|
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
|
||||||
github.com/wdvxdr1123/ZeroBot v1.3.2/go.mod h1:i2DIqQjtjE+3gvVi9r9sc+QpNaUuyTXx/HNXXayIpwI=
|
github.com/wdvxdr1123/ZeroBot v1.3.2/go.mod h1:i2DIqQjtjE+3gvVi9r9sc+QpNaUuyTXx/HNXXayIpwI=
|
||||||
github.com/wdvxdr1123/ZeroBot v1.4.1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
|
github.com/wdvxdr1123/ZeroBot v1.4.1/go.mod h1:7t9m4vDZPwWAmzKlhP6IvUoisOIiqNdm/3AJgiY3+ew=
|
||||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220207114459-068919ac2b02 h1:Tm5gEjJpm0M2sY6RegimsrRekqNBD26qZjYwTx5Gt6s=
|
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220208041536-d463c1c92bb4 h1:T/m7vDUFKdLd0xfSZHVPQGaRZ73nwPzidLW7hTn25mg=
|
||||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220207114459-068919ac2b02/go.mod h1:NwXIp7PgjV+kUALMXJ4v4/3QcsRSOodtjhLekuPXFog=
|
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220208041536-d463c1c92bb4/go.mod h1:NwXIp7PgjV+kUALMXJ4v4/3QcsRSOodtjhLekuPXFog=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||||
|
|||||||
@ -4,15 +4,13 @@ package acgimage
|
|||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/classify"
|
"github.com/FloatTech/AnimeAPI/classify"
|
||||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/ctxext"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
|
"github.com/FloatTech/zbputils/imgpool"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
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/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
@ -29,7 +27,6 @@ var (
|
|||||||
randapi = "&loli=true&r18=true"
|
randapi = "&loli=true&r18=true"
|
||||||
msgof = make(map[int64]message.MessageID)
|
msgof = make(map[int64]message.MessageID)
|
||||||
block = false
|
block = false
|
||||||
limit = rate.NewManager(time.Minute, 5)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
@ -53,14 +50,10 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 有保护的随机图片
|
// 有保护的随机图片
|
||||||
engine.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).
|
engine.OnFullMatch("随机图片", zero.OnlyGroup).Limit(ctxext.LimitByUser).SetBlock(true).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if limit.Load(ctx.Event.UserID).Acquire() {
|
class, dhash, comment, _ := classify.Classify(randapi, true)
|
||||||
class, dhash, comment, _ := classify.Classify(randapi, true)
|
replyClass(ctx, class, dhash, comment, false)
|
||||||
replyClass(ctx, class, dhash, comment, false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.SendChain(message.Text("你太快啦!"))
|
|
||||||
})
|
})
|
||||||
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
|
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
|
||||||
engine.OnFullMatch("直接随机", ctxext.UserOrGrpAdmin).SetBlock(true).
|
engine.OnFullMatch("直接随机", ctxext.UserOrGrpAdmin).SetBlock(true).
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/aireply"
|
"github.com/FloatTech/AnimeAPI/aireply"
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
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/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
@ -21,21 +21,16 @@ const (
|
|||||||
var modes = [...]string{"青云客", "小爱"}
|
var modes = [...]string{"青云客", "小爱"}
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
bucket := rate.NewManager(time.Minute, 20) // 接口回复限速器
|
|
||||||
engine := control.Register(serviceName, order.PrioAIReply, &control.Options{
|
engine := control.Register(serviceName, order.PrioAIReply, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "人工智能回复\n" +
|
Help: "人工智能回复\n" +
|
||||||
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客 | 小爱]\n- ",
|
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客 | 小爱]\n- ",
|
||||||
})
|
})
|
||||||
// 回复 @和包括名字
|
// 回复 @和包括名字
|
||||||
engine.OnMessage(zero.OnlyToMe).SetBlock(true).
|
engine.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
aireply := aireply.NewAIReply(getReplyMode(ctx))
|
aireply := aireply.NewAIReply(getReplyMode(ctx))
|
||||||
if !bucket.Load(ctx.Event.UserID).Acquire() {
|
reply := message.ParseMessageFromString(aireply.Talk(ctx.ExtractPlainText(), zero.BotConfig.NickName[0]))
|
||||||
// 频繁触发,不回复
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reply := aireply.Talk(ctx.ExtractPlainText())
|
|
||||||
// 回复
|
// 回复
|
||||||
time.Sleep(time.Second * 1)
|
time.Sleep(time.Second * 1)
|
||||||
if zero.OnlyPublic(ctx) {
|
if zero.OnlyPublic(ctx) {
|
||||||
|
|||||||
@ -1,32 +1,27 @@
|
|||||||
package aireply
|
package aireply
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/aireply"
|
"github.com/FloatTech/AnimeAPI/aireply"
|
||||||
"github.com/FloatTech/AnimeAPI/mockingbird"
|
"github.com/FloatTech/AnimeAPI/mockingbird"
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
limit := rate.NewManager(time.Second*10, 1)
|
|
||||||
|
|
||||||
control.Register("mockingbird", order.PrioMockingBird, &control.Options{
|
control.Register("mockingbird", order.PrioMockingBird, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "拟声鸟\n- @Bot 任意文本(任意一句话回复)",
|
Help: "拟声鸟\n- @Bot 任意文本(任意一句话回复)",
|
||||||
}).OnMessage(zero.OnlyToMe, func(ctx *zero.Ctx) bool {
|
}).OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
return limit.Load(ctx.Event.UserID).Acquire()
|
|
||||||
}).SetBlock(true).
|
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
msg := ctx.ExtractPlainText()
|
msg := ctx.ExtractPlainText()
|
||||||
r := aireply.NewAIReply(getReplyMode(ctx))
|
r := aireply.NewAIReply(getReplyMode(ctx))
|
||||||
ctx.SendChain(mockingbird.Speak(ctx.Event.UserID, func() string {
|
ctx.SendChain(message.Record(mockingbird.Speak(ctx.Event.UserID, func() string {
|
||||||
return r.TalkPlain(msg)
|
return r.TalkPlain(msg, zero.BotConfig.NickName[0])
|
||||||
}))
|
})))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,17 +2,15 @@
|
|||||||
package coser
|
package coser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
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/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
@ -21,19 +19,14 @@ import (
|
|||||||
var (
|
var (
|
||||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
|
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
|
||||||
coserURL = "http://ovooa.com/API/cosplay/api.php"
|
coserURL = "http://ovooa.com/API/cosplay/api.php"
|
||||||
limit = rate.NewManager(time.Minute, 5)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
control.Register("coser", order.PrioCoser, &control.Options{
|
control.Register("coser", order.PrioCoser, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "三次元小姐姐\n- coser",
|
Help: "三次元小姐姐\n- coser",
|
||||||
}).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).
|
}).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||||
data, err := web.ReqWith(coserURL, "GET", "", ua)
|
data, err := web.ReqWith(coserURL, "GET", "", ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -2,13 +2,11 @@
|
|||||||
package curse
|
package curse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
@ -20,25 +18,18 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
limit := rate.NewManager(time.Minute, 30)
|
|
||||||
engine := control.Register("curse", order.PrioCurse, &control.Options{
|
engine := control.Register("curse", order.PrioCurse, &control.Options{
|
||||||
DisableOnDefault: true,
|
DisableOnDefault: true,
|
||||||
Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我",
|
Help: "骂人(求骂,自卫)\n- 骂我\n- 大力骂我",
|
||||||
})
|
})
|
||||||
|
|
||||||
engine.OnFullMatch("骂我").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnFullMatch("骂我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
text := getRandomCurseByLevel(minLevel).Text
|
text := getRandomCurseByLevel(minLevel).Text
|
||||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
||||||
})
|
})
|
||||||
|
|
||||||
engine.OnFullMatch("大力骂我").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnFullMatch("大力骂我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
process.SleepAbout1sTo2s()
|
process.SleepAbout1sTo2s()
|
||||||
text := getRandomCurseByLevel(maxLevel).Text
|
text := getRandomCurseByLevel(maxLevel).Text
|
||||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
||||||
|
|||||||
@ -19,10 +19,10 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/ctxext"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
|
"github.com/FloatTech/zbputils/imgpool"
|
||||||
"github.com/FloatTech/zbputils/math"
|
"github.com/FloatTech/zbputils/math"
|
||||||
"github.com/FloatTech/zbputils/txt2img"
|
"github.com/FloatTech/zbputils/txt2img"
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,8 @@ package funny
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
@ -22,15 +20,11 @@ var (
|
|||||||
Help: "讲个笑话\n" +
|
Help: "讲个笑话\n" +
|
||||||
"- 讲个笑话[@xxx] | 讲个笑话[qq号]",
|
"- 讲个笑话[@xxx] | 讲个笑话[qq号]",
|
||||||
})
|
})
|
||||||
limit = rate.NewManager(time.Minute, 20)
|
db = &sql.Sqlite{DBPath: dbfile}
|
||||||
db = &sql.Sqlite{DBPath: dbfile}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine.OnPrefix("讲个笑话").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnPrefix("讲个笑话").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 获取名字
|
// 获取名字
|
||||||
name := ctxext.NickName(ctx)
|
name := ctxext.NickName(ctx)
|
||||||
var j joke
|
var j joke
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/ctxext"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
|
"github.com/FloatTech/zbputils/imgpool"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
|
|||||||
@ -6,13 +6,12 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
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/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
@ -25,19 +24,12 @@ const (
|
|||||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
|
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
limit = rate.NewManager(time.Minute, 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
control.Register("juejuezi", order.PrioJueJueZi, &control.Options{
|
control.Register("juejuezi", order.PrioJueJueZi, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "绝绝子生成器\n" +
|
Help: "绝绝子生成器\n" +
|
||||||
"- 喝奶茶绝绝子 | 绝绝子吃饭",
|
"- 喝奶茶绝绝子 | 绝绝子吃饭",
|
||||||
}).OnRegex("[\u4E00-\u9FA5]{0,10}绝绝子[\u4E00-\u9FA5]{0,10}").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
}).OnRegex("[\u4E00-\u9FA5]{0,10}绝绝子[\u4E00-\u9FA5]{0,10}").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
toDealStr := []rune(strings.ReplaceAll(ctx.ExtractPlainText(), "绝绝子", ""))
|
toDealStr := []rune(strings.ReplaceAll(ctx.ExtractPlainText(), "绝绝子", ""))
|
||||||
switch len(toDealStr) {
|
switch len(toDealStr) {
|
||||||
case 0, 1:
|
case 0, 1:
|
||||||
|
|||||||
@ -11,9 +11,9 @@ import (
|
|||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/ctxext"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
|
"github.com/FloatTech/zbputils/imgpool"
|
||||||
"github.com/FloatTech/zbputils/math"
|
"github.com/FloatTech/zbputils/math"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
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"
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
@ -57,7 +56,6 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
db = &sql.Sqlite{DBPath: confile}
|
db = &sql.Sqlite{DBPath: confile}
|
||||||
limit = rate.NewManager(time.Minute*5, 2)
|
|
||||||
clock timer.Clock
|
clock timer.Clock
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -333,12 +331,8 @@ func init() { // 插件主体
|
|||||||
ctx.SendChain(message.Text(clock.ListTimers(ctx.Event.GroupID)))
|
ctx.SendChain(message.Text(clock.ListTimers(ctx.Event.GroupID)))
|
||||||
})
|
})
|
||||||
// 随机点名
|
// 随机点名
|
||||||
engine.OnFullMatchGroup([]string{"翻牌"}, zero.OnlyGroup).SetBlock(true).
|
engine.OnFullMatchGroup([]string{"翻牌"}, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
|
||||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 无缓存获取群员列表
|
// 无缓存获取群员列表
|
||||||
list := ctx.CallAction("get_group_member_list", zero.Params{
|
list := ctx.CallAction("get_group_member_list", zero.Params{
|
||||||
"group_id": ctx.Event.GroupID,
|
"group_id": ctx.Event.GroupID,
|
||||||
|
|||||||
@ -12,16 +12,14 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
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/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
)
|
)
|
||||||
|
|
||||||
var limit = rate.NewManager(time.Minute*3, 5)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
control.Register("music", order.PrioMusic, &control.Options{
|
control.Register("music", order.PrioMusic, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
@ -30,12 +28,8 @@ func init() {
|
|||||||
"- 网易点歌[xxx]\n" +
|
"- 网易点歌[xxx]\n" +
|
||||||
"- 酷我点歌[xxx]\n" +
|
"- 酷我点歌[xxx]\n" +
|
||||||
"- 酷狗点歌[xxx]",
|
"- 酷狗点歌[xxx]",
|
||||||
}).OnRegex(`^(.{0,2})点歌\s?(.{1,25})$`).SetBlock(true).
|
}).OnRegex(`^(.{0,2})点歌\s?(.{1,25})$`).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
|
||||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// switch 平台
|
// switch 平台
|
||||||
switch ctx.State["regex_matched"].([]string)[1] {
|
switch ctx.State["regex_matched"].([]string)[1] {
|
||||||
case "酷我":
|
case "酷我":
|
||||||
|
|||||||
@ -9,17 +9,16 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/antchfx/htmlquery"
|
"github.com/antchfx/htmlquery"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
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/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
ub "github.com/FloatTech/zbputils/binary"
|
ub "github.com/FloatTech/zbputils/binary"
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/txt2img"
|
"github.com/FloatTech/zbputils/txt2img"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
@ -44,16 +43,11 @@ var (
|
|||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "铅笔小说网搜索\n- 小说[xxx]",
|
Help: "铅笔小说网搜索\n- 小说[xxx]",
|
||||||
})
|
})
|
||||||
limit = rate.NewManager(time.Minute, 5)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine.OnRegex("^小说([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).
|
engine.OnRegex("^小说([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||||
login(username, password)
|
login(username, password)
|
||||||
searchKey := ctx.State["regex_matched"].([]string)[1]
|
searchKey := ctx.State["regex_matched"].([]string)[1]
|
||||||
|
|||||||
@ -10,8 +10,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
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/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
@ -20,7 +20,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
limit = rate.NewManager(time.Minute*3, 5)
|
|
||||||
templates = map[string]string{
|
templates = map[string]string{
|
||||||
"py2": "print 'Hello World!'",
|
"py2": "print 'Hello World!'",
|
||||||
"ruby": "puts \"Hello World!\";",
|
"ruby": "puts \"Hello World!\";",
|
||||||
@ -105,46 +104,42 @@ func init() {
|
|||||||
"JavaScript || TypeScript || PHP || Shell \n" +
|
"JavaScript || TypeScript || PHP || Shell \n" +
|
||||||
"Kotlin || Rust || Erlang || Ruby || Swift \n" +
|
"Kotlin || Rust || Erlang || Ruby || Swift \n" +
|
||||||
"R || VB || Py2 || Perl || Pascal || Scala",
|
"R || VB || Py2 || Perl || Pascal || Scala",
|
||||||
}).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).
|
}).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
language := ctx.State["regex_matched"].([]string)[1]
|
||||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
language = strings.ToLower(language)
|
||||||
|
if runType, exist := table[language]; !exist {
|
||||||
|
// 不支持语言
|
||||||
|
ctx.SendChain(
|
||||||
|
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
||||||
|
message.Text("语言不是受支持的编程语种呢~"),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
language := ctx.State["regex_matched"].([]string)[1]
|
// 执行运行
|
||||||
language = strings.ToLower(language)
|
block := ctx.State["regex_matched"].([]string)[2]
|
||||||
if runType, exist := table[language]; !exist {
|
block = message.UnescapeCQCodeText(block)
|
||||||
// 不支持语言
|
if block == "help" {
|
||||||
|
// 输出模板
|
||||||
ctx.SendChain(
|
ctx.SendChain(
|
||||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
|
||||||
message.Text("语言不是受支持的编程语种呢~"),
|
message.Text(
|
||||||
|
">runcode ", language, "\n",
|
||||||
|
templates[language],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// 执行运行
|
if output, err := runCode(block, runType); err != nil {
|
||||||
block := ctx.State["regex_matched"].([]string)[2]
|
// 运行失败
|
||||||
block = message.UnescapeCQCodeText(block)
|
|
||||||
if block == "help" {
|
|
||||||
// 输出模板
|
|
||||||
ctx.SendChain(
|
ctx.SendChain(
|
||||||
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
|
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
||||||
message.Text(
|
message.Text("ERROR: ", err),
|
||||||
">runcode ", language, "\n",
|
|
||||||
templates[language],
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if output, err := runCode(block, runType); err != nil {
|
// 运行成功
|
||||||
// 运行失败
|
ctx.SendChain(
|
||||||
ctx.SendChain(
|
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
||||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
message.Text(output),
|
||||||
message.Text("ERROR: ", err),
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// 运行成功
|
|
||||||
ctx.SendChain(
|
|
||||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
|
||||||
message.Text(output),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,12 +6,12 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/ascii2d"
|
"github.com/FloatTech/AnimeAPI/ascii2d"
|
||||||
"github.com/FloatTech/AnimeAPI/imgpool"
|
|
||||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||||
"github.com/FloatTech/AnimeAPI/saucenao"
|
"github.com/FloatTech/AnimeAPI/saucenao"
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/ctxext"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/file"
|
"github.com/FloatTech/zbputils/file"
|
||||||
|
"github.com/FloatTech/zbputils/imgpool"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
|||||||
@ -10,17 +10,16 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
imagepool "github.com/FloatTech/AnimeAPI/imgpool"
|
|
||||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
"github.com/FloatTech/zbputils/ctxext"
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
fileutil "github.com/FloatTech/zbputils/file"
|
fileutil "github.com/FloatTech/zbputils/file"
|
||||||
|
imagepool "github.com/FloatTech/zbputils/imgpool"
|
||||||
"github.com/FloatTech/zbputils/math"
|
"github.com/FloatTech/zbputils/math"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
"github.com/FloatTech/zbputils/rule"
|
"github.com/FloatTech/zbputils/rule"
|
||||||
"github.com/FloatTech/zbputils/sql"
|
"github.com/FloatTech/zbputils/sql"
|
||||||
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/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
@ -70,7 +69,6 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
limit := rate.NewManager(time.Minute*1, 5)
|
|
||||||
engine := control.Register("setutime", order.PrioSetuTime, &control.Options{
|
engine := control.Register("setutime", order.PrioSetuTime, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "涩图\n" +
|
Help: "涩图\n" +
|
||||||
@ -79,12 +77,8 @@ func init() { // 插件主体
|
|||||||
"- 删除[涩图/二次元/风景/车万][P站图片ID]\n" +
|
"- 删除[涩图/二次元/风景/车万][P站图片ID]\n" +
|
||||||
"- >setu status",
|
"- >setu status",
|
||||||
})
|
})
|
||||||
engine.OnRegex(`^来份(.*)$`, rule.FirstValueInList(pool)).SetBlock(true).
|
engine.OnRegex(`^来份(.*)$`, rule.FirstValueInList(pool)).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
|
||||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var imgtype = ctx.State["regex_matched"].([]string)[1]
|
var imgtype = ctx.State["regex_matched"].([]string)[1]
|
||||||
// 补充池子
|
// 补充池子
|
||||||
go pool.fill(ctx, imgtype)
|
go pool.fill(ctx, imgtype)
|
||||||
|
|||||||
@ -5,14 +5,12 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine.OnFullMatch("哄我").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnFullMatch("哄我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := web.ReqWith(chpURL, "GET", chpReferer, ua)
|
data, err := web.ReqWith(chpURL, "GET", chpReferer, ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
|||||||
@ -5,14 +5,12 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := web.ReqWith(duURL, "GET", duReferer, ua)
|
data, err := web.ReqWith(duURL, "GET", duReferer, ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
|||||||
@ -5,14 +5,12 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine.OnFullMatch("发个朋友圈").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnFullMatch("发个朋友圈").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua)
|
data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
|||||||
@ -2,10 +2,7 @@
|
|||||||
package shadiao
|
package shadiao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
)
|
)
|
||||||
@ -31,5 +28,4 @@ var (
|
|||||||
Help: "沙雕app\n" +
|
Help: "沙雕app\n" +
|
||||||
"- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子",
|
"- 哄我\n- 渣我\n- 来碗绿茶\n- 发个朋友圈\n- 来碗毒鸡汤\n- 讲个段子",
|
||||||
})
|
})
|
||||||
limit = rate.NewManager(time.Minute, 60)
|
|
||||||
)
|
)
|
||||||
|
|||||||
@ -6,14 +6,12 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine.OnFullMatch("来碗绿茶").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnFullMatch("来碗绿茶").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua)
|
data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
@ -23,10 +21,7 @@ func init() {
|
|||||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
||||||
})
|
})
|
||||||
|
|
||||||
engine.OnFullMatch("渣我").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnFullMatch("渣我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua)
|
data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
|||||||
@ -8,14 +8,12 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine.OnFullMatch("讲个段子").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
engine.OnFullMatch("讲个段子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := web.ReqWith(yduanziURL, "POST", yduanziReferer, ua)
|
data, err := web.ReqWith(yduanziURL, "POST", yduanziReferer, ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
|||||||
@ -2,12 +2,9 @@
|
|||||||
package shindan
|
package shindan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/FloatTech/AnimeAPI/shindanmaker"
|
"github.com/FloatTech/AnimeAPI/shindanmaker"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
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/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
@ -18,11 +15,6 @@ import (
|
|||||||
"github.com/FloatTech/zbputils/txt2img"
|
"github.com/FloatTech/zbputils/txt2img"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// 限制调用频率
|
|
||||||
limit = rate.NewManager(time.Minute*5, 5)
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
engine := control.Register("shindan", order.PrioShinDan, &control.Options{
|
engine := control.Register("shindan", order.PrioShinDan, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
@ -32,18 +24,14 @@ func init() {
|
|||||||
"- 卖萌[@xxx]\n" +
|
"- 卖萌[@xxx]\n" +
|
||||||
"- 抽老婆[@xxx]",
|
"- 抽老婆[@xxx]",
|
||||||
})
|
})
|
||||||
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Handle(handle)
|
engine.OnPrefix("异世界转生", number(587874)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
|
||||||
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Handle(handle)
|
engine.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
|
||||||
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Handle(handle)
|
engine.OnPrefix("卖萌", number(360578)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
|
||||||
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Handle(handle)
|
engine.OnPrefix("抽老婆", number(1075116)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// shindanmaker 处理函数
|
// shindanmaker 处理函数
|
||||||
func handle(ctx *zero.Ctx) {
|
func handle(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
|
||||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 获取名字
|
// 获取名字
|
||||||
name := ctxext.NickName(ctx)
|
name := ctxext.NickName(ctx)
|
||||||
// 调用接口
|
// 调用接口
|
||||||
|
|||||||
@ -6,23 +6,18 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
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"
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/process"
|
"github.com/FloatTech/zbputils/process"
|
||||||
|
|
||||||
"github.com/FloatTech/ZeroBot-Plugin/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
bucket = rate.NewManager(time.Minute, 20) // 接口回复
|
|
||||||
)
|
|
||||||
|
|
||||||
func tl(d string) ([]byte, error) {
|
func tl(d string) ([]byte, error) {
|
||||||
url := "https://api.cloolc.club/fanyi?data=" + d
|
url := "https://api.cloolc.club/fanyi?data=" + d
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
@ -47,12 +42,8 @@ func init() {
|
|||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "翻译\n" +
|
Help: "翻译\n" +
|
||||||
">TL 你好",
|
">TL 你好",
|
||||||
}).OnRegex(`^>TL\s(-.{1,10}? )?(.*)$`).SetBlock(true).
|
}).OnRegex(`^>TL\s(-.{1,10}? )?(.*)$`).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !bucket.Load(ctx.Event.UserID).Acquire() {
|
|
||||||
// 频繁触发,不回复
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msg := []string{ctx.State["regex_matched"].([]string)[2]}
|
msg := []string{ctx.State["regex_matched"].([]string)[2]}
|
||||||
rely, err := tl(msg[0])
|
rely, err := tl(msg[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -2,12 +2,10 @@
|
|||||||
package wangyiyun
|
package wangyiyun
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/FloatTech/zbputils/control"
|
"github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
"github.com/FloatTech/zbputils/web"
|
"github.com/FloatTech/zbputils/web"
|
||||||
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/wdvxdr1123/ZeroBot/utils/helper"
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||||
|
|
||||||
@ -21,15 +19,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
limit := rate.NewManager(time.Minute, 60)
|
|
||||||
control.Register("wangyiyun", order.PrioWangYiYun, &control.Options{
|
control.Register("wangyiyun", order.PrioWangYiYun, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "wangyiyun \n- 来份网易云热评",
|
Help: "wangyiyun \n- 来份网易云热评",
|
||||||
}).OnFullMatch("来份网易云热评").SetBlock(true).
|
}).OnFullMatch("来份网易云热评").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data, err := web.ReqWith(wangyiyunURL, "GET", wangyiyunReferer, ua)
|
data, err := web.ReqWith(wangyiyunURL, "GET", wangyiyunReferer, ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR:", err))
|
ctx.SendChain(message.Text("ERROR:", err))
|
||||||
|
|||||||
@ -4,21 +4,15 @@ package wtf
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
|
|
||||||
control "github.com/FloatTech/zbputils/control"
|
control "github.com/FloatTech/zbputils/control"
|
||||||
|
"github.com/FloatTech/zbputils/ctxext"
|
||||||
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/order"
|
"github.com/FloatTech/ZeroBot-Plugin/order"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// 限制调用频率
|
|
||||||
limit = rate.NewManager(time.Minute*5, 5)
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
en := control.Register("wtf", order.PrioWtf, &control.Options{
|
en := control.Register("wtf", order.PrioWtf, &control.Options{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
@ -32,12 +26,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
ctx.SendChain(message.Text(s))
|
ctx.SendChain(message.Text(s))
|
||||||
})
|
})
|
||||||
en.OnRegex(`^查询鬼东西(\d*)`, zero.OnlyGroup).SetBlock(true).
|
en.OnRegex(`^查询鬼东西(\d*)`, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
|
||||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 调用接口
|
// 调用接口
|
||||||
i, err := strconv.Atoi(ctx.State["regex_matched"].([]string)[1])
|
i, err := strconv.Atoi(ctx.State["regex_matched"].([]string)[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user