mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
feat:将牌阵结果解析纳入转发列表 (#359)
This commit is contained in:
parent
e9a8b99f4f
commit
0e29010897
@ -41,8 +41,8 @@ var cardMap = make(cardSet, 80)
|
||||
var infoMap = make(map[string]cardInfo, 80)
|
||||
var formationMap = make(map[string]formation, 10)
|
||||
|
||||
// var cardName = make([]string, 30)
|
||||
var formationName = make([]string, 10)
|
||||
var majorArcanaName = make([]string, 0, 80)
|
||||
var formationName = make([]string, 0, 10)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("tarot", &ctrl.Options[*zero.Ctx]{
|
||||
@ -68,8 +68,10 @@ func init() {
|
||||
}
|
||||
for _, card := range cardMap {
|
||||
infoMap[card.Name] = card.cardInfo
|
||||
// 可以拿来显示塔罗牌列表
|
||||
// cardName = append(cardName, card.Name)
|
||||
}
|
||||
for i := 0; i < 22; i++ {
|
||||
// 噢天哪,我应该把json里面序号设成int
|
||||
majorArcanaName = append(majorArcanaName, cardMap[strconv.Itoa(i)].Name)
|
||||
}
|
||||
logrus.Infof("[tarot]读取%d张塔罗牌", len(cardMap))
|
||||
formation, err := engine.GetLazyData("formation.json", true)
|
||||
@ -92,7 +94,7 @@ func init() {
|
||||
match := ctx.State["regex_matched"].([]string)[1]
|
||||
cardType := ctx.State["regex_matched"].([]string)[2]
|
||||
n := 1
|
||||
reasons := [...]string{"您抽到的是~\n", "锵锵锵,塔罗牌的预言是~\n", "诶,让我看看您抽到了~\n"}
|
||||
reasons := [...]string{"您抽到的是~\n『", "锵锵锵,塔罗牌的预言是~\n『", "诶,让我看看您抽到了~\n『"}
|
||||
position := [...]string{"正位", "逆位"}
|
||||
reverse := [...]string{"", "Reverse"}
|
||||
start := 0
|
||||
@ -124,10 +126,10 @@ func init() {
|
||||
if n == 1 {
|
||||
i := rand.Intn(length) + start
|
||||
p := rand.Intn(2)
|
||||
card := cardMap[(strconv.Itoa(i))]
|
||||
card := cardMap[strconv.Itoa(i)]
|
||||
name := card.Name
|
||||
if id := ctx.SendChain(
|
||||
message.Text(reasons[rand.Intn(len(reasons))], position[p], " 的 ", name, "\n"),
|
||||
message.Text(reasons[rand.Intn(len(reasons))], position[p], "』的『", name, "』\n"),
|
||||
message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
}
|
||||
@ -144,10 +146,10 @@ func init() {
|
||||
}
|
||||
randomIntMap[j] = 0
|
||||
p := rand.Intn(2)
|
||||
card := cardMap[(strconv.Itoa(j + start))]
|
||||
card := cardMap[strconv.Itoa(j+start)]
|
||||
name := card.Name
|
||||
tarotMsg := []message.MessageSegment{
|
||||
message.Text(reasons[rand.Intn(len(reasons))], position[p], " 的 ", name, "\n"),
|
||||
message.Text(reasons[rand.Intn(len(reasons))], position[p], "』的『", name, "』\n"),
|
||||
message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))}
|
||||
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotMsg...)
|
||||
}
|
||||
@ -164,7 +166,21 @@ func init() {
|
||||
message.Text("\n正位:", info.Description),
|
||||
message.Text("\n逆位:", info.ReverseDescription))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"))
|
||||
var build strings.Builder
|
||||
build.WriteString("塔罗牌列表\n大阿尔卡纳:\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[:7], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[7:14], " "))
|
||||
build.WriteString("\n")
|
||||
build.WriteString(strings.Join(majorArcanaName[14:22], " "))
|
||||
build.WriteString("\n小阿尔卡纳:\n[圣杯|星币|宝剑|权杖] [0-10|侍从|骑士|王后|国王]")
|
||||
txt := build.String()
|
||||
cardList, err := text.RenderToBase64(txt, text.FontFile, 420, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"))
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
}
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"), message.Image("base64://"+binary.BytesToString(cardList)))
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^((塔罗|大阿(尔)?卡纳)|小阿(尔)?卡纳|混合)牌阵\s?(.*)`, getTarot).SetBlock(true).Limit(ctxext.LimitByGroup).Handle(func(ctx *zero.Ctx) {
|
||||
@ -182,12 +198,15 @@ func init() {
|
||||
length = 77
|
||||
}
|
||||
if ok {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
var build strings.Builder
|
||||
build.WriteString(ctx.CardOrNickName(ctx.Event.UserID))
|
||||
build.WriteString("---")
|
||||
build.WriteString(match)
|
||||
build.WriteString("\n")
|
||||
msg := make([]message.MessageSegment, info.CardsNum)
|
||||
msg := make([]message.MessageSegment, info.CardsNum+1)
|
||||
randomIntMap := make(map[int]int, 30)
|
||||
for i := range msg {
|
||||
for i := 0; i < info.CardsNum; i++ {
|
||||
j := rand.Intn(length)
|
||||
_, ok := randomIntMap[j]
|
||||
for ok {
|
||||
@ -196,14 +215,20 @@ func init() {
|
||||
}
|
||||
randomIntMap[j] = 0
|
||||
p := rand.Intn(2)
|
||||
card := cardMap[(strconv.Itoa(j + start))]
|
||||
card := cardMap[strconv.Itoa(j+start)]
|
||||
name := card.Name
|
||||
description := card.Description
|
||||
if p == 1 {
|
||||
description = card.ReverseDescription
|
||||
}
|
||||
tarotMsg := []message.MessageSegment{message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))}
|
||||
build.WriteString(info.Represent[0][i])
|
||||
build.WriteString(": ")
|
||||
build.WriteString(":『")
|
||||
build.WriteString(position[p])
|
||||
build.WriteString(" 的 ")
|
||||
build.WriteString("』的『")
|
||||
build.WriteString(name)
|
||||
build.WriteString("』\n其释义为: \n")
|
||||
build.WriteString(description)
|
||||
build.WriteString("\n")
|
||||
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotMsg...)
|
||||
}
|
||||
@ -213,11 +238,10 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
// TODO 视gocq变化将牌阵信息加入转发列表中
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(formation)))
|
||||
msg[info.CardsNum] = ctxext.FakeSenderForwardNode(ctx, []message.MessageSegment{message.Image("base64://" + binary.BytesToString(formation))}...)
|
||||
ctx.SendGroupForwardMessage(ctx.Event.GroupID, msg)
|
||||
} else {
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~\n现有牌阵列表: ", strings.Join(formationName, " ")))
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~\n现有牌阵列表: \n", strings.Join(formationName, "\n")))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user