随机函数

This commit is contained in:
Suika 2021-06-27 03:42:48 +08:00 committed by GitHub
parent f0abb9352d
commit bf92ab9f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

18
utils/random.go Normal file
View File

@ -0,0 +1,18 @@
package utils
import (
"github.com/wdvxdr1123/ZeroBot/message"
"math/rand"
"time"
)
func RandText(text ...[]string) message.MessageSegment {
length := len(text)
rand.Seed(time.Now().UnixNano())
return message.Text(text[rand.Intn(length)])
}
func Suiji() int {
rand.Seed(time.Now().UnixNano())
return rand.Intn(30)
}