mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-23 09:40:04 +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"
|
"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() {
|
func init() {
|
||||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
@ -46,22 +56,20 @@ func init() {
|
|||||||
card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))]
|
card := cards[fcext.RandSenderPerDayN(ctx.Event.UserID, len(cards))]
|
||||||
data, err := engine.GetLazyData("wives/"+card, true)
|
data, err := engine.GetLazyData("wives/"+card, true)
|
||||||
card, _, _ = strings.Cut(card, ".")
|
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
|
var msgText string
|
||||||
if len(match) == 3 {
|
work, name := card2name(card)
|
||||||
work, name := match[1], match[2]
|
if work != "" && name != "" {
|
||||||
msgText = fmt.Sprintf("今天的二次元老婆是~来自【%s】的【%s】哒", work, name)
|
msgText = fmt.Sprintf("今天的二次元老婆是~来自【%s】的【%s】哒", work, name)
|
||||||
} else {
|
} else {
|
||||||
msgText = fmt.Sprintf("今天的二次元老婆是~【%s】哒", card)
|
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(
|
if id := ctx.SendChain(
|
||||||
message.At(ctx.Event.UserID),
|
message.At(ctx.Event.UserID),
|
||||||
message.Text(msgText),
|
message.Text(msgText),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user