mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
add DoOnceOnSuccess
This commit is contained in:
parent
5b98ac86a8
commit
1afe660e81
@ -18,28 +18,16 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
cards = []string{}
|
cards = []string{}
|
||||||
re = regexp.MustCompile(`^\[(.*?)\](.*)\..*$`)
|
re = regexp.MustCompile(`^\[(.*?)\](.*) - P\d+\..*$`)
|
||||||
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
Help: "- 抽老婆",
|
Help: "- 抽老婆",
|
||||||
Brief: "从老婆库抽每日老婆",
|
Brief: "从老婆库抽每日老婆",
|
||||||
PublicDataFolder: "Wife",
|
PublicDataFolder: "Wife",
|
||||||
}).ApplySingle(ctxext.DefaultSingle)
|
}).ApplySingle(ctxext.DefaultSingle)
|
||||||
)
|
getJson = fcext.DoOnceOnSuccess(
|
||||||
|
|
||||||
func card2name(card string) (string, string) {
|
|
||||||
match := re.FindStringSubmatch(card)
|
|
||||||
if len(match) >= 3 {
|
|
||||||
return match[1], match[2]
|
|
||||||
}
|
|
||||||
return "", ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
_ = os.MkdirAll(engine.DataFolder()+"wives", 0755)
|
|
||||||
engine.OnFullMatch("抽老婆", fcext.DoOnceOnSuccess(
|
|
||||||
func(ctx *zero.Ctx) bool {
|
func(ctx *zero.Ctx) bool {
|
||||||
data, err := engine.GetLazyData("wife.json", true)
|
data, err := engine.GetLazyData("wife.json", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return false
|
return false
|
||||||
@ -52,7 +40,20 @@ func init() {
|
|||||||
logrus.Infof("[wife]加载%d个老婆", len(cards))
|
logrus.Infof("[wife]加载%d个老婆", len(cards))
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
)).SetBlock(true).
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
func card2name(card string) (string, string) {
|
||||||
|
match := re.FindStringSubmatch(card)
|
||||||
|
if len(match) >= 3 {
|
||||||
|
return match[1], match[2]
|
||||||
|
}
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
_ = os.MkdirAll(engine.DataFolder()+"wives", 0755)
|
||||||
|
engine.OnFullMatch("抽老婆", getJson).SetBlock(true).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
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)
|
||||||
|
|||||||
@ -29,7 +29,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
enguess.OnFullMatch("猜老婆").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
enguess.OnFullMatch("猜老婆", getJson).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||||
class := 3
|
class := 3
|
||||||
|
|
||||||
card := cards[rand.Intn(len(cards))]
|
card := cards[rand.Intn(len(cards))]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user