Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xyy0411 authored Oct 13, 2024
1 parent ed33c5e commit 9a0f6a1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions plugin/niuniu/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math"
"math/rand"
"strings"
"time"
)

var (
Expand Down Expand Up @@ -215,3 +216,35 @@ func contains(s string, array []string) bool {
}
return false
}

func randomChoice(options []string) string {
return options[rand.Intn(len(options))]
}

func updateMap(t string, d bool) {
value, ok := prop.Load(t)
if value == nil {
return
}
// 检查一次是否已经过期
if !d {
if time.Since(value.TimeLimit) > time.Minute*8 {
prop.Delete(t)
}
return
}
if ok {
prop.Store(t, &propsCount{
Count: value.Count + 1,
TimeLimit: value.TimeLimit,
})
} else {
prop.Store(t, &propsCount{
Count: 1,
TimeLimit: time.Now(),
})
}
if time.Since(value.TimeLimit) > time.Minute*8 {
prop.Delete(t)
}
}

0 comments on commit 9a0f6a1

Please sign in to comment.