|
|
@ -14,19 +14,20 @@ import (
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/Flashfyre/pokerogue-server/db"
|
|
|
|
"github.com/Flashfyre/pokerogue-server/db"
|
|
|
|
|
|
|
|
"github.com/go-co-op/gocron"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const secondsPerDay = 60 * 60 * 24
|
|
|
|
const secondsPerDay = 60 * 60 * 24
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
|
|
|
|
dailyRunScheduler = gocron.NewScheduler(time.UTC)
|
|
|
|
dailyRunSecret []byte
|
|
|
|
dailyRunSecret []byte
|
|
|
|
dailyRunSeed string
|
|
|
|
dailyRunSeed string
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func ScheduleDailyRunRefresh() {
|
|
|
|
func ScheduleDailyRunRefresh() {
|
|
|
|
scheduler.Every(1).Day().At("00:00").Do(func() {
|
|
|
|
dailyRunScheduler.Every(1).Day().At("00:00").Do(InitDailyRun)
|
|
|
|
InitDailyRun()
|
|
|
|
dailyRunScheduler.StartAsync()
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func InitDailyRun() {
|
|
|
|
func InitDailyRun() {
|
|
|
@ -57,9 +58,8 @@ func InitDailyRun() {
|
|
|
|
err = db.TryAddDailyRun(dailyRunSeed)
|
|
|
|
err = db.TryAddDailyRun(dailyRunSeed)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err.Error())
|
|
|
|
log.Print(err.Error())
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.Printf("Daily Run Seed: %s", dailyRunSeed)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("Daily Run Seed: %s", dailyRunSeed)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DeriveDailyRunSeed(seedTime time.Time) []byte {
|
|
|
|
func DeriveDailyRunSeed(seedTime time.Time) []byte {
|
|
|
|