-
Notifications
You must be signed in to change notification settings - Fork 2k
将电影查询移至主仓库 #1155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
将电影查询移至主仓库 #1155
Conversation
Changes by create-pull-request action
Changes by create-pull-request action
plugin/movies/main.go
Outdated
var ( | ||
mu sync.RWMutex | ||
todayPic = ttl.NewCache[uint64, []byte](time.Hour * 12) | ||
en = control.Register("movies", &ctrl.Options[*zero.Ctx]{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AutoRegister
plugin/movies/main.go
Outdated
|
||
var ( | ||
mu sync.RWMutex | ||
todayPic = ttl.NewCache[uint64, []byte](time.Hour * 12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你有没有想过每次get都会刷新cache时间,如果12小时内有一个人查询,这个缓存就会再延续12小时。这里不适合用cache。
plugin/movies/main.go
Outdated
var parsed movieOnList | ||
err = json.Unmarshal(data, &parsed) | ||
if err != nil { | ||
ctx.SendChain(message.Text("[EEROR2]:", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
告知用户是1还是2无意义,而且还拼错了。
plugin/movies/main.go
Outdated
return | ||
} | ||
if len(parsed.MovieList) == 0 { | ||
ctx.SendChain(message.Text("今日无电影上映")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ret
plugin/movies/main.go
Outdated
ctx.SendChain(message.ImageBytes(pic)) | ||
}) | ||
en.OnFullMatch("预售电影").SetBlock(true).Handle(func(ctx *zero.Ctx) { | ||
todayOnPic := todayPic.Get(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个高度相似,可以封装为一个函数。
No description provided.