Skip to content

Commit

Permalink
🎨 优化鉴赏图片, 文本重用 (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
guohuiyuan authored Oct 14, 2022
1 parent 55aa869 commit 894cf41
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ print("run[CQ:image,file="+j["img"]+"]")

- [x] 查弹幕 [xxx] 2 (最后一个参数是页码)

- [x] 设置b站cookie SESSDATA=82da790d,1663822823,06ecf\*31 (最好把cookie设全)
- [x] 设置b站cookie b_ut=7;buvid3=0;i-wanna-go-back=-1;innersign=0; (最好把cookie设全)

获取Cookie可以使用[这个工具](https://github.com/XiaoMiku01/login_bili_go)

Expand Down
2 changes: 1 addition & 1 deletion plugin/bilibili/bilibili.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func init() {
"- >user info [xxx]\n" +
"- 查成分 [xxx]\n" +
"- 查弹幕 [xxx]\n" +
"- 设置b站cookie [xxx]\n" +
"- 设置b站cookie b_ut=7;buvid3=0;i-wanna-go-back=-1;innersign=0;\n" +
"- 更新vup",
PublicDataFolder: "Bilibili",
})
Expand Down
10 changes: 8 additions & 2 deletions plugin/danbooru/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ package deepdanbooru
import (
"crypto/md5"
"encoding/hex"
"strings"

"github.com/FloatTech/floatbox/file"
"github.com/FloatTech/floatbox/img/writer"
ctrl "github.com/FloatTech/zbpctrl"
"github.com/FloatTech/zbputils/control"
"github.com/FloatTech/zbputils/ctxext"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
Expand All @@ -29,7 +31,7 @@ func init() { // 插件主体
Handle(func(ctx *zero.Ctx) {
ctx.SendChain(message.Text("少女祈祷中..."))
for _, url := range ctx.State["image_url"].([]string) {
t, err := tagurl("", url)
t, st, err := tagurl("", url)
if err != nil {
ctx.SendChain(message.Text("ERROR: ", err))
return
Expand All @@ -39,7 +41,11 @@ func init() { // 插件主体
if file.IsNotExist(f) {
_ = writer.SavePNG2Path(f, t)
}
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + f))
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+file.BOTPATH+"/"+f))}
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text("tags: ", strings.Join(st.tseq, ","))))
if id := ctx.Send(m).ID(); id == 0 {
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
}
}
})
}
4 changes: 2 additions & 2 deletions plugin/danbooru/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (s *sorttags) Swap(i, j int) {
s.tseq[j], s.tseq[i] = s.tseq[i], s.tseq[j]
}

func tagurl(name, u string) (im image.Image, err error) {
func tagurl(name, u string) (im image.Image, st *sorttags, err error) {
ch := make(chan []byte, 1)
go func() {
var data []byte
Expand All @@ -72,7 +72,7 @@ func tagurl(name, u string) (im image.Image, err error) {
}
longestlen++

st := newsorttags(tags)
st = newsorttags(tags)
sort.Sort(st)

_, err = file.GetLazyData(text.BoldFontFile, true)
Expand Down

0 comments on commit 894cf41

Please sign in to comment.