update wife data & update wife\main.go

This commit is contained in:
shudorcl 2025-09-18 17:27:38 +08:00
parent 8fb25210dd
commit 7c0d0b4874
2 changed files with 20 additions and 12 deletions

2
data

@ -1 +1 @@
Subproject commit 2b10767f59a1661d81827c42ef9181223b4cfd78
Subproject commit c1878300e9c20a6f5649372d565d8f4868020595

View File

@ -17,6 +17,16 @@ import (
"github.com/wdvxdr1123/ZeroBot/message"
)
var re = regexp.MustCompile(`^\[(.*?)\](.*)\..*$`)
func card2name(card string) (string, string) {
match := re.FindStringSubmatch(card)
if len(match) >= 3 {
return match[1], match[2]
}
return "", ""
}
func init() {
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
DisableOnDefault: false,
@ -46,22 +56,20 @@ func init() {
card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))]
data, err := engine.GetLazyData("wives/"+card, true)
card, _, _ = strings.Cut(card, ".")
if err != nil {
ctx.SendChain(
message.At(ctx.Event.UserID),
message.Text("今天的二次元老婆是~【", card, "】哒\n【图片下载失败: ", err, "】"),
)
return
}
re := regexp.MustCompile(`^\[(.*?)\](.*)\..*$`)
match := re.FindStringSubmatch(card)
var msgText string
if len(match) == 3 {
work, name := match[1], match[2]
work, name := card2name(card)
if work != "" && name != "" {
msgText = fmt.Sprintf("今天的二次元老婆是~来自【%s】的【%s】哒", work, name)
} else {
msgText = fmt.Sprintf("今天的二次元老婆是~【%s】哒", card)
}
if err != nil {
ctx.SendChain(
message.At(ctx.Event.UserID),
message.Text(msgText, "\n【图片下载失败: ", err, "】"),
)
return
}
if id := ctx.SendChain(
message.At(ctx.Event.UserID),
message.Text(msgText),