Skip to content
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

feat:使用niu包,添加新玩法牛牛拍卖行 #1098

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (windows, amd64)

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 @@
}
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
Loading