Skip to content

Commit 941d6d2

Browse files
authored
feat: 抽塔罗牌附加解析 (#383)
1 parent 169af4c commit 941d6d2

File tree

6 files changed

+79
-110
lines changed

6 files changed

+79
-110
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,6 @@ print("run[CQ:image,file="+j["img"]+"]")
493493

494494
- [x] 教你一篇小作文[作文]
495495

496-
- [x] [回复]查重
497-
498496
</details>
499497
<details>
500498
<summary>漂流瓶</summary>

plugin/diana/bing.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ var engine = control.Register("diana", &ctrl.Options[*zero.Ctx]{
1717
Help: "嘉然\n" +
1818
"- 小作文\n" +
1919
"- 发大病\n" +
20-
"- 教你一篇小作文[作文]\n" +
21-
"- [回复]查重",
20+
"- 教你一篇小作文[作文]",
2221
PublicDataFolder: "Diana",
2322
})
2423

plugin/diana/zhiwang.go

Lines changed: 0 additions & 89 deletions
This file was deleted.

plugin/gif/gif.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package gif
22

33
import (
4+
"errors"
45
"image"
56
"image/color"
67
"sync"
78

89
"github.com/Coloured-glaze/gg"
10+
"github.com/FloatTech/floatbox/file"
911
"github.com/FloatTech/floatbox/img/writer"
1012
"github.com/FloatTech/zbputils/img"
13+
"github.com/FloatTech/zbputils/img/text"
1114
)
1215

1316
// mo 摸
@@ -1394,3 +1397,52 @@ func whirl(cc *context, value ...string) (string, error) {
13941397
}
13951398
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, whirl))
13961399
}
1400+
1401+
// always 一直
1402+
func alwaysDoGif(cc *context, value ...string) (string, error) {
1403+
_ = value
1404+
var err error
1405+
var face []*image.NRGBA
1406+
name := cc.usrdir + "AlwaysDo.gif"
1407+
face, err = img.LoadAllFrames(cc.headimgsdir[0], 500, 500)
1408+
if err != nil {
1409+
// 载入失败尝试载入第一帧
1410+
face = make([]*image.NRGBA, 0)
1411+
first, err := img.LoadFirstFrame(cc.headimgsdir[0], 500, 500)
1412+
if err != nil {
1413+
return "", err
1414+
}
1415+
face = append(face, first.Im)
1416+
}
1417+
canvas := gg.NewContext(500, 600)
1418+
canvas.SetColor(color.Black)
1419+
_, err = file.GetLazyData(text.BoldFontFile, true)
1420+
if err != nil {
1421+
return "", err
1422+
}
1423+
err = canvas.LoadFontFace(text.BoldFontFile, 40)
1424+
if err != nil {
1425+
return "", err
1426+
}
1427+
length := len(face)
1428+
if length > 50 {
1429+
length = 50
1430+
}
1431+
arg := "要我一直"
1432+
l, _ := canvas.MeasureString(arg)
1433+
if l > 500 {
1434+
return "", errors.New("文字消息太长了")
1435+
}
1436+
turn := make([]*image.NRGBA, length)
1437+
for i, f := range face {
1438+
canvas := gg.NewContext(500, 600)
1439+
canvas.DrawImage(f, 0, 0)
1440+
canvas.SetColor(color.Black)
1441+
_ = canvas.LoadFontFace(text.BoldFontFile, 40)
1442+
canvas.DrawString(arg, 280-l, 560)
1443+
canvas.DrawImage(img.Size(f, 90, 90).Im, 280, 505)
1444+
canvas.DrawString("吗", 370, 560)
1445+
turn[i] = img.Size(canvas.Image(), 0, 0).Im
1446+
}
1447+
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, turn))
1448+
}

plugin/gif/run.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ var (
118118
"我老婆": nowife,
119119
"远离": yuanli,
120120
"抬棺": taiguan,
121+
"一直": alwaysDoGif,
121122
}
122123
)
123124

@@ -140,7 +141,7 @@ func init() { // 插件主体
140141
"- 抬棺|- 远离|- 我老婆|- 小天使XXX|- 你的XXX|- 不要看\n" +
141142
"- 玩一下XXX|- 给我变|- 揍|- 吞|- 膜拜|- 诶嘿|- 2蹭|- 你犯法了\n" +
142143
"- 砰|- 注意力涣散|- 蒙蔽|- 踩|- 好玩|- 2转|- 踢球|- 2舔|\n" +
143-
"- 可莉吃|- 胡桃啃|- 怀",
144+
"- 可莉吃|- 胡桃啃|- 怀|- 一直(支持动图)",
144145
PrivateDataFolder: "gif",
145146
}).ApplySingle(ctxext.DefaultSingle)
146147
datapath = file.BOTPATH + "/" + en.DataFolder()

plugin/tarot/tarot.go

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package tarot
33

44
import (
55
"encoding/json"
6-
"fmt"
76
"math/rand"
87
"strconv"
98
"strings"
@@ -71,7 +70,6 @@ func init() {
7170
infoMap[card.Name] = card.cardInfo
7271
}
7372
for i := 0; i < 22; i++ {
74-
// 噢天哪,我应该把json里面序号设成int
7573
majorArcanaName = append(majorArcanaName, cardMap[strconv.Itoa(i)].Name)
7674
}
7775
logrus.Infof("[tarot]读取%d张塔罗牌", len(cardMap))
@@ -95,9 +93,9 @@ func init() {
9593
match := ctx.State["regex_matched"].([]string)[1]
9694
cardType := ctx.State["regex_matched"].([]string)[2]
9795
n := 1
98-
reasons := [...]string{"您抽到的是~\n", "锵锵锵,塔罗牌的预言是~\n", "诶,让我看看您抽到了~\n"}
99-
position := [...]string{"正位", "逆位"}
100-
reverse := [...]string{"", "Reverse"}
96+
reasons := [...]string{"您抽到的是~\n", "锵锵锵,塔罗牌的预言是~\n", "诶,让我看看您抽到了~\n"}
97+
position := [...]string{"『正位』", "『逆位』"}
98+
reverse := [...]string{"", "Reverse/"}
10199
start := 0
102100
length := 22
103101
if match != "" {
@@ -129,9 +127,14 @@ func init() {
129127
p := rand.Intn(2)
130128
card := cardMap[strconv.Itoa(i)]
131129
name := card.Name
130+
description := card.Description
131+
if p == 1 {
132+
description = card.ReverseDescription
133+
}
132134
if id := ctx.SendChain(
133-
message.Text(reasons[rand.Intn(len(reasons))], position[p], "』的『", name, "』\n"),
134-
message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))); id.ID() == 0 {
135+
message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n"),
136+
message.Image(bed+reverse[p]+card.ImgURL),
137+
message.Text("\n其释义为: ", description)); id.ID() == 0 {
135138
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
136139
}
137140
return
@@ -149,9 +152,14 @@ func init() {
149152
p := rand.Intn(2)
150153
card := cardMap[strconv.Itoa(j+start)]
151154
name := card.Name
155+
description := card.Description
156+
if p == 1 {
157+
description = card.ReverseDescription
158+
}
152159
tarotMsg := []message.MessageSegment{
153-
message.Text(reasons[rand.Intn(len(reasons))], position[p], "』的『", name, "』\n"),
154-
message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))}
160+
message.Text(position[p], "的『", name, "』\n"),
161+
message.Image(bed + reverse[p] + card.ImgURL),
162+
message.Text("\n其释义为: ", description)}
155163
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotMsg...)
156164
}
157165
ctx.SendGroupForwardMessage(ctx.Event.GroupID, msg)
@@ -164,8 +172,8 @@ func init() {
164172
ctx.SendChain(
165173
message.Image(bed+info.ImgURL),
166174
message.Text("\n", match, "的含义是~"),
167-
message.Text("\n正位:", info.Description),
168-
message.Text("\n逆位:", info.ReverseDescription))
175+
message.Text("\n『正位』:", info.Description),
176+
message.Text("\n『逆位』:", info.ReverseDescription))
169177
} else {
170178
var build strings.Builder
171179
build.WriteString("塔罗牌列表\n大阿尔卡纳:\n")
@@ -188,8 +196,8 @@ func init() {
188196
cardType := ctx.State["regex_matched"].([]string)[1]
189197
match := ctx.State["regex_matched"].([]string)[5]
190198
info, ok := formationMap[match]
191-
position := [...]string{"正位", "逆位"}
192-
reverse := [...]string{"", "Reverse"}
199+
position := [...]string{"『正位』", "『逆位』"}
200+
reverse := [...]string{"", "Reverse/"}
193201
start, length := 0, 22
194202
if strings.Contains(cardType, "小") {
195203
start = 22
@@ -222,11 +230,11 @@ func init() {
222230
if p == 1 {
223231
description = card.ReverseDescription
224232
}
225-
tarotMsg := []message.MessageSegment{message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))}
233+
tarotMsg := []message.MessageSegment{message.Image(bed + reverse[p] + card.ImgURL)}
226234
build.WriteString(info.Represent[0][i])
227-
build.WriteString(":")
235+
build.WriteString(":")
228236
build.WriteString(position[p])
229-
build.WriteString("的『")
237+
build.WriteString("的『")
230238
build.WriteString(name)
231239
build.WriteString("』\n其释义为: \n")
232240
build.WriteString(description)

0 commit comments

Comments
 (0)