Skip to content

Commit 894cf41

Browse files
authored
🎨 优化鉴赏图片, 文本重用 (#451)
1 parent 55aa869 commit 894cf41

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ print("run[CQ:image,file="+j["img"]+"]")
444444

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

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

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

plugin/bilibili/bilibili.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func init() {
5353
"- >user info [xxx]\n" +
5454
"- 查成分 [xxx]\n" +
5555
"- 查弹幕 [xxx]\n" +
56-
"- 设置b站cookie [xxx]\n" +
56+
"- 设置b站cookie b_ut=7;buvid3=0;i-wanna-go-back=-1;innersign=0;\n" +
5757
"- 更新vup",
5858
PublicDataFolder: "Bilibili",
5959
})

plugin/danbooru/main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ package deepdanbooru
44
import (
55
"crypto/md5"
66
"encoding/hex"
7+
"strings"
78

89
"github.com/FloatTech/floatbox/file"
910
"github.com/FloatTech/floatbox/img/writer"
1011
ctrl "github.com/FloatTech/zbpctrl"
1112
"github.com/FloatTech/zbputils/control"
13+
"github.com/FloatTech/zbputils/ctxext"
1214
zero "github.com/wdvxdr1123/ZeroBot"
1315
"github.com/wdvxdr1123/ZeroBot/message"
1416
"github.com/wdvxdr1123/ZeroBot/utils/helper"
@@ -29,7 +31,7 @@ func init() { // 插件主体
2931
Handle(func(ctx *zero.Ctx) {
3032
ctx.SendChain(message.Text("少女祈祷中..."))
3133
for _, url := range ctx.State["image_url"].([]string) {
32-
t, err := tagurl("", url)
34+
t, st, err := tagurl("", url)
3335
if err != nil {
3436
ctx.SendChain(message.Text("ERROR: ", err))
3537
return
@@ -39,7 +41,11 @@ func init() { // 插件主体
3941
if file.IsNotExist(f) {
4042
_ = writer.SavePNG2Path(f, t)
4143
}
42-
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + f))
44+
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+file.BOTPATH+"/"+f))}
45+
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text("tags: ", strings.Join(st.tseq, ","))))
46+
if id := ctx.Send(m).ID(); id == 0 {
47+
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
48+
}
4349
}
4450
})
4551
}

plugin/danbooru/tag.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (s *sorttags) Swap(i, j int) {
4646
s.tseq[j], s.tseq[i] = s.tseq[i], s.tseq[j]
4747
}
4848

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

75-
st := newsorttags(tags)
75+
st = newsorttags(tags)
7676
sort.Sort(st)
7777

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

0 commit comments

Comments
 (0)