避免伪随机

This commit is contained in:
fumiama 2021-06-17 00:21:25 +08:00
parent 4bd2d8f8c5
commit 3d3da9a495

View File

@ -5,6 +5,7 @@ import (
"math/rand" "math/rand"
"strconv" "strconv"
"strings" "strings"
"time"
timer "github.com/fumiama/ZeroBot-Plugin-Timer" timer "github.com/fumiama/ZeroBot-Plugin-Timer"
zero "github.com/wdvxdr1123/ZeroBot" zero "github.com/wdvxdr1123/ZeroBot"
@ -269,6 +270,7 @@ func init() { // 插件主体
Handle(func(ctx *zero.Ctx) { Handle(func(ctx *zero.Ctx) {
if ctx.Event.GroupID > 0 { if ctx.Event.GroupID > 0 {
list := ctx.GetGroupMemberList(ctx.Event.GroupID) list := ctx.GetGroupMemberList(ctx.Event.GroupID)
rand.Seed(time.Now().UnixNano())
rand_index := fmt.Sprint(rand.Intn(int(list.Get("#").Int()))) rand_index := fmt.Sprint(rand.Intn(int(list.Get("#").Int())))
random_card := list.Get(rand_index + ".card").String() random_card := list.Get(rand_index + ".card").String()
if random_card == "" { if random_card == "" {