Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr4'
Browse files Browse the repository at this point in the history
  • Loading branch information
xyy0411 committed Jan 12, 2025
2 parents 38eae93 + dadb2ae commit 1557e4d
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 859 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,10 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] 赎牛牛

- [x] 牛牛拍卖行

- [x] 出售牛牛

- [x] 牛牛商店

- [x] 牛牛背包
Expand Down
46 changes: 22 additions & 24 deletions plugin/niuniu/draw.go
Original file line number Diff line number Diff line change
@@ -1,41 +1,34 @@
package niuniu

import (
"bytes"
"fmt"
"image"
"image/png"
"net/http"

"github.com/FloatTech/AnimeAPI/niu"

Check failure on line 10 in plugin/niuniu/draw.go

View workflow job for this annotation

GitHub Actions / Build binary CI (linux, 386)

no required module provides package github.com/FloatTech/AnimeAPI/niu; to add it:

Check failure on line 10 in plugin/niuniu/draw.go

View workflow job for this annotation

GitHub Actions / Build binary CI (linux, arm)

no required module provides package github.com/FloatTech/AnimeAPI/niu; to add it:

Check failure on line 10 in plugin/niuniu/draw.go

View workflow job for this annotation

GitHub Actions / Build binary CI (linux, arm64)

no required module provides package github.com/FloatTech/AnimeAPI/niu; to add it:
"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/rendercard"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/img/text"
zero "github.com/wdvxdr1123/ZeroBot"
)

type drawUserRanking struct {
name string
user *userInfo
}

type drawer []drawUserRanking

func (allUsers drawer) draw(t bool) (img image.Image, err error) {
fontbyte, err := file.GetLazyData(text.GlowSansFontFile, control.Md5File, true)
func processRankingImg(allUsers niu.BaseInfos, ctx *zero.Ctx, t bool) ([]byte, error) {
fontByte, err := file.GetLazyData(text.GlowSansFontFile, control.Md5File, true)
if err != nil {
return nil, err
}
var (
title string
s string
)
title = "牛牛深度排行"
s = "牛牛深度"
if t {
title = "牛牛长度排行"
s = "牛牛长度"
s := "牛牛长度"
title := "牛牛长度排行"
if !t {
s = "牛牛深度"
title = "牛牛深度排行"
}
ri := make([]*rendercard.RankInfo, len(allUsers))
for i, user := range allUsers {
resp, err := http.Get(fmt.Sprintf("https://q1.qlogo.cn/g?b=qq&nk=%d&s=100", user.user.UID))
resp, err := http.Get(fmt.Sprintf("https://q1.qlogo.cn/g?b=qq&nk=%d&s=100", user.UID))
if err != nil {
return nil, err
}
Expand All @@ -46,11 +39,16 @@ func (allUsers drawer) draw(t bool) (img image.Image, err error) {
}
ri[i] = &rendercard.RankInfo{
Avatar: decode,
TopLeftText: user.name,
BottomLeftText: fmt.Sprintf("QQ:%d", user.user.UID),
RightText: fmt.Sprintf("%s:%.2fcm", s, user.user.Length),
TopLeftText: ctx.CardOrNickName(user.UID),
BottomLeftText: fmt.Sprintf("QQ:%d", user.UID),
RightText: fmt.Sprintf("%s:%.2fcm", s, user.Length),
}
}
img, err = rendercard.DrawRankingCard(fontbyte, title, ri)
return
img, err := rendercard.DrawRankingCard(fontByte, title, ri)
if err != nil {
return nil, err
}
var buf bytes.Buffer
err = png.Encode(&buf, img)
return buf.Bytes(), err
}
Loading

0 comments on commit 1557e4d

Please sign in to comment.