mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-23 01:36:36 +08:00
update wife data & update wife\main.go
This commit is contained in:
parent
8fb25210dd
commit
7c0d0b4874
2
data
2
data
@ -1 +1 @@
|
||||
Subproject commit 2b10767f59a1661d81827c42ef9181223b4cfd78
|
||||
Subproject commit c1878300e9c20a6f5649372d565d8f4868020595
|
||||
@ -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),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user