Skip to content

Commit

Permalink
✏️ 修复缓存上限控制
Browse files Browse the repository at this point in the history
  • Loading branch information
kanrichan committed Jun 29, 2021
1 parent a4e2389 commit 04593e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugin_lolicon/lolicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ func init() {
Handle(func(ctx *zero.Ctx) {
go func() {
min := func(a, b int) int {
if a > b {
if a < b {
return a
} else {
return b
}
}
for i := 0; i < min(10-cap(QUEUE), 2); i++ {
for i := 0; i < min(cap(QUEUE)-len(QUEUE), 2); i++ {
resp, err := http.Get(API)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
ctx.SendChain(message.Text("ERROR: code ", resp.StatusCode))
}
data, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
json := gjson.ParseBytes(data)
if e := json.Get("error").Str; e != "" {
ctx.SendChain(message.Text("ERROR: ", e))
Expand Down

0 comments on commit 04593e2

Please sign in to comment.