Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion plugin_moyu_calendar/calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
20 changes: 14 additions & 6 deletions plugin_wordle/wordle.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var colors = [...]color.RGBA{
}

var words []string
var questions []string

func init() {
en := control.Register("wordle", order.AcquirePrio(), &control.Options{
Expand All @@ -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()
Expand All @@ -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]
Expand All @@ -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 {
Expand All @@ -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:
Expand Down