From 48442330c11fe1684c9a4b6c81e548f1f2dc161e Mon Sep 17 00:00:00 2001 From: fumiama Date: Mon, 27 Sep 2021 21:31:38 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20=E7=BE=8E=E5=8C=96=20lo?= =?UTF-8?q?g=20&=20=E6=9B=B4=E6=96=B0=20banner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 2 +- plugin_reborn/load.go | 35 ++++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/main.go b/main.go index 4fa316fa..98f33060 100644 --- a/main.go +++ b/main.go @@ -53,7 +53,7 @@ import ( var ( contents = []string{ "* OneBot + ZeroBot + Golang", - "* Version 1.1.5 - 2021-09-09 20:52:33 +0800 CST", + "* Version 1.1.6 - 2021-09-27 21:30:33 +0800 CST", "* Copyright © 2020 - 2021 Kanri, DawnNights, Fumiama, Suika", "* Project: https://github.com/FloatTech/ZeroBot-Plugin", } diff --git a/plugin_reborn/load.go b/plugin_reborn/load.go index b2f5975b..59a2c11a 100644 --- a/plugin_reborn/load.go +++ b/plugin_reborn/load.go @@ -3,11 +3,12 @@ package reborn import ( "encoding/json" "io" - "log" "net/http" "os" + "time" wr "github.com/mroth/weightedrand" + log "github.com/sirupsen/logrus" ) const ( @@ -26,20 +27,24 @@ var ( ) func init() { - area := make(rate, 226) - err := load(&area) - if err != nil { - panic(err) - } - choices := make([]wr.Choice, len(area)) - for i, a := range area { - choices[i].Item = a.Name - choices[i].Weight = uint(a.Weight * 1e9) - } - areac, err = wr.NewChooser(choices...) - if err != nil { - panic(err) - } + go func() { + time.Sleep(time.Second) + area := make(rate, 226) + err := load(&area) + if err != nil { + panic(err) + } + choices := make([]wr.Choice, len(area)) + for i, a := range area { + choices[i].Item = a.Name + choices[i].Weight = uint(a.Weight * 1e9) + } + areac, err = wr.NewChooser(choices...) + if err != nil { + panic(err) + } + log.Printf("[Reborn] 读取%d个国家/地区", len(area)) + }() } // load 加载rate数据