Skip to content

Commit 4519dd5

Browse files
committed
💫 ♻️ 🎉 ✨ ⚡️ 强制使用优先级
1 parent 925e684 commit 4519dd5

File tree

58 files changed

+303
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+303
-215
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/FloatTech/ZeroBot-Plugin
33
go 1.17
44

55
require (
6-
github.com/FloatTech/AnimeAPI v1.2.4-beta1
7-
github.com/FloatTech/zbputils v1.2.4-beta1
6+
github.com/FloatTech/AnimeAPI v1.2.4-beta2
7+
github.com/FloatTech/zbputils v1.2.4-beta2
88
github.com/antchfx/htmlquery v1.2.4
99
github.com/chromedp/chromedp v0.7.6
1010
github.com/corona10/goimagehash v1.0.3

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
github.com/FloatTech/AnimeAPI v1.2.4-beta1 h1:Ff+721UgTSXCRiod83wlUCY0C1nE4wWa7+NCgYjF/Ew=
2-
github.com/FloatTech/AnimeAPI v1.2.4-beta1/go.mod h1:tQNIP/1fbQzEi3U9v9PsdPOr2OURMx9S8WH+w1oco4I=
1+
github.com/FloatTech/AnimeAPI v1.2.4-beta2 h1:bpWv2QwIgommXblBTro+OtxfUWfSv86dSLMA2M1jjog=
2+
github.com/FloatTech/AnimeAPI v1.2.4-beta2/go.mod h1:q2WwEhalrhjGdI/woUwWMryUXwIWKgJybQA2t2B+hB4=
33
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
4-
github.com/FloatTech/zbputils v1.2.4-beta1 h1:WT85o9Y6MAJtmQaMD5h0l1mJ/7qBcjRQdNlCsB5pAPY=
5-
github.com/FloatTech/zbputils v1.2.4-beta1/go.mod h1:ZIuQP4tuhn7jiowEy+PALiHmr4zzPQBj4VdjEyd5/Es=
4+
github.com/FloatTech/zbputils v1.2.4-beta2 h1:9y8BZR5Rr4NgDz/818r8sCBjitIPrHY+Hd6tl3lINn4=
5+
github.com/FloatTech/zbputils v1.2.4-beta2/go.mod h1:ZIuQP4tuhn7jiowEy+PALiHmr4zzPQBj4VdjEyd5/Es=
66
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M=
77
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
88
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ func getKanban() string {
153153
func main() {
154154
printBanner()
155155
// 帮助
156-
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).FirstPriority().
156+
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
157157
Handle(func(ctx *zero.Ctx) {
158158
ctx.SendChain(message.Text(banner, "\n可发送\"/服务列表\"查看 bot 功能"))
159159
})
160-
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).FirstPriority().
160+
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).
161161
Handle(func(ctx *zero.Ctx) {
162162
ctx.SendChain(message.Text(getKanban()))
163163
})

order/prio.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Package order 各个插件的优先级
2+
package order
3+
4+
const (
5+
PrioChat = iota * 10
6+
PrioSleepManage
7+
PrioAtri
8+
PrioManager
9+
10+
PrioACGImage
11+
PrioAIFalse
12+
PrioAIWife
13+
PrioBase14
14+
PrioBilibili
15+
PrioBilibiliPush
16+
PrioBookReview
17+
PrioCangTouShi
18+
PrioChoose
19+
PrioChouXiangHua
20+
PrioCoser
21+
PrioCPStory
22+
PrioDanbooru
23+
PrioDiana
24+
PrioFansDaily
25+
PrioFortune
26+
PrioFunny
27+
PrioGIF
28+
PrioGithub
29+
PrioHS
30+
PrioImageFinder
31+
PrioJueJueZi
32+
PrioLolicon
33+
PrioMinecraft
34+
PrioMoyu
35+
PrioMusic
36+
PrioNativeSetu
37+
PrioNativeWife
38+
PrioNBNHHSH
39+
PrioNovel
40+
PrioOmikuji
41+
PrioReborn
42+
PrioRuncode
43+
PrioSauceNao
44+
PrioScore
45+
PrioSetuTime
46+
PrioShaDiao
47+
PrioShinDan
48+
PrioTraceMoe
49+
PrioTranslation
50+
PrioVtbQuotation
51+
PrioWtf
52+
53+
PrioCurse
54+
PrioMockingBird
55+
PrioAIReply
56+
)

plugin_acgimage/classify.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/FloatTech/AnimeAPI/classify"
1010
"github.com/FloatTech/AnimeAPI/picture"
11+
"github.com/FloatTech/ZeroBot-Plugin/order"
1112
zero "github.com/wdvxdr1123/ZeroBot"
1213
"github.com/wdvxdr1123/ZeroBot/extension/rate"
1314
"github.com/wdvxdr1123/ZeroBot/message"
@@ -31,7 +32,7 @@ var (
3132
)
3233

3334
func init() { // 插件主体
34-
engine := control.Register("acgimage", &control.Options{
35+
engine := control.Register("acgimage", order.PrioACGImage, &control.Options{
3536
DisableOnDefault: false,
3637
Help: "随机图片与AI点评\n" +
3738
"- 随机图片(评级大于6的图将私发)\n" +
@@ -40,7 +41,7 @@ func init() { // 插件主体
4041
"- 太涩了(撤回最近发的图)\n" +
4142
"- 评价图片(发送一张图片让bot评分)",
4243
})
43-
engine.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
44+
engine.OnRegex(`^设置随机图片网址(.*)$`, zero.OnlyPrivate, zero.SuperUserPermission).SetBlock(true).
4445
Handle(func(ctx *zero.Ctx) {
4546
url := ctx.State["regex_matched"].([]string)[1]
4647
if !strings.HasPrefix(url, "http") {
@@ -51,7 +52,7 @@ func init() { // 插件主体
5152
}
5253
})
5354
// 有保护的随机图片
54-
engine.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).SetPriority(24).
55+
engine.OnFullMatch("随机图片", zero.OnlyGroup).SetBlock(true).
5556
Handle(func(ctx *zero.Ctx) {
5657
if limit.Load(ctx.Event.UserID).Acquire() {
5758
class, dhash, comment, _ := classify.Classify(randapi, true)
@@ -61,7 +62,7 @@ func init() { // 插件主体
6162
ctx.SendChain(message.Text("你太快啦!"))
6263
})
6364
// 直接随机图片,无r18保护,后果自负。如果出r18图可尽快通过发送"太涩了"撤回
64-
engine.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(24).
65+
engine.OnFullMatch("直接随机", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
6566
Handle(func(ctx *zero.Ctx) {
6667
if block {
6768
ctx.SendChain(message.Text("请稍后再试哦"))
@@ -78,7 +79,7 @@ func init() { // 插件主体
7879
}
7980
})
8081
// 撤回最后的直接随机图片
81-
engine.OnFullMatch("太涩了").SetBlock(true).SetPriority(24).
82+
engine.OnFullMatch("太涩了").SetBlock(true).
8283
Handle(func(ctx *zero.Ctx) {
8384
msg, ok := msgof[ctx.Event.GroupID]
8485
if ok {
@@ -87,7 +88,7 @@ func init() { // 插件主体
8788
}
8889
})
8990
// 上传一张图进行评价
90-
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).SetPriority(24).
91+
engine.OnKeywordGroup([]string{"评价图片"}, zero.OnlyGroup, picture.CmdMatch, picture.MustGiven).SetBlock(true).
9192
Handle(func(ctx *zero.Ctx) {
9293
ctx.SendChain(message.Text("少女祈祷中..."))
9394
for _, url := range ctx.State["image_url"].([]string) {
@@ -96,7 +97,7 @@ func init() { // 插件主体
9697
break
9798
}
9899
})
99-
engine.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).SetPriority(20).
100+
engine.OnRegex(`^给你点提示哦:(.*)$`, zero.OnlyPrivate).SetBlock(true).
100101
Handle(func(ctx *zero.Ctx) {
101102
dhash := ctx.State["regex_matched"].([]string)[1]
102103
if len(dhash) == 5*3 {

plugin_ai_false/ai_false.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"time"
99

10+
"github.com/FloatTech/ZeroBot-Plugin/order"
1011
control "github.com/FloatTech/zbputils/control"
1112
"github.com/shirou/gopsutil/v3/cpu"
1213
"github.com/shirou/gopsutil/v3/disk"
@@ -17,7 +18,7 @@ import (
1718
)
1819

1920
func init() { // 插件主体
20-
engine := control.Register("aifalse", &control.Options{
21+
engine := control.Register("aifalse", order.PrioAIFalse, &control.Options{
2122
DisableOnDefault: false,
2223
Help: "AIfalse\n" +
2324
"- 查询计算机当前活跃度: [检查身体|自检|启动自检|系统状态]",

plugin_ai_reply/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"time"
77

88
"github.com/FloatTech/AnimeAPI/aireply"
9+
"github.com/FloatTech/ZeroBot-Plugin/order"
910
control "github.com/FloatTech/zbputils/control"
1011
zero "github.com/wdvxdr1123/ZeroBot"
1112
"github.com/wdvxdr1123/ZeroBot/extension/rate"
@@ -14,20 +15,19 @@ import (
1415

1516
const (
1617
serviceName = "aireply"
17-
prio = 256
1818
)
1919

2020
var modes = [...]string{"青云客", "小爱"}
2121

2222
func init() { // 插件主体
2323
bucket := rate.NewManager(time.Minute, 20) // 接口回复限速器
24-
engine := control.Register(serviceName, &control.Options{
24+
engine := control.Register(serviceName, order.PrioAIReply, &control.Options{
2525
DisableOnDefault: false,
2626
Help: "人工智能回复\n" +
2727
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]\n- ",
2828
})
2929
// 回复 @和包括名字
30-
engine.OnMessage(zero.OnlyToMe).SetBlock(true).SetPriority(prio).
30+
engine.OnMessage(zero.OnlyToMe).SetBlock(true).
3131
Handle(func(ctx *zero.Ctx) {
3232
aireply := aireply.NewAIReply(getReplyMode(ctx))
3333
if !bucket.Load(ctx.Event.UserID).Acquire() {
@@ -44,7 +44,7 @@ func init() { // 插件主体
4444
}
4545
ctx.Send(reply)
4646
})
47-
engine.OnPrefix(`设置回复模式`).SetBlock(true).SetPriority(20).
47+
engine.OnPrefix(`设置回复模式`).SetBlock(true).
4848
Handle(func(ctx *zero.Ctx) {
4949
param := ctx.State["args"].(string)
5050
err := setReplyMode(ctx, param)

plugin_ai_reply/tts.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ import (
88

99
"github.com/FloatTech/AnimeAPI/aireply"
1010
"github.com/FloatTech/AnimeAPI/mockingbird"
11+
"github.com/FloatTech/ZeroBot-Plugin/order"
1112
control "github.com/FloatTech/zbputils/control"
1213
)
1314

14-
const ttsprio = 250
15-
1615
func init() {
1716
limit := rate.NewManager(time.Second*10, 1)
1817

19-
control.Register("mockingbird", &control.Options{
18+
control.Register("mockingbird", order.PrioMockingBird, &control.Options{
2019
DisableOnDefault: false,
2120
Help: "拟声鸟\n- @Bot 任意文本(任意一句话回复)",
2221
}).OnMessage(zero.OnlyToMe, func(ctx *zero.Ctx) bool {
2322
return limit.Load(ctx.Event.UserID).Acquire()
24-
}).SetBlock(true).SetPriority(ttsprio).
23+
}).SetBlock(true).
2524
Handle(func(ctx *zero.Ctx) {
2625
msg := ctx.ExtractPlainText()
2726
r := aireply.NewAIReply(getReplyMode(ctx))

plugin_aiwife/non-existent.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"math/rand"
77
"time"
88

9+
"github.com/FloatTech/ZeroBot-Plugin/order"
910
control "github.com/FloatTech/zbputils/control"
1011
zero "github.com/wdvxdr1123/ZeroBot"
1112
"github.com/wdvxdr1123/ZeroBot/message"
@@ -19,11 +20,11 @@ func init() { // 插件主体
1920
// TODO: 1.17 特性暂不增加
2021
// rand.Seed(time.Now().UnixMicro())
2122
rand.Seed(time.Now().UnixNano())
22-
control.Register("aiwife", &control.Options{
23+
control.Register("aiwife", order.PrioAIWife, &control.Options{
2324
DisableOnDefault: false,
2425
Help: "AIWife\n" +
2526
"- waifu|随机waifu",
26-
}).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10).SetBlock(true).
27+
}).OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetBlock(true).
2728
Handle(func(ctx *zero.Ctx) {
2829
miku := rand.Intn(100000) + 1
2930
ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku)))

0 commit comments

Comments
 (0)