Skip to content

将电影查询移至主仓库 #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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

fangliuyu
Copy link
Contributor

No description provided.

var (
mu sync.RWMutex
todayPic = ttl.NewCache[uint64, []byte](time.Hour * 12)
en = control.Register("movies", &ctrl.Options[*zero.Ctx]{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AutoRegister


var (
mu sync.RWMutex
todayPic = ttl.NewCache[uint64, []byte](time.Hour * 12)
Copy link
Member

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。

var parsed movieOnList
err = json.Unmarshal(data, &parsed)
if err != nil {
ctx.SendChain(message.Text("[EEROR2]:", err))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

告知用户是1还是2无意义,而且还拼错了。

return
}
if len(parsed.MovieList) == 0 {
ctx.SendChain(message.Text("今日无电影上映"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ret

ctx.SendChain(message.ImageBytes(pic))
})
en.OnFullMatch("预售电影").SetBlock(true).Handle(func(ctx *zero.Ctx) {
todayOnPic := todayPic.Get(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个高度相似,可以封装为一个函数。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants