mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-21 15:30:09 +08:00
✏️ 修复一下碧油鸡 (#136)
This commit is contained in:
parent
ba2d011d48
commit
7ec7ab8682
@ -28,7 +28,14 @@ func init() {
|
||||
Help: "摸鱼人日历\n" +
|
||||
"- /启用 moyucalendar\n" +
|
||||
"- /禁用 moyucalendar",
|
||||
})
|
||||
}).OnFullMatch("摸鱼人日历").SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
image, err := crew()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
ctx.SendChain(message.Image(image))
|
||||
})
|
||||
|
||||
// 定时任务每天8点执行一次
|
||||
_, err := process.CronTab.AddFunc("* 8 * * *", func() {
|
||||
|
||||
@ -41,6 +41,7 @@ var colors = [...]color.RGBA{
|
||||
}
|
||||
|
||||
var words []string
|
||||
var questions []string
|
||||
|
||||
func init() {
|
||||
en := control.Register("wordle", order.AcquirePrio(), &control.Options{
|
||||
@ -60,11 +61,20 @@ func init() {
|
||||
}),
|
||||
))
|
||||
go func() {
|
||||
data, err := file.GetLazyData(en.DataFolder()+"words.bin", true, true)
|
||||
questionsdata, err := file.GetLazyData(en.DataFolder()+"questions.bin", true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
wordpacks := loadwords(data)
|
||||
questionspacks := loadwords(questionsdata)
|
||||
questions = make([]string, len(questionspacks))
|
||||
for i := range questionspacks {
|
||||
questions[i] = questionspacks[i].String()
|
||||
}
|
||||
wordsdata, err := file.GetLazyData(en.DataFolder()+"words.bin", true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
wordpacks := loadwords(wordsdata)
|
||||
words = make([]string, len(wordpacks))
|
||||
for i := range wordpacks {
|
||||
words[i] = wordpacks[i].String()
|
||||
@ -73,7 +83,7 @@ func init() {
|
||||
}()
|
||||
en.OnRegex(`(个人|团队)猜单词`, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
target := words[rand.Intn(len(words))]
|
||||
target := questions[rand.Intn(len(questions))]
|
||||
game := newWordleGame(target)
|
||||
_, img, cl, _ := game("")
|
||||
typ := ctx.State["regex_matched"].([]string)[1]
|
||||
@ -90,8 +100,6 @@ func init() {
|
||||
} else {
|
||||
next = zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^[A-Z]{5}$|^[a-z]{5}$`), zero.OnlyGroup, zero.CheckGroup(ctx.Event.GroupID))
|
||||
}
|
||||
recv, cancel := next.Repeat()
|
||||
defer cancel()
|
||||
var win bool
|
||||
var err error
|
||||
for {
|
||||
@ -103,7 +111,7 @@ func init() {
|
||||
),
|
||||
)
|
||||
return
|
||||
case e := <-recv:
|
||||
case e := <-next.Next():
|
||||
win, img, cl, err = game(e.Message.String())
|
||||
switch {
|
||||
case win:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user