update wife

- 增加角色作品名
This commit is contained in:
shudorcl 2025-09-18 16:07:01 +08:00
parent b9250ab82d
commit 8fb25210dd
2 changed files with 14 additions and 3 deletions

2
data

@ -1 +1 @@
Subproject commit 328d7638e6947e8ac1bc8d3f5ecd6a351a4a3b6f Subproject commit 2b10767f59a1661d81827c42ef9181223b4cfd78

View File

@ -3,7 +3,9 @@ package wife
import ( import (
"encoding/json" "encoding/json"
"fmt"
"os" "os"
"regexp"
"strings" "strings"
fcext "github.com/FloatTech/floatbox/ctxext" fcext "github.com/FloatTech/floatbox/ctxext"
@ -51,14 +53,23 @@ func init() {
) )
return return
} }
re := regexp.MustCompile(`^\[(.*?)\](.*)\..*$`)
match := re.FindStringSubmatch(card)
var msgText string
if len(match) == 3 {
work, name := match[1], match[2]
msgText = fmt.Sprintf("今天的二次元老婆是~来自【%s】的【%s】哒", work, name)
} else {
msgText = fmt.Sprintf("今天的二次元老婆是~【%s】哒", card)
}
if id := ctx.SendChain( if id := ctx.SendChain(
message.At(ctx.Event.UserID), message.At(ctx.Event.UserID),
message.Text("今天的二次元老婆是~【", card, "】哒"), message.Text(msgText),
message.ImageBytes(data), message.ImageBytes(data),
); id.ID() == 0 { ); id.ID() == 0 {
ctx.SendChain( ctx.SendChain(
message.At(ctx.Event.UserID), message.At(ctx.Event.UserID),
message.Text("今天的二次元老婆是~【", card, "】哒\n【图片发送失败, 请联系维护者】"), message.Text(msgText, "\n【图片发送失败, 多半是被夹了,请联系维护者】"),
) )
} }
}) })