Files
go-bot-dongl/controller/roll.go

34 lines
877 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package controller
import (
"fmt"
"math/rand"
"strings"
"time"
"github.com/eatmoreapple/openwechat"
)
func Roll(msg *openwechat.Message, self *openwechat.Self) {
randomText := []string{
"转动命运的齿轮,拨开眼前迷雾...",
fmt.Sprintf("启动吧,命运的水晶球,为%s指引方向", self.NickName),
fmt.Sprintf("在此祈愿,请为%s降下指引...", self.NickName),
}
answerText := []string{
"让我们来看看是什么结果!答案是:'%s'",
"根据命运的指引,接下来 '%s' 会比较好",
"祈愿被回应了!是 '%s'",
"结束了,命运之轮停在了 '%s'",
}
choices := strings.Split(msg.Content, " ")[1:]
msg.ReplyText(randomText[rand.Intn(len(randomText))])
time.Sleep(1 * time.Second)
msg.ReplyText(fmt.Sprintf(answerText[rand.Intn(len(answerText))], choices[rand.Intn(len(choices))]))
}