Skip to content

Commit aa67d09

Browse files
committed
feat(all): update to go1.24+
1 parent 724e48f commit aa67d09

File tree

25 files changed

+344
-861
lines changed

25 files changed

+344
-861
lines changed

.github/workflows/gomod2nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Go
1919
uses: actions/setup-go@master
2020
with:
21-
go-version: "1.20"
21+
go-version: "1.25"
2222

2323
- name: Check out code into the Go module directory
2424
uses: actions/checkout@master

.github/workflows/nightly.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Setup Go environment
3131
uses: actions/setup-go@master
3232
with:
33-
go-version: '1.20'
33+
go-version: '1.25'
3434
- name: Cache downloaded module
3535
uses: actions/cache@master
3636
continue-on-error: true
@@ -45,6 +45,7 @@ jobs:
4545
GOARCH: ${{ matrix.goarch }}
4646
IS_PR: ${{ !!github.head_ref }}
4747
run: |
48+
go generate ./...
4849
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
4950
if $IS_PR ; then echo $PR_PROMPT; fi
5051
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX"

.github/workflows/pull.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ jobs:
2626
- name: Set up Go
2727
uses: actions/setup-go@master
2828
with:
29-
go-version: '1.20'
29+
go-version: '1.25'
3030

3131
- name: Check out code into the Go module directory
3232
uses: actions/checkout@v4
3333
with:
3434
ref: ${{ github.event.pull_request.head.sha }}
3535

3636
- name: Tidy Modules
37-
run: go mod tidy
37+
run: |
38+
go mod tidy
39+
go generate ./...
3840
3941
- name: golangci-lint
4042
uses: golangci/golangci-lint-action@master

.github/workflows/push.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ jobs:
88
- name: Set up Go
99
uses: actions/setup-go@master
1010
with:
11-
go-version: '1.20'
11+
go-version: '1.25'
1212

1313
- name: Check out code into the Go module directory
1414
uses: actions/checkout@master
1515

1616
- name: Tidy Modules
17-
run: go mod tidy
17+
run: |
18+
go mod tidy
19+
go generate ./...
1820
1921
- name: Run Lint
2022
uses: golangci/golangci-lint-action@master

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@master
1818
with:
19-
go-version: '1.20'
19+
go-version: '1.25'
2020

2121
- name: Run GoReleaser
2222
uses: goreleaser/goreleaser-action@master

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ run:
5656
deadline: 5m
5757
issues-exit-code: 1
5858
tests: false
59-
go: '1.20'
59+
go: '1.25'
6060

6161
# output configuration options
6262
output:

.goreleaser.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ env:
44
before:
55
hooks:
66
- go mod tidy
7+
- go generate ./...
78
- go install github.com/tc-hib/go-winres@latest
89
- go-winres make
910
builds:

README.md

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,50 +1462,6 @@ print("run[CQ:image,file="+j["img"]+"]")
14621462

14631463
- [x] 每日特惠
14641464
</details>
1465-
<details>
1466-
<summary>百度文心AI</summary>
1467-
1468-
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wenxinAI"`
1469-
1470-
基于百度文心API的一些功能
1471-
1472-
key申请链接:https://wenxin.baidu.com/moduleApi/key
1473-
1474-
- [x][自己/本群/QQ号/群+群号]设置文心key [API Key] [Secret Key]
1475-
1476-
- [x][自己/本群/QQ号/群+群号]设置画图key [API Key] [Secret Key]
1477-
1478-
例:“为10086设置画图key 123 456”;“为群10010设置画图key 789 101”
1479-
1480-
文心key和画图key的API key 可以是相同的,只是文心key日限为200,画图日限为50,以此作区别。
1481-
1482-
- [x] 文心作文 (x字的)[作文题目]
1483-
1484-
- [x] 文心提案 (x字的)[文案标题]
1485-
1486-
- [x] 文心摘要 (x字的)[文章内容]
1487-
1488-
- [x] 文心小说 (x字的)[小说上文]
1489-
1490-
- [x] 文心对联 [上联]
1491-
1492-
- [x] 文心问答 [问题]
1493-
1494-
- [x] 文心补全 [带“_”的填空题]
1495-
1496-
- [x] 文心自定义 [prompt]
1497-
1498-
- [x] [bot名称]画几张[图片描述][图片类型][图片尺寸]
1499-
1500-
指令示例:
1501-
1502-
- 文心作文 我的椛椛机器人
1503-
1504-
- 文心作文 300字的我的椛椛机器人
1505-
1506-
- 椛椛帮我画几张金凤凰,背景绚烂,高饱和,古风,仙境,高清,4K,古风的油画方图
1507-
1508-
</details>
15091465
<details>
15101466
<summary>抽老婆</summary>
15111467

@@ -1549,27 +1505,27 @@ print("run[CQ:image,file="+j["img"]+"]")
15491505

15501506
</details>
15511507
<details>
1552-
<summary>一些游戏王插件</summary>
1508+
<summary>游戏王白鸽API卡查</summary>
1509+
1510+
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygocdb"`
15531511

1554-
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygo"`
1555-
1556-
##### 白鸽API卡查
1557-
1558-
###### `"github.com/FloatTech/ZeroBot-Plugin/plugin/ygo/ygocdb.go"`
15591512
- [x] /ydp [xxx]
15601513
- [x] /yds [xxx]
15611514
- [x] /ydb [xxx]
15621515
- 注:[xxx]为搜索内容;p:返回一张图片;s:返回一张效果描述;b:高级搜索
1563-
1564-
##### 集换社卡价查询
15651516

1566-
###### `"github.com/FloatTech/ZeroBot-Plugin/plugin/ygo/ygotrade.go"`
1517+
</details>
1518+
<details>
1519+
<summary>游戏王集换社卡价查询</summary>
1520+
1521+
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ygotrade"`
1522+
15671523
- [x] 查卡价 [卡名]
15681524
- [x] 查卡价 [卡名] -r [稀有度 稀有度 ...]
15691525
- [x] 查卡店 [卡名]
15701526
- [x] 查卡店 [卡名] -r [稀有度]
15711527
- 注:卡店只支持单个稀有度查询
1572-
1528+
15731529
</details>
15741530
<details>
15751531
<summary>月幕galgame图</summary>

abineundo/main.go

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
// Package abineundo provides an explicit "from the beginning" (Latin: "ab ineundō")
2+
// initialization anchor.
3+
//
4+
// Name origin:
5+
//
6+
// Latin phrase "ab ineundō" meaning "from which is to be begun".
7+
//
8+
// Purpose:
9+
//
10+
// Place this package at the very top of top-level main.go so its init (present
11+
// or future) executes before other plugin packages, filling in a predictable
12+
// plugin priority.
13+
//
14+
// Typical usage:
15+
//
16+
// import (
17+
// _ "github.com/your/module/abineundo" // priority anchor
18+
// // ... other imports ...
19+
// )
20+
//
21+
// A blank identifier import preserves ordering side-effects without expanding the
22+
// exported API surface.
23+
//
24+
// (No further code is required here; the package's presence alone defines ordering semantics.)
25+
package abineundo
26+
27+
import (
28+
"bufio"
29+
_ "embed"
30+
"regexp"
31+
"strings"
32+
33+
"github.com/FloatTech/zbputils/control"
34+
"github.com/sirupsen/logrus"
35+
)
36+
37+
//go:embed ref/main/main.go
38+
var maincode string
39+
40+
//go:embed ref/custom/register.go
41+
var customcode string
42+
43+
const (
44+
statusnone = iota
45+
statushigh
46+
statushighend
47+
statusmid
48+
statusmidend
49+
statuslow
50+
statuslowend
51+
)
52+
53+
var (
54+
priore = regexp.MustCompile(`^\t// -{28}(高|中|低)优先级区-{28} //$`)
55+
mainpluginre = regexp.MustCompile(`^\t_ "github\.com/FloatTech/ZeroBot-Plugin/plugin/(\w+)"\s+// `)
56+
custpluginre = regexp.MustCompile(`^\t_ "github\.com/FloatTech/ZeroBot-Plugin/custom/plugin/(\w+)"\s+// `)
57+
)
58+
59+
func init() {
60+
highprios := make([]string, 0, 64)
61+
midprios := make([]string, 0, 64)
62+
lowprios := make([]string, 0, 64)
63+
64+
status := statusnone
65+
scanner := bufio.NewScanner(strings.NewReader(maincode))
66+
for scanner.Scan() {
67+
line := scanner.Text()
68+
69+
prioword := ""
70+
match := priore.FindStringSubmatch(line)
71+
if len(match) > 1 {
72+
prioword = match[1]
73+
}
74+
switch prioword {
75+
case "高":
76+
switch status {
77+
case statusnone:
78+
status = statushigh
79+
case statushigh:
80+
status = statushighend
81+
default:
82+
panic("unexpected")
83+
}
84+
case "中":
85+
switch status {
86+
case statushighend:
87+
status = statusmid
88+
case statusmid:
89+
status = statusmidend
90+
default:
91+
panic("unexpected")
92+
}
93+
case "低":
94+
switch status {
95+
case statusmidend:
96+
status = statuslow
97+
case statuslow:
98+
status = statuslowend
99+
default:
100+
panic("unexpected")
101+
}
102+
default:
103+
switch status {
104+
case statusnone: // 还未开始匹配
105+
continue
106+
case statuslowend: // 匹配已结束
107+
break
108+
default: // 继续匹配插件
109+
}
110+
}
111+
112+
// 在对应优先级区域内匹配插件
113+
if matches := mainpluginre.FindStringSubmatch(line); len(matches) > 1 {
114+
name := matches[1]
115+
switch status {
116+
case statushigh:
117+
highprios = append(highprios, name)
118+
case statusmid:
119+
midprios = append(midprios, name)
120+
case statuslow:
121+
lowprios = append(lowprios, name)
122+
default: // 在不该匹配到插件的区域匹配到
123+
panic("unexpected")
124+
}
125+
}
126+
}
127+
128+
custprios := make([]string, 0, 64)
129+
130+
scanner = bufio.NewScanner(strings.NewReader(customcode))
131+
for scanner.Scan() {
132+
line := scanner.Text()
133+
134+
if matches := custpluginre.FindStringSubmatch(line); len(matches) > 1 {
135+
custprios = append(custprios, matches[1])
136+
}
137+
}
138+
139+
// 生成最终插件优先级表
140+
m := make(map[string]uint64, 4*(len(highprios)+len(midprios)+len(lowprios)+len(custprios)))
141+
i := 0
142+
for _, name := range highprios {
143+
m[name] = (uint64(i) + 1) * 10
144+
logrus.Debugln("[ab] set high plugin", name, "prio to", m[name])
145+
i++
146+
}
147+
for _, name := range custprios {
148+
m[name] = (uint64(i) + 1) * 10
149+
logrus.Debugln("[ab] set cust plugin", name, "prio to", m[name])
150+
i++
151+
}
152+
for _, name := range midprios {
153+
m[name] = (uint64(i) + 1) * 10
154+
logrus.Debugln("[ab] set mid plugin", name, "prio to", m[name])
155+
i++
156+
}
157+
for _, name := range lowprios {
158+
m[name] = (uint64(i) + 1) * 10
159+
logrus.Debugln("[ab] set low plugin", name, "prio to", m[name])
160+
i++
161+
}
162+
163+
control.LoadCustomPriority(m)
164+
}

abineundo/ref/custom/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!.gitignore
2+
*

0 commit comments

Comments
 (0)